-
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.
- Loading branch information
1 parent
219c4f7
commit ae03ded
Showing
11 changed files
with
235 additions
and
20 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
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -20,19 +20,20 @@ | |
/** | ||
* @author Silas Joisten <[email protected]> | ||
* | ||
* @method array assetResponse(array $overrides = []) | ||
* @method array datasourceDimensionResponse(array $overrides = []) | ||
* @method array datasourceEntriesResponse(array $overrides = []) | ||
* @method array datasourceEntryResponse(array $overrides = []) | ||
* @method array datasourceResponse(array $overrides = []) | ||
* @method array datasourcesResponse(array $overrides = []) | ||
* @method array linkAlternateResponse(array $overrides = []) | ||
* @method array linkResponse(array $overrides = []) | ||
* @method array linksResponse(array $overrides = []) | ||
* @method array spaceResponse(array $overrides = []) | ||
* @method array storiesResponse(array $overrides = []) | ||
* @method array storyResponse(array $overrides = []) | ||
* @method array tagsResponse(array $overrides = []) | ||
* @method array assetResponse(array $overrides = []) | ||
* @method array datasourceDimensionResponse(array $overrides = []) | ||
* @method array datasourceEntriesResponse(array $overrides = []) | ||
* @method array datasourceEntryResponse(array $overrides = []) | ||
* @method array datasourceResponse(array $overrides = []) | ||
* @method array datasourcesResponse(array $overrides = []) | ||
* @method array linkAlternateResponse(array $overrides = []) | ||
* @method array linkResponse(array $overrides = []) | ||
* @method array linksResponse(array $overrides = []) | ||
* @method string relation() | ||
* @method array spaceResponse(array $overrides = []) | ||
* @method array storiesResponse(array $overrides = []) | ||
* @method array storyResponse(array $overrides = []) | ||
* @method array tagsResponse(array $overrides = []) | ||
*/ | ||
final class Generator extends BaseGenerator | ||
{ | ||
|
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
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
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
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
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
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
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 |
---|---|---|
|
@@ -21,7 +21,6 @@ | |
use Storyblok\Api\Resolver\ResolverInterface; | ||
use Storyblok\Api\Response\StoriesResponse; | ||
use Storyblok\Api\Response\StoryResponse; | ||
use Webmozart\Assert\Assert; | ||
|
||
/** | ||
* @author Silas Joisten <[email protected]> | ||
|
130 changes: 130 additions & 0 deletions
130
tests/Unit/Domain/Value/Resolver/RelationCollectionTest.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,130 @@ | ||
<?php | ||
|
||
declare(strict_types=1); | ||
|
||
/** | ||
* This file is part of Storyblok-Api. | ||
* | ||
* (c) SensioLabs Deutschland <[email protected]> | ||
* | ||
* For the full copyright and license information, please view the LICENSE | ||
* file that was distributed with this source code. | ||
*/ | ||
|
||
namespace Storyblok\Api\Tests\Unit\Domain\Value\Resolver; | ||
|
||
use PHPUnit\Framework\TestCase; | ||
use Storyblok\Api\Domain\Value\Resolver\Relation; | ||
use Storyblok\Api\Domain\Value\Resolver\RelationCollection; | ||
use Storyblok\Api\Tests\Util\FakerTrait; | ||
|
||
/** | ||
* @author Silas Joisten <[email protected]> | ||
*/ | ||
final class RelationCollectionTest extends TestCase | ||
{ | ||
use FakerTrait; | ||
|
||
/** | ||
* @test | ||
*/ | ||
public function add(): void | ||
{ | ||
$faker = self::faker(); | ||
|
||
$collection = new RelationCollection(); | ||
self::assertEmpty($collection); | ||
|
||
$collection->add(new Relation($faker->relation())); | ||
self::assertCount(1, $collection); | ||
} | ||
|
||
/** | ||
* @test | ||
*/ | ||
public function remove(): void | ||
{ | ||
$faker = self::faker(); | ||
|
||
$relation = new Relation($faker->relation()); | ||
|
||
$collection = new RelationCollection([$relation]); | ||
self::assertCount(1, $collection); | ||
|
||
$collection->remove($relation); | ||
self::assertEmpty($collection); | ||
} | ||
|
||
/** | ||
* @test | ||
*/ | ||
public function hasReturnsTrue(): void | ||
{ | ||
$faker = self::faker(); | ||
|
||
$relation = new Relation($faker->relation()); | ||
|
||
$collection = new RelationCollection([$relation, new Relation($faker->relation())]); | ||
|
||
self::assertTrue($collection->has($relation)); | ||
} | ||
|
||
/** | ||
* @test | ||
*/ | ||
public function hasReturnsFalse(): void | ||
{ | ||
$faker = self::faker(); | ||
|
||
$collection = new RelationCollection([new Relation($faker->relation())]); | ||
|
||
self::assertFalse($collection->has(new Relation($faker->relation()))); | ||
} | ||
|
||
/** | ||
* @test | ||
*/ | ||
public function isCountable(): void | ||
{ | ||
$faker = self::faker(); | ||
|
||
$relation = new Relation($faker->relation()); | ||
|
||
$collection = new RelationCollection([$relation]); | ||
|
||
self::assertSame(1, $collection->count()); | ||
} | ||
|
||
/** | ||
* @test | ||
*/ | ||
public function toStringMethod(): void | ||
{ | ||
$faker = self::faker(); | ||
|
||
$relations = [ | ||
new Relation($relation1 = $faker->relation()), | ||
new Relation($relation2 = $faker->relation()), | ||
new Relation($relation3 = $faker->relation()), | ||
]; | ||
|
||
$collection = new RelationCollection($relations); | ||
|
||
self::assertSame(implode(',', [$relation1, $relation2, $relation3]), $collection->toString()); | ||
} | ||
|
||
/** | ||
* @test | ||
*/ | ||
public function getIterator(): void | ||
{ | ||
$faker = self::faker(); | ||
|
||
$relations = [ | ||
new Relation($faker->relation()), | ||
new Relation($faker->relation()), | ||
]; | ||
|
||
self::assertInstanceOf(\ArrayIterator::class, (new RelationCollection($relations))->getIterator()); | ||
} | ||
} |
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,50 @@ | ||
<?php | ||
|
||
declare(strict_types=1); | ||
|
||
/** | ||
* This file is part of Storyblok-Api. | ||
* | ||
* (c) SensioLabs Deutschland <[email protected]> | ||
* | ||
* For the full copyright and license information, please view the LICENSE | ||
* file that was distributed with this source code. | ||
*/ | ||
|
||
namespace Storyblok\Api\Tests\Unit\Domain\Value\Resolver; | ||
|
||
use PHPUnit\Framework\TestCase; | ||
use Storyblok\Api\Domain\Value\Resolver\Relation; | ||
use Storyblok\Api\Tests\Util\FakerTrait; | ||
|
||
/** | ||
* @author Silas Joisten <[email protected]> | ||
*/ | ||
final class RelationTest extends TestCase | ||
{ | ||
use FakerTrait; | ||
|
||
/** | ||
* @test | ||
*/ | ||
public function value(): void | ||
{ | ||
$value = self::faker()->relation(); | ||
|
||
self::assertSame($value, (new Relation($value))->value); | ||
} | ||
|
||
/** | ||
* @test | ||
* | ||
* @dataProvider \Ergebnis\DataProvider\StringProvider::arbitrary() | ||
* @dataProvider \Ergebnis\DataProvider\StringProvider::blank() | ||
* @dataProvider \Ergebnis\DataProvider\StringProvider::empty() | ||
*/ | ||
public function valueInvalid(string $value): void | ||
{ | ||
self::expectException(\InvalidArgumentException::class); | ||
|
||
new Relation($value); | ||
} | ||
} |
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