2023-12-26 20:06:57 +01:00
|
|
|
<?php
|
|
|
|
|
|
|
|
namespace Tests\Feature\Form;
|
|
|
|
|
|
|
|
use App\Form\Fields\Field;
|
2024-02-16 14:32:16 +01:00
|
|
|
use App\Form\Enums\NamiType;
|
2023-12-26 20:06:57 +01:00
|
|
|
use Worksome\RequestFactories\RequestFactory;
|
2024-03-14 23:54:41 +01:00
|
|
|
use App\Form\Enums\SpecialType;
|
2023-12-26 20:06:57 +01:00
|
|
|
|
|
|
|
/**
|
|
|
|
* @method self name(string $name)
|
|
|
|
* @method self key(string $key)
|
2024-07-14 00:11:18 +02:00
|
|
|
* @method self required(bool|string $isRequired)
|
2023-12-26 20:06:57 +01:00
|
|
|
* @method self rows(int $rows)
|
|
|
|
* @method self columns(array{mobile: int, tablet: int, desktop: int} $rows)
|
2023-12-27 00:42:17 +01:00
|
|
|
* @method self default(mixed $default)
|
2024-02-06 01:24:24 +01:00
|
|
|
* @method self options(array<int, string> $options)
|
|
|
|
* @method self maxToday(bool $maxToday)
|
2024-02-09 00:21:33 +01:00
|
|
|
* @method self parentGroup(int $groupId)
|
|
|
|
* @method self parentField(string $fieldKey)
|
2024-02-16 14:32:16 +01:00
|
|
|
* @method self namiType(?NamiType $type)
|
2024-02-19 02:10:58 +01:00
|
|
|
* @method self forMembers(bool $forMembers)
|
2024-03-14 23:54:41 +01:00
|
|
|
* @method self specialType(SpecialType $specialType)
|
2024-04-10 00:00:20 +02:00
|
|
|
* @method self hint(string $hint)
|
2024-04-15 16:37:36 +02:00
|
|
|
* @method self min(int $min)
|
|
|
|
* @method self max(int $max)
|
2024-04-17 10:19:56 +02:00
|
|
|
* @method self allowcustom(bool $allowcustom)
|
2024-06-19 00:04:28 +02:00
|
|
|
* @method self emptyOptionValue(string $emptyOptionValue)
|
2024-06-07 01:02:07 +02:00
|
|
|
* @method self intro(string $intro)
|
2023-12-26 20:06:57 +01:00
|
|
|
*/
|
|
|
|
class FormtemplateFieldRequest extends RequestFactory
|
|
|
|
{
|
|
|
|
/**
|
|
|
|
* @return array<string, mixed>
|
|
|
|
*/
|
|
|
|
public function definition(): array
|
|
|
|
{
|
|
|
|
return [
|
|
|
|
'name' => $this->faker->words(5, true),
|
|
|
|
'key' => str($this->faker->words(5, true))->snake()->toString(),
|
|
|
|
'columns' => ['mobile' => 2, 'tablet' => 4, 'desktop' => 6],
|
2024-02-18 18:48:31 +01:00
|
|
|
'nami_type' => null,
|
2024-02-18 18:58:28 +01:00
|
|
|
'for_members' => true,
|
2024-04-19 11:38:53 +02:00
|
|
|
'hint' => null,
|
2023-12-26 20:06:57 +01:00
|
|
|
];
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* @param string|class-string<Field> $field
|
|
|
|
*/
|
2024-02-04 03:19:28 +01:00
|
|
|
public static function type(string $field): self
|
2023-12-26 20:06:57 +01:00
|
|
|
{
|
2024-02-04 03:19:28 +01:00
|
|
|
|
2023-12-26 20:06:57 +01:00
|
|
|
if (!$field || !class_exists($field)) {
|
2024-02-04 03:19:28 +01:00
|
|
|
return self::new(['type' => $field]);
|
2023-12-26 20:06:57 +01:00
|
|
|
}
|
|
|
|
|
2024-02-04 03:19:28 +01:00
|
|
|
return self::new([
|
2023-12-26 20:06:57 +01:00
|
|
|
'type' => $field::type(),
|
2024-03-13 15:48:08 +01:00
|
|
|
'value' => $field::default(),
|
2024-02-04 03:19:28 +01:00
|
|
|
...$field::fake((new static())->faker),
|
2023-12-26 20:06:57 +01:00
|
|
|
]);
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* @param mixed $args
|
|
|
|
*/
|
|
|
|
public function __call(string $method, $args): self
|
|
|
|
{
|
2024-02-06 01:24:09 +01:00
|
|
|
return $this->state([(string) str($method)->snake() => $args[0]]);
|
2023-12-26 20:06:57 +01:00
|
|
|
}
|
|
|
|
}
|