| @@ 176-192 (lines=17) @@ | ||
| 173 | * @access public |
|
| 174 | * @return void |
|
| 175 | */ |
|
| 176 | public function testGetKeyFromModel() |
|
| 177 | { |
|
| 178 | $this |
|
| 179 | ->given($this->newTestedInstance) |
|
| 180 | ->and($this->testedInstance->setMapping($this->getMappingArray())) |
|
| 181 | ->then |
|
| 182 | ->string($this->testedInstance->getKeyFromModel('Foo\Bar\Model\OrderItem')) |
|
| 183 | ->isEqualTo('order_items') |
|
| 184 | ||
| 185 | ->then($testedInstance = $this->testedInstance) |
|
| 186 | ->exception(function () use ($testedInstance) { |
|
| 187 | $testedInstance->getKeyFromModel('\Not\Viable\Classname'); |
|
| 188 | }) |
|
| 189 | ->isInstanceOf('Mapado\RestClientSdk\Exception\MappingException') |
|
| 190 | ->hasMessage('Model name \Not\Viable\Classname not found in mapping') |
|
| 191 | ; |
|
| 192 | } |
|
| 193 | ||
| 194 | /** |
|
| 195 | * testGetClassMetadata |
|
| @@ 200-218 (lines=19) @@ | ||
| 197 | * @access public |
|
| 198 | * @return void |
|
| 199 | */ |
|
| 200 | public function testGetClassMetadata() |
|
| 201 | { |
|
| 202 | $this |
|
| 203 | ->given($testedInstance = $this->newTestedInstance) |
|
| 204 | ->and($this->testedInstance->setMapping($this->getMappingArray())) |
|
| 205 | ->then |
|
| 206 | ->object($this->testedInstance->getClassMetadata('Foo\Bar\Model\Order')) |
|
| 207 | ->isInstanceOf('Mapado\RestClientSdk\Mapping\ClassMetadata') |
|
| 208 | ->object($this->testedInstance->getClassMetadata('Foo\Bar\Model\Client')) |
|
| 209 | ->isInstanceOf('Mapado\RestClientSdk\Mapping\ClassMetadata') |
|
| 210 | ||
| 211 | ->then |
|
| 212 | ->exception(function () use ($testedInstance) { |
|
| 213 | $testedInstance->getClassMetadata('Foo\Bar'); |
|
| 214 | }) |
|
| 215 | ->isInstanceOf('Mapado\RestClientSdk\Exception\MappingException') |
|
| 216 | ->hasMessage('Foo\Bar model is not mapped') |
|
| 217 | ; |
|
| 218 | } |
|
| 219 | ||
| 220 | /** |
|
| 221 | * testHasClassMetadata |
|
| @@ 226-241 (lines=16) @@ | ||
| 223 | * @access public |
|
| 224 | * @return void |
|
| 225 | */ |
|
| 226 | public function testHasClassMetadata() |
|
| 227 | { |
|
| 228 | $this |
|
| 229 | ->given($testedInstance = $this->newTestedInstance) |
|
| 230 | ->and($this->testedInstance->setMapping($this->getMappingArray())) |
|
| 231 | ->then |
|
| 232 | ->boolean($this->testedInstance->hasClassMetadata('Foo\Bar\Model\Order')) |
|
| 233 | ->isTrue() |
|
| 234 | ->boolean($this->testedInstance->hasClassMetadata('Foo\Bar\Model\Client')) |
|
| 235 | ->isTrue() |
|
| 236 | ||
| 237 | ->then |
|
| 238 | ->boolean($testedInstance->hasClassMetadata('Foo\Bar')) |
|
| 239 | ->isFalse() |
|
| 240 | ; |
|
| 241 | } |
|
| 242 | ||
| 243 | public function testMappingConfiguration() |
|
| 244 | { |
|