You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
47 lines
1.3 KiB
47 lines
1.3 KiB
|
4 weeks ago
|
<?php
|
||
|
|
|
||
|
|
namespace Tests\Unit;
|
||
|
|
|
||
|
|
use App\Support\SignupSchemaLayout;
|
||
|
|
use Tests\TestCase;
|
||
|
|
|
||
|
|
class SignupSchemaLayoutTest extends TestCase
|
||
|
|
{
|
||
|
|
public function test_fields_tolerate_missing_list_and_filter_keys(): void
|
||
|
|
{
|
||
|
|
$fields = SignupSchemaLayout::fields([
|
||
|
|
[
|
||
|
|
'key' => 'contact_email',
|
||
|
|
'type' => 'email',
|
||
|
|
'label' => '邮箱',
|
||
|
|
],
|
||
|
|
[
|
||
|
|
'key' => 'event_location',
|
||
|
|
'type' => 'select',
|
||
|
|
'label' => '意向参赛地点',
|
||
|
|
'list' => true,
|
||
|
|
'filter' => true,
|
||
|
|
],
|
||
|
|
]);
|
||
|
|
|
||
|
|
$this->assertCount(2, $fields);
|
||
|
|
$this->assertFalse($fields[0]['list']);
|
||
|
|
$this->assertFalse($fields[0]['filter']);
|
||
|
|
$this->assertTrue($fields[1]['list']);
|
||
|
|
$this->assertTrue($fields[1]['filter']);
|
||
|
|
$this->assertSame(['event_location'], array_column(SignupSchemaLayout::listFields([
|
||
|
|
[
|
||
|
|
'key' => 'contact_email',
|
||
|
|
'type' => 'email',
|
||
|
|
'label' => '邮箱',
|
||
|
|
],
|
||
|
|
[
|
||
|
|
'key' => 'event_location',
|
||
|
|
'type' => 'select',
|
||
|
|
'label' => '意向参赛地点',
|
||
|
|
'list' => true,
|
||
|
|
],
|
||
|
|
]), 'key'));
|
||
|
|
}
|
||
|
|
}
|