-
-
Notifications
You must be signed in to change notification settings - Fork 351
Expand file tree
/
Copy pathBooleanFieldTest.php
More file actions
64 lines (53 loc) · 1.49 KB
/
Copy pathBooleanFieldTest.php
File metadata and controls
64 lines (53 loc) · 1.49 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
<?php
/**
* League.Csv (https://csv.thephpleague.com)
*
* (c) Ignace Nyamagana Butera <nyamsprod@gmail.com>
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/
declare(strict_types=1);
namespace League\Csv\Schema;
use PHPUnit\Framework\Attributes\CoversClass;
use PHPUnit\Framework\Attributes\DataProvider;
use PHPUnit\Framework\TestCase;
#[CoversClass(BooleanField::class)]
final class BooleanFieldTest extends TestCase
{
private BooleanField $field;
protected function setUp(): void
{
$this->field = new BooleanField();
}
public static function provideBooleanValues(): array
{
return [
[true, true],
[false, false],
['true', true],
['false', false],
['1', true],
['0', false],
[' true ', true],
['', null],
[' ', null],
['foo', null],
[[], null],
[123, null],
];
}
#[DataProvider('provideBooleanValues')]
public function testParse(mixed $input, ?bool $expected): void
{
$result = $this->field->parse($input);
null === $expected
? self::assertNull($result)
: self::assertSame($expected, $result);
}
public function test_metadata_contains_expected_structure(): void
{
$field = new BooleanField();
self::assertTrue($field->metadata()->isEmpty());
}
}