laravel-nami-api/tests/Factories/CourseFactory.php

35 lines
882 B
PHP
Raw Normal View History

2023-02-07 02:30:00 +01:00
<?php
namespace Zoomyboy\LaravelNami\Tests\Factories;
use Carbon\Carbon;
use Worksome\RequestFactories\RequestFactory;
use Zoomyboy\LaravelNami\Data\Course;
class CourseFactory extends RequestFactory
{
public function definition(): array
{
return [
'courseId' => $this->faker->numberBetween(100, 200),
'id' => $this->faker->numberBetween(100, 200),
'organizer' => $this->faker->word(),
'eventName' => $this->faker->word(),
'completedAt' => Carbon::parse($this->faker->dateTime())->startOfDay(),
];
}
/**
* @param array<string, mixed> $attributes
*/
public function toCourse(array $attributes = []): Course
2023-02-07 02:30:00 +01:00
{
return Course::from($this->create($attributes));
}
public function id(int $id): self
{
return $this->state(['id' => $id]);
}
}