| Total Complexity | 2 |
| Total Lines | 55 |
| Duplicated Lines | 0 % |
| Changes | 1 | ||
| Bugs | 0 | Features | 1 |
| 1 | <?php |
||
| 14 | class ConstructorLessInstanciatorTest extends TestCase |
||
| 15 | { |
||
| 16 | public function testInterface() |
||
| 21 | ); |
||
| 22 | } |
||
| 23 | |||
| 24 | public function testBuild() |
||
| 25 | { |
||
| 26 | $instanciator = new ConstructorLessInstanciator; |
||
| 27 | $object = new class('bar') { |
||
| 28 | public $foo; |
||
| 29 | |||
| 30 | public function __construct(string $foo) |
||
| 31 | { |
||
| 32 | $this->foo = $foo; |
||
| 33 | } |
||
| 34 | }; |
||
| 35 | |||
| 36 | $this->assertInstanceOf( |
||
| 37 | 'stdClass', |
||
| 38 | $instanciator->build( |
||
| 39 | 'stdClass', |
||
| 40 | Map::of('string', 'variable') |
||
| 41 | ) |
||
| 42 | ); |
||
| 43 | |||
| 44 | $builtObject = $instanciator->build( |
||
| 45 | get_class($object), |
||
| 46 | Map::of('string', 'variable') |
||
| 47 | ); |
||
| 48 | |||
| 49 | $this->assertInstanceOf(get_class($object), $builtObject); |
||
| 50 | $this->assertNull($builtObject->foo); |
||
| 51 | } |
||
| 52 | |||
| 53 | public function testGetParameters() |
||
| 54 | { |
||
| 55 | $instanciator = new ConstructorLessInstanciator; |
||
| 56 | $object = new class('bar') { |
||
| 57 | public function __construct(string $foo) |
||
| 59 | } |
||
| 60 | }; |
||
| 69 | ); |
||
| 70 | } |
||
| 71 | } |
||
| 72 |
This check looks for parameters that have been defined for a function or method, but which are not used in the method body.