| Conditions | 5 |
| Paths | 4 |
| Total Lines | 24 |
| Code Lines | 17 |
| Lines | 0 |
| Ratio | 0 % |
| Changes | 0 | ||
| 1 | <?php |
||
| 7 | public function runGetterSetterTests($testClass) |
||
| 8 | { |
||
| 9 | $reflection = new \ReflectionClass($testClass); |
||
| 10 | $properties = $reflection->getProperties(); |
||
| 11 | foreach ($properties as $property) { |
||
| 12 | $name = $property->getName(); |
||
| 13 | $getMethod = 'get'.ucfirst($name); |
||
| 14 | $setMethod = 'set'.ucfirst($name); |
||
| 15 | self::assertTrue($reflection->hasMethod($getMethod), $getMethod); |
||
| 16 | self::assertTrue($reflection->hasMethod($setMethod), $setMethod); |
||
| 17 | |||
| 18 | $obj = new $testClass(); |
||
| 19 | |||
| 20 | $parameters = $reflection->getMethod($setMethod)->getParameters(); |
||
| 21 | if ($parameters && 1 == count($parameters)) { |
||
| 22 | $parameter = $parameters[0]; |
||
| 23 | if (!$parameter->getClass()) { |
||
| 24 | $someValue = 'somevalue'; |
||
| 25 | $obj->$setMethod($someValue); |
||
| 26 | self::assertSame($someValue, $obj->$getMethod(), "$setMethod, $getMethod"); |
||
| 27 | } |
||
| 28 | } |
||
| 29 | } |
||
| 30 | } |
||
| 31 | } |
||
| 32 |