Skip to content

Commit

Permalink
Revert "convert to pest"
Browse files Browse the repository at this point in the history
This reverts commit 3e27dfb.
  • Loading branch information
edalzell committed Jan 28, 2025
1 parent 0efe678 commit 278c107
Show file tree
Hide file tree
Showing 13 changed files with 1,902 additions and 1,657 deletions.
8 changes: 3 additions & 5 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -45,10 +45,9 @@
},
"require-dev": {
"mockery/mockery": "^1.3.1",
"nunomaduro/collision": "^6.0 || ^7.0 || ^8.0",
"pestphp/pest-plugin-drift": "^3.0",
"phpunit/phpunit": "^9.0 || ^10.0 || ^11.0",
"orchestra/testbench": "^7.0 || ^8.0 || ^9.0",
"nunomaduro/collision": "^6.0 || ^7.0",
"phpunit/phpunit": "^9.0 || ^10.0",
"orchestra/testbench": "^7.0 || ^8.0",
"spatie/laravel-ray": "^1.35",
"spatie/test-time": "^1.2"
},
Expand All @@ -57,7 +56,6 @@
"preferred-install": "dist",
"sort-packages": true,
"allow-plugins": {
"pestphp/pest-plugin": true,
"pixelfear/composer-dist-plugin": true
}
},
Expand Down
87 changes: 53 additions & 34 deletions tests/Feature/EventsOffsetTest.php
Original file line number Diff line number Diff line change
@@ -1,31 +1,43 @@
<?php

uses(\TransformStudios\Events\Tests\TestCase::class);
namespace TransformStudios\Events\Tests\Feature;

use Illuminate\Support\Carbon;
use Statamic\Facades\Cascade;
use Statamic\Facades\Entry;
use TransformStudios\Events\Tags\Events;

uses(\TransformStudios\Events\Tests\PreventSavingStacheItemsToDisk::class);

beforeEach(function () {
Entry::make()
->collection('events')
->slug('recurring-event')
->id('recurring-event')
->data([
'title' => 'Recurring Event',
'start_date' => Carbon::now()->toDateString(),
'start_time' => '11:00',
'end_time' => '12:00',
'recurrence' => 'weekly',
'categories' => ['one'],
])->save();

$this->tag = app(Events::class);
});

test('can offset upcoming occurrences', function () {
use TransformStudios\Events\Tests\PreventSavingStacheItemsToDisk;
use TransformStudios\Events\Tests\TestCase;

class EventsOffsetTest extends TestCase
{
use PreventSavingStacheItemsToDisk;

private Events $tag;

public function setUp(): void
{
parent::setUp();

Entry::make()
->collection('events')
->slug('recurring-event')
->id('recurring-event')
->data([
'title' => 'Recurring Event',
'start_date' => Carbon::now()->toDateString(),
'start_time' => '11:00',
'end_time' => '12:00',
'recurrence' => 'weekly',
'categories' => ['one'],
])->save();

$this->tag = app(Events::class);
}

/** @test */
public function canOffsetUpcomingOccurrences()
{
Carbon::setTestNow(now()->setTimeFromTimeString('10:00'));

$this->tag
Expand All @@ -38,10 +50,12 @@

$occurrences = $this->tag->upcoming();

expect($occurrences)->toHaveCount(3);
});
$this->assertCount(3, $occurrences);
}

test('can offset between occurrences', function () {
/** @test */
public function canOffsetBetweenOccurrences()
{
Carbon::setTestNow(now()->setTimeFromTimeString('10:00'));

$this->tag->setContext([])
Expand All @@ -54,10 +68,12 @@

$occurrences = $this->tag->between();

expect($occurrences)->toHaveCount(2);
});
$this->assertCount(2, $occurrences);
}

test('can offset today occurrences', function () {
/** @test */
public function canOffsetTodayOccurrences()
{
Carbon::setTestNow(now()->setTimeFromTimeString('12:01'));

Entry::make()
Expand All @@ -76,7 +92,7 @@
'offset' => 1,
]);

expect($this->tag->today())->toHaveCount(1);
$this->assertCount(1, $this->tag->today());

$this->tag->setContext([])
->setParameters([
Expand All @@ -85,10 +101,12 @@
'offset' => 1,
]);

expect($this->tag->today())->toHaveCount(0);
});
$this->assertCount(0, $this->tag->today());
}

test('can offset single day occurrences', function () {
/** @test */
public function canOffsetSingleDayOccurrences()
{
Carbon::setTestNow(now()->setTimeFromTimeString('10:00'));

$this->tag->setContext([])
Expand All @@ -97,5 +115,6 @@
'offset' => 1,
]);

expect($this->tag->today())->toHaveCount(0);
});
$this->assertCount(0, $this->tag->today());
}
}
Loading

0 comments on commit 278c107

Please sign in to comment.