Skip to content

Commit 77dc3b4

Browse files
committed
Update README.md
1 parent 45507ad commit 77dc3b4

File tree

1 file changed

+0
-45
lines changed

1 file changed

+0
-45
lines changed

README.md

Lines changed: 0 additions & 45 deletions
Original file line numberDiff line numberDiff line change
@@ -462,48 +462,3 @@ Event::listen(StateTransitioned::class, function (StateTransitioned $event) {
462462
Log::info("Model {$event->model->getKey()} transitioned from {$event->from} to {$event->to}");
463463
});
464464
```
465-
466-
## Testing
467-
468-
The package includes a generic `StateModelFactory` that provides a flexible foundation for creating test models in specific states:
469-
470-
```php
471-
use NathanDunn\StateHistory\StateModelFactory;
472-
473-
class ArticleFactory extends StateModelFactory
474-
{
475-
protected $model = Article::class;
476-
477-
public function definition(): array
478-
{
479-
return [
480-
'title' => fake()->sentence(),
481-
'content' => fake()->paragraphs(3, true),
482-
];
483-
}
484-
485-
// Add your own helper methods
486-
public function draft(): static
487-
{
488-
return $this->inState('state', ArticleState::Draft);
489-
}
490-
491-
public function published(): static
492-
{
493-
return $this->inState('state', ArticleState::Published);
494-
}
495-
}
496-
497-
// Use your custom methods
498-
$draftArticle = Article::factory()->draft()->create();
499-
$publishedArticle = Article::factory()->published()->create();
500-
501-
// Or use the core inState method directly
502-
$reviewArticle = Article::factory()->inState('state', ArticleState::Review)->create();
503-
```
504-
505-
The factory provides one core method that works with any field and state:
506-
507-
- **`inState(string $field, BackedEnum|string $state)`** - Sets the `current_{field}` column to the specified state
508-
509-
This gives you complete flexibility to define your own helper methods based on your specific enums and state names.

0 commit comments

Comments
 (0)