| @@ 47-68 (lines=22) @@ | ||
| 44 | * @testdox Do not throws error on creating new instances, due to all arguments passed are ignored |
|
| 45 | * @group Criticals |
|
| 46 | */ |
|
| 47 | public function testConstructorWithBadArguments() |
|
| 48 | { |
|
| 49 | $actual = null; |
|
| 50 | $message = String::format( |
|
| 51 | '$object = new {class}();', |
|
| 52 | [ |
|
| 53 | 'class' => Object::class, |
|
| 54 | ] |
|
| 55 | ); |
|
| 56 | ||
| 57 | try { |
|
| 58 | $actual = new Object(); |
|
| 59 | } catch (Exception $e) { |
|
| 60 | $actual = $e; |
|
| 61 | $message .= String::format( |
|
| 62 | ' // # Constructor should not throws exceptions. Error: {0}', |
|
| 63 | $this->exporter->export($e->getMessage()) |
|
| 64 | ); |
|
| 65 | } |
|
| 66 | ||
| 67 | $this->assertInstanceOf(Object::class, $actual, $message); |
|
| 68 | } |
|
| 69 | } |
|
| 70 | ||
| @@ 59-81 (lines=23) @@ | ||
| 56 | * @dataProvider badConstructorArgumentsProvider |
|
| 57 | * @group Criticals |
|
| 58 | */ |
|
| 59 | public function testConstructorWithBadArguments($obj) |
|
| 60 | { |
|
| 61 | $actual = null; |
|
| 62 | $message = String::format( |
|
| 63 | '$type = new {class}({obj});', |
|
| 64 | [ |
|
| 65 | 'class' => Type::class, |
|
| 66 | 'obj' => $this->exporter->shortenedExport($obj), |
|
| 67 | ] |
|
| 68 | ); |
|
| 69 | ||
| 70 | try { |
|
| 71 | $actual = new Type($obj); |
|
| 72 | } catch (\Exception $e) { |
|
| 73 | $actual = $e; |
|
| 74 | $message .= String::format( |
|
| 75 | ' // # Constructor should not throws exceptions. Error: {0}', |
|
| 76 | $this->exporter->export($e->getMessage()) |
|
| 77 | ); |
|
| 78 | } |
|
| 79 | ||
| 80 | $this->assertInstanceOf(Type::class, $actual, $message); |
|
| 81 | } |
|
| 82 | ||
| 83 | /** |
|
| 84 | * @coverage Type::toString |
|