@@ 78-99 (lines=22) @@ | ||
75 | /** |
|
76 | * @test |
|
77 | */ |
|
78 | public function shouldParseObject() |
|
79 | { |
|
80 | //given |
|
81 | $parser = $this->parser('object $user { string $name bool $isActive }'); |
|
82 | ||
83 | //when |
|
84 | $nodes = $parser->S(); |
|
85 | ||
86 | //then |
|
87 | Assert::thatArray($nodes) |
|
88 | ->extracting('type', 'name', 'isArray') |
|
89 | ->containsExactly(['object', '$user', false]); |
|
90 | ||
91 | /** @var Node $node */ |
|
92 | $node = Arrays::first($nodes); |
|
93 | Assert::thatArray($node->getElements()) |
|
94 | ->extracting('type', 'name', 'isArray', 'elements') |
|
95 | ->containsExactly( |
|
96 | ['string', '$name', false, []], |
|
97 | ['bool', '$isActive', false, []] |
|
98 | ); |
|
99 | } |
|
100 | ||
101 | /** |
|
102 | * @test |
|
@@ 104-125 (lines=22) @@ | ||
101 | /** |
|
102 | * @test |
|
103 | */ |
|
104 | public function shouldParseObjectArray() |
|
105 | { |
|
106 | //given |
|
107 | $parser = $this->parser('object[] $user { string $name bool $isActive }'); |
|
108 | ||
109 | //when |
|
110 | $nodes = $parser->S(); |
|
111 | ||
112 | //then |
|
113 | Assert::thatArray($nodes) |
|
114 | ->extracting('type', 'name', 'isArray') |
|
115 | ->containsExactly(['object', '$user', true]); |
|
116 | ||
117 | /** @var Node $node */ |
|
118 | $node = Arrays::first($nodes); |
|
119 | Assert::thatArray($node->getElements()) |
|
120 | ->extracting('type', 'name', 'isArray', 'elements') |
|
121 | ->containsExactly( |
|
122 | ['string', '$name', false, []], |
|
123 | ['bool', '$isActive', false, []] |
|
124 | ); |
|
125 | } |
|
126 | ||
127 | /** |
|
128 | * @test |
|
@@ 164-185 (lines=22) @@ | ||
161 | /** |
|
162 | * @test |
|
163 | */ |
|
164 | public function shouldParseObjectWithArrayInsideAttribute() |
|
165 | { |
|
166 | //given |
|
167 | $parser = $this->parser('object $user { string[] $name bool $isActive }'); |
|
168 | ||
169 | //when |
|
170 | $nodes = $parser->S(); |
|
171 | ||
172 | //then |
|
173 | Assert::thatArray($nodes) |
|
174 | ->extracting('type', 'name', 'isArray') |
|
175 | ->containsExactly(['object', '$user', false]); |
|
176 | ||
177 | /** @var Node $node */ |
|
178 | $node = Arrays::first($nodes); |
|
179 | Assert::thatArray($node->getElements()) |
|
180 | ->extracting('type', 'name', 'isArray', 'elements') |
|
181 | ->containsExactly( |
|
182 | ['string', '$name', true, []], |
|
183 | ['bool', '$isActive', false, []] |
|
184 | ); |
|
185 | } |
|
186 | ||
187 | /** |
|
188 | * @test |