Test Failed
Push — master ( 322b96...cb950d )
by Nelson
03:16
created

VersionTest::testIsValid()   A

Complexity

Conditions 2
Paths 2

Size

Total Lines 19
Code Lines 11

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
cc 2
eloc 11
nc 2
nop 2
dl 0
loc 19
rs 9.9
c 0
b 0
f 0
1
<?php declare(strict_types=1);
2
/**
3
 * PHP: Nelson Martell Library file
4
 *
5
 * Copyright © 2016-2019 Nelson Martell (http://nelson6e65.github.io)
6
 *
7
 * Licensed under The MIT License (MIT)
8
 * For full copyright and license information, please see the LICENSE
9
 * Redistributions of files must retain the above copyright notice.
10
 *
11
 * @copyright 2016-2019 Nelson Martell
12
 * @link      http://nelson6e65.github.io/php_nml/
13
 * @since     0.6.0
14
 * @license   http://www.opensource.org/licenses/mit-license.php The MIT License (MIT)
15
 * */
16
17
namespace NelsonMartell\Test\TestCase;
18
19
use NelsonMartell\Extensions\Text;
20
21
use NelsonMartell\Test\DataProviders\VersionTestProvider;
22
23
use NelsonMartell\Version;
24
25
use PHPUnit\Framework\TestCase;
26
27
/**
28
 *
29
 * @author Nelson Martell <[email protected]>
30
 * @internal
31
 * @since 0.6.0
32
 * */
33
class VersionTest extends TestCase
34
{
35
    use VersionTestProvider;
36
37
    public function getTargetClassName()
38
    {
39
        return Version::class;
40
    }
41
42
    /**
43
     * @depends NelsonMartell\Test\TestCase\VersionComponentTest::testParseMethod
44
     */
45
    public function testPerformsConversionFromString()
46
    {
47
        // Test for array ['invalid', 'array']
0 ignored issues
show
Unused Code Comprehensibility introduced by
59% of this comment could be valid code. Did you maybe forget this after debugging?

Sometimes obsolete code just ends up commented out instead of removed. In this case it is better to remove the code once you have checked you do not need it.

The code might also have been commented out for debugging purposes. In this case it is vital that someone uncomments it again or your project may behave in very unexpected ways in production.

This check looks for comments that seem to be mostly valid code and reports them.

Loading history...
48
        $this->markTestIncomplete(
49
            'Tests for "'.Version::class.'::parse'.'" has not been completed yet.'
50
        );
51
    }
52
53
54
    /**
55
     * @testdox Can check if Version instance is valid
56
     * @dataProvider isValidProvider
57
     *
58
     * @param  bool    $expected [description]
59
     * @param  Version $version  [description]
60
     */
61
    public function testIsValid(bool $expected, Version $version) : void
62
    {
63
        $actual = $version->isValid();
64
65
        $message = Text::format(
66
            '$version->{method}(); // {actual}',
67
            [
68
                'method' => 'isValid',
69
                'obj'    => static::export($version),
70
                'actual' => static::export($actual)
71
            ]
72
        );
73
74
        $this->assertInternalType('boolean', $actual, $message.' # Should return a boolean #');
0 ignored issues
show
Deprecated Code introduced by
The function PHPUnit\Framework\Assert::assertInternalType() has been deprecated: https://github.com/sebastianbergmann/phpunit/issues/3369 ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-deprecated  annotation

74
        /** @scrutinizer ignore-deprecated */ $this->assertInternalType('boolean', $actual, $message.' # Should return a boolean #');

This function has been deprecated. The supplier of the function has supplied an explanatory message.

The explanatory message should give you some clue as to whether and when the function will be removed and what other function to use instead.

Loading history...
75
76
        if ($expected === true) {
77
            $this->assertTrue($actual, $message);
78
        } else {
79
            $this->assertFalse($actual, $message);
80
        }
81
    }
82
}
83