-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
test: turn EventDate tests into Scheduling tests
- Loading branch information
1 parent
d76fdb0
commit 2dec229
Showing
4 changed files
with
88 additions
and
103 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
78 changes: 0 additions & 78 deletions
78
test/Service/GraphQL/Resolver/Resource/ResourceEventDateResolverTest.php
This file was deleted.
Oops, something went wrong.
67 changes: 67 additions & 0 deletions
67
test/Service/GraphQL/Resolver/Resource/ResourceSchedulingResolverTest.php
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,67 @@ | ||
<?php | ||
|
||
declare(strict_types=1); | ||
|
||
namespace Atoolo\EventsCalendar\Test\Service\GraphQL\Resolver\Resource; | ||
|
||
use Atoolo\EventsCalendar\Scheduling; | ||
use Atoolo\EventsCalendar\SchedulingFactory; | ||
use Atoolo\EventsCalendar\Service\GraphQL\Factory\EventDateFactory; | ||
use Atoolo\EventsCalendar\Service\GraphQL\Resolver\Resource\ResourceEventDateResolver; | ||
use Atoolo\EventsCalendar\Service\GraphQL\Resolver\Resource\ResourceSchedulingResolver; | ||
use Atoolo\EventsCalendar\Service\GraphQL\Types\EventDate; | ||
use Atoolo\Resource\DataBag; | ||
use Atoolo\Resource\Resource; | ||
use Atoolo\Resource\ResourceLanguage; | ||
use DateTime; | ||
use PHPUnit\Framework\Attributes\CoversClass; | ||
use PHPUnit\Framework\MockObject\MockObject; | ||
use PHPUnit\Framework\TestCase; | ||
|
||
#[CoversClass(ResourceSchedulingResolver::class)] | ||
class ResourceEventDateResolverTest extends TestCase | ||
{ | ||
private ResourceSchedulingResolver $resolver; | ||
|
||
private SchedulingFactory&MockObject $schedulingFactory; | ||
|
||
public function setUp(): void | ||
{ | ||
$this->schedulingFactory = $this->createMock( | ||
SchedulingFactory::class, | ||
); | ||
$this->resolver = new ResourceSchedulingResolver( | ||
$this->schedulingFactory, | ||
); | ||
} | ||
|
||
public function testGetEventDates(): void | ||
{ | ||
$resource = $this->createResource([]); | ||
$schedulingsExpected = [new Scheduling(new DateTime())]; | ||
$this->schedulingFactory | ||
->method('create') | ||
->willReturn($schedulingsExpected); | ||
$schedulings = $this->resolver->getSchedulings($resource); | ||
$this->assertNotEmpty($schedulings); | ||
$this->assertEquals( | ||
$schedulingsExpected, | ||
$schedulings, | ||
); | ||
} | ||
|
||
/** | ||
* @param array<string,mixed> $data | ||
*/ | ||
private function createResource(array $data): Resource | ||
{ | ||
return new Resource( | ||
$data['url'] ?? '', | ||
$data['id'] ?? '', | ||
$data['name'] ?? '', | ||
$data['objectType'] ?? '', | ||
ResourceLanguage::default(), | ||
new DataBag($data), | ||
); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters