1 | <?php |
||
18 | class FieldDataTypeTest extends Unit |
||
19 | { |
||
20 | /** |
||
21 | * @var FieldDataType |
||
22 | */ |
||
23 | private $dataType; |
||
24 | |||
25 | /** |
||
26 | * Set the dataType. |
||
27 | * |
||
28 | * @SuppressWarnings(PHPMD.CamelCaseMethodName) |
||
29 | * phpcs:disable PSR2.Methods.MethodDeclaration.Underscore |
||
30 | */ |
||
31 | protected function _before() |
||
32 | { |
||
33 | $this->dataType = new FieldDataType(); |
||
34 | } |
||
35 | |||
36 | //============================================================================================================== |
||
37 | //================================================= TESTS ==================================================== |
||
38 | //============================================================================================================== |
||
39 | |||
40 | /** |
||
41 | * Get mapper handle test. |
||
42 | */ |
||
43 | public function testGetMapperHandle() |
||
44 | { |
||
45 | $result = $this->dataType->getMapperHandle(); |
||
46 | |||
47 | $this->assertSame('modelMapper', $result); |
||
48 | } |
||
49 | |||
50 | /** |
||
51 | * Get records test. |
||
52 | */ |
||
53 | public function testGetRecords() |
||
54 | { |
||
55 | $records = [$this->getMockField()]; |
||
56 | |||
57 | Craft::$app->fields->expects($this->exactly(1)) |
||
58 | ->method('getAllFields') |
||
59 | ->willReturn($records); |
||
60 | |||
61 | $result = $this->dataType->getRecords(); |
||
62 | |||
63 | $this->assertSame($records, $result); |
||
64 | } |
||
65 | |||
66 | //============================================================================================================== |
||
67 | //================================================ HELPERS =================================================== |
||
68 | //============================================================================================================== |
||
69 | |||
70 | /** |
||
71 | * @return Mock|Field |
||
72 | */ |
||
73 | private function getMockField() |
||
74 | { |
||
75 | return $this->getMockBuilder(Field::class)->getMock(); |
||
76 | } |
||
77 | } |
||
78 |