zenstruck /
foundry
| 1 | <?php |
||
| 2 | |||
| 3 | namespace Zenstruck\Foundry\Tests\Unit; |
||
| 4 | |||
| 5 | use PHPUnit\Framework\TestCase; |
||
|
0 ignored issues
–
show
|
|||
| 6 | use Zenstruck\Foundry\FactoryCollection; |
||
| 7 | use Zenstruck\Foundry\Test\Factories; |
||
| 8 | use Zenstruck\Foundry\Tests\Fixtures\Entity\Category; |
||
| 9 | use function Zenstruck\Foundry\factory; |
||
| 10 | |||
| 11 | /** |
||
| 12 | * @author Kevin Bond <[email protected]> |
||
| 13 | */ |
||
| 14 | final class FactoryCollectionTest extends TestCase |
||
| 15 | { |
||
| 16 | use Factories; |
||
| 17 | |||
| 18 | /** |
||
| 19 | * @test |
||
| 20 | */ |
||
| 21 | public function can_create_with_static_size(): void |
||
| 22 | { |
||
| 23 | $collection = new FactoryCollection(factory(Category::class), 2); |
||
| 24 | |||
| 25 | $this->assertCount(2, $collection->create()); |
||
| 26 | $this->assertCount(2, $collection->create()); |
||
| 27 | $this->assertCount(2, $collection->create()); |
||
| 28 | $this->assertCount(2, $collection->create()); |
||
| 29 | $this->assertCount(2, $collection->create()); |
||
| 30 | } |
||
| 31 | |||
| 32 | /** |
||
| 33 | * @test |
||
| 34 | */ |
||
| 35 | public function can_create_with_random_range(): void |
||
| 36 | { |
||
| 37 | $collection = new FactoryCollection(factory(Category::class), 0, 3); |
||
| 38 | $counts = []; |
||
| 39 | |||
| 40 | while (4 !== \count(\array_unique($counts))) { |
||
| 41 | $counts[] = \count($collection->create()); |
||
| 42 | } |
||
| 43 | |||
| 44 | $this->assertCount(4, \array_unique($counts)); |
||
| 45 | $this->assertContains(0, $counts); |
||
| 46 | $this->assertContains(1, $counts); |
||
| 47 | $this->assertContains(2, $counts); |
||
| 48 | $this->assertContains(3, $counts); |
||
| 49 | $this->assertNotContains(4, $counts); |
||
| 50 | $this->assertNotContains(5, $counts); |
||
| 51 | } |
||
| 52 | |||
| 53 | /** |
||
| 54 | * @test |
||
| 55 | */ |
||
| 56 | public function min_must_be_less_than_or_equal_to_max(): void |
||
| 57 | { |
||
| 58 | $this->expectException(\InvalidArgumentException::class); |
||
| 59 | $this->expectExceptionMessage('Min must be less than max.'); |
||
| 60 | |||
| 61 | new FactoryCollection(factory(Category::class), 4, 3); |
||
| 62 | } |
||
| 63 | } |
||
| 64 |
The issue could also be caused by a filter entry in the build configuration. If the path has been excluded in your configuration, e.g.
excluded_paths: ["lib/*"], you can move it to the dependency path list as follows:For further information see https://scrutinizer-ci.com/docs/tools/php/php-scrutinizer/#list-dependency-paths