|
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'] |
|
|
|
|
|
|
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 #'); |
|
|
|
|
|
|
75
|
|
|
|
|
76
|
|
|
if ($expected === true) { |
|
77
|
|
|
$this->assertTrue($actual, $message); |
|
78
|
|
|
} else { |
|
79
|
|
|
$this->assertFalse($actual, $message); |
|
80
|
|
|
} |
|
81
|
|
|
} |
|
82
|
|
|
} |
|
83
|
|
|
|
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.