adrema/tests/RequestFactories/UserRequestFactory.php

32 lines
810 B
PHP
Raw Normal View History

2024-08-02 15:12:47 +02:00
<?php
namespace Tests\RequestFactories;
use Worksome\RequestFactories\RequestFactory;
class UserRequestFactory extends RequestFactory
{
/**
* @return array{fee_id: int, name: string, children: array<int, array{amount: int, name: string}>}
*/
public function definition(): array
{
return [
'firstname' => $this->faker->firstName(),
'lastname' => $this->faker->lastName(),
'email' => $this->faker->safeEmail(),
];
}
public function name(string $name): self
{
[$firstname, $lastname] = explode(' ', $name ?: ' ');
return $this->state(['firstname' => $firstname, 'lastname' => $lastname]);
}
public function email(string $email): self
{
return $this->state(['email' => $email]);
}
}