@@ 141-157 (lines=17) @@ | ||
138 | * @access public |
|
139 | * @return void |
|
140 | */ |
|
141 | public function testGetKeyFromModel() |
|
142 | { |
|
143 | $this |
|
144 | ->given($this->newTestedInstance) |
|
145 | ->and($this->testedInstance->setMapping($this->getMappingArray())) |
|
146 | ->then |
|
147 | ->string($this->testedInstance->getKeyFromModel('Foo\Bar\Model\OrderItem')) |
|
148 | ->isEqualTo('order_items') |
|
149 | ||
150 | ->then($testedInstance = $this->testedInstance) |
|
151 | ->exception(function () use ($testedInstance) { |
|
152 | $testedInstance->getKeyFromModel('\Not\Viable\Classname'); |
|
153 | }) |
|
154 | ->isInstanceOf('Mapado\RestClientSdk\Exception\MappingException') |
|
155 | ->hasMessage('Model name \Not\Viable\Classname not found in mapping') |
|
156 | ; |
|
157 | } |
|
158 | ||
159 | /** |
|
160 | * testGetClassMetadata |
|
@@ 165-183 (lines=19) @@ | ||
162 | * @access public |
|
163 | * @return void |
|
164 | */ |
|
165 | public function testGetClassMetadata() |
|
166 | { |
|
167 | $this |
|
168 | ->given($testedInstance = $this->newTestedInstance) |
|
169 | ->and($this->testedInstance->setMapping($this->getMappingArray())) |
|
170 | ->then |
|
171 | ->object($this->testedInstance->getClassMetadata('Foo\Bar\Model\Order')) |
|
172 | ->isInstanceOf('Mapado\RestClientSdk\Mapping\ClassMetadata') |
|
173 | ->object($this->testedInstance->getClassMetadata('Foo\Bar\Model\Client')) |
|
174 | ->isInstanceOf('Mapado\RestClientSdk\Mapping\ClassMetadata') |
|
175 | ||
176 | ->then |
|
177 | ->exception(function () use ($testedInstance) { |
|
178 | $testedInstance->getClassMetadata('Foo\Bar'); |
|
179 | }) |
|
180 | ->isInstanceOf('Mapado\RestClientSdk\Exception\MappingException') |
|
181 | ->hasMessage('Foo\Bar model is not mapped') |
|
182 | ; |
|
183 | } |
|
184 | ||
185 | /** |
|
186 | * testHasClassMetadata |
|
@@ 191-206 (lines=16) @@ | ||
188 | * @access public |
|
189 | * @return void |
|
190 | */ |
|
191 | public function testHasClassMetadata() |
|
192 | { |
|
193 | $this |
|
194 | ->given($testedInstance = $this->newTestedInstance) |
|
195 | ->and($this->testedInstance->setMapping($this->getMappingArray())) |
|
196 | ->then |
|
197 | ->boolean($this->testedInstance->hasClassMetadata('Foo\Bar\Model\Order')) |
|
198 | ->isTrue() |
|
199 | ->boolean($this->testedInstance->hasClassMetadata('Foo\Bar\Model\Client')) |
|
200 | ->isTrue() |
|
201 | ||
202 | ->then |
|
203 | ->boolean($testedInstance->hasClassMetadata('Foo\Bar')) |
|
204 | ->isFalse() |
|
205 | ; |
|
206 | } |
|
207 | ||
208 | public function testMappingConfiguration() |
|
209 | { |