diff --git a/src/Factories/Factory.php b/src/Factories/Factory.php index e5c2c60..9292960 100644 --- a/src/Factories/Factory.php +++ b/src/Factories/Factory.php @@ -257,6 +257,7 @@ public function published(bool|string $published): self { return match ($published) { 'random' => $this->sequence(fn (Sequence $sequence) => ['published' => collect([true, false])->random()]), + 'sequence' => $this->sequence(fn (Sequence $sequence) => ['published' => true], ['published' => false]), false, 'false' => $this->set('published', false), default => $this->set('published', true), }; diff --git a/tests/FactoryTest.php b/tests/FactoryTest.php index a73239e..2c5aafe 100644 --- a/tests/FactoryTest.php +++ b/tests/FactoryTest.php @@ -373,11 +373,14 @@ public function test_can_set_publish_state() $entry = FactoryTestEntryFactory::new()->published('false')->create(); $this->assertSame(false, $entry->published()); - $entry = FactoryTestEntryFactory::new()->site('random')->create(); + $entry = FactoryTestEntryFactory::new()->published('random')->create(); $this->assertContains($entry->published(), [true, false]); - $entry = FactoryTestEntryFactory::new()->site('anything')->create(); + $entry = FactoryTestEntryFactory::new()->published('anything')->create(); $this->assertSame(true, $entry->published()); + + $entries = FactoryTestEntryFactory::times(10)->published('sequence')->create(); + $entries->each(fn ($entry, $index) => $this->assertSame($index % 2 === 0 ? true : false, $entry->published())); } }