Code Duplication    Length = 34-34 lines in 2 locations

tests/TestCase/StrictObjectTest.php 1 location

@@ 36-69 (lines=34) @@
33
 * @internal
34
 * @group Criticals
35
 * */
36
class StrictObjectTest extends TestCase
37
{
38
    use ObjectTestProvider;
39
40
    /**
41
     * Overrides default tests, due to this class constructor do not throws argument exceptions.
42
     * So, using any type should be pass.
43
     *
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 = Text::format(
51
            '$object = new {class}();',
52
            [
53
                'class' => StrictObject::class,
54
            ]
55
        );
56
57
        try {
58
            $actual = new StrictObject();
59
        } catch (Exception $e) {
60
            $actual = $e;
61
            $message .= Text::format(
62
                ' // # Constructor should not throws exceptions. Error: {0}',
63
                $this->exporter->export($e->getMessage())
64
            );
65
        }
66
67
        $this->assertInstanceOf(StrictObject::class, $actual, $message);
68
    }
69
}
70

tests/TestCaseL72/ObjectTest.php 1 location

@@ 38-71 (lines=34) @@
35
 * @requires PHP < 7.2.0
36
 *
37
 * */
38
class ObjectTest extends TestCase
39
{
40
    use ObjectTestProvider;
41
42
    /**
43
     * Overrides default tests, due to this class constructor do not throws argument exceptions.
44
     * So, using any type should be pass.
45
     *
46
     * @testdox Do not throws error on creating new instances, due to all arguments passed are ignored
47
     * @group Criticals
48
     */
49
    public function testConstructorWithBadArguments()
50
    {
51
        $actual = null;
52
        $message = Text::format(
53
            '$object = new {class}();',
54
            [
55
                'class' => Object::class,
56
            ]
57
        );
58
59
        try {
60
            $actual = new Object();
61
        } catch (Exception $e) {
62
            $actual = $e;
63
            $message .= Text::format(
64
                ' // # Constructor should not throws exceptions. Error: {0}',
65
                $this->exporter->export($e->getMessage())
66
            );
67
        }
68
69
        $this->assertInstanceOf(Object::class, $actual, $message);
70
    }
71
}
72