Completed
Push — master ( 7e5e34...10763a )
by Nelson
02:30
created

testConstructorWithBadArguments()   A

Complexity

Conditions 2
Paths 2

Size

Total Lines 22
Code Lines 13

Duplication

Lines 22
Ratio 100 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
cc 2
eloc 13
c 1
b 0
f 0
nc 2
nop 0
dl 22
loc 22
rs 9.2
1
<?php
2
/**
3
 * PHP: Nelson Martell Library file
4
 *
5
 * Content:
6
 * - Test case for: [NelsonMartell] StrictObject
7
 *
8
 * Copyright © 2016-2017 Nelson Martell (http://nelson6e65.github.io)
9
 *
10
 * Licensed under The MIT License (MIT)
11
 * For full copyright and license information, please see the LICENSE
12
 * Redistributions of files must retain the above copyright notice.
13
 *
14
 * @copyright 2016-2017 Nelson Martell
15
 * @link      http://nelson6e65.github.io/php_nml/
16
 * @since     v0.6.0
17
 * @license   http://www.opensource.org/licenses/mit-license.php The MIT License (MIT)
18
 * */
19
20
namespace NelsonMartell\Test\TestCase;
21
22
use NelsonMartell as NML;
23
use NelsonMartell\Extensions\Text;
24
use NelsonMartell\Test\DataProviders\ObjectTestProvider;
25
use NelsonMartell\StrictObject;
26
use PHPUnit\Framework\TestCase;
27
use \InvalidArgumentException;
28
use \Exception;
29
30
/**
31
 *
32
 * @author Nelson Martell <[email protected]>
33
 * @internal
34
 * @group Criticals
35
 * */
36 View Code Duplication
class StrictObjectTest extends TestCase
0 ignored issues
show
Duplication introduced by
This class seems to be duplicated in your project.

Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.

You can also find more detailed suggestions in the “Code” section of your repository.

Loading history...
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;
0 ignored issues
show
Coding Style introduced by
Equals sign not aligned with surrounding assignments; expected 2 spaces but found 1 space

This check looks for multiple assignments in successive lines of code. It will report an issue if the operators are not in a straight line.

To visualize

$a = "a";
$ab = "ab";
$abc = "abc";

will produce issues in the first and second line, while this second example

$a   = "a";
$ab  = "ab";
$abc = "abc";

will produce no issues.

Loading history...
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;
0 ignored issues
show
Coding Style introduced by
Equals sign not aligned with surrounding assignments; expected 3 spaces but found 1 space

This check looks for multiple assignments in successive lines of code. It will report an issue if the operators are not in a straight line.

To visualize

$a = "a";
$ab = "ab";
$abc = "abc";

will produce issues in the first and second line, while this second example

$a   = "a";
$ab  = "ab";
$abc = "abc";

will produce no issues.

Loading history...
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