Passed
Push — master ( 209660...779a56 )
by Nelson
02:44
created

unaccesiblePropertiesProvider()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 7
Code Lines 4

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
cc 1
eloc 4
nc 1
nop 0
dl 0
loc 7
rs 10
c 0
b 0
f 0
1
<?php
2
/**
3
 * PHP: Nelson Martell Library file
4
 *
5
 * Content:
6
 * - Trait definition.
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\DataProviders;
21
22
use NelsonMartell\Test\Helpers\ConstructorMethodTester;
23
use NelsonMartell\Test\Helpers\ExporterPlugin;
24
use NelsonMartell\Test\Helpers\HasReadOnlyProperties;
25
use NelsonMartell\Test\Helpers\HasUnaccesibleProperties;
26
use NelsonMartell\Test\Helpers\IComparableTester;
27
use NelsonMartell\Test\Helpers\IComparerTester;
28
use NelsonMartell\Test\Helpers\IEquatableTester;
29
use NelsonMartell\Test\Helpers\ImplementsIStrictPropertiesContainer;
30
use NelsonMartell\VersionComponent;
31
32
/**
33
 * Data providers for NelsonMartell\Test\VersionComponent.
34
 *
35
 * @author Nelson Martell <[email protected]>
36
 * @internal
37
 * */
38
trait VersionComponentTestProvider
39
{
40
    use ExporterPlugin;
41
    use ConstructorMethodTester;
42
    use IComparableTester;
43
    use IComparerTester;
44
    use IEquatableTester;
45
    use ImplementsIStrictPropertiesContainer;
46
    use HasReadOnlyProperties;
47
    use HasUnaccesibleProperties;
48
49
    public function unaccesiblePropertiesProvider()
50
    {
51
        $obj = new VersionComponent(null, 'beta');
52
53
        return [
54
            '$stringValue with case changed' => [$obj, 'StringValue'],
55
            '$intValue with case changed'    => [$obj, 'IntValue'],
56
        ];
57
    }
58
59
    public function goodConstructorArgumentsProvider()
60
    {
61
        return [
62
            'No args'           => [],
63
            'null values'       => [null, null],
64
            'Only integer part' => [1, null],
65
            'Only string part'  => [null, '-alpha'],
66
            'All arguments'     => [5, '-beta'],
67
            'Git describe'      => [19, '-g7575872'],
68
        ];
69
    }
70
71
    public function badConstructorArgumentsProvider()
72
    {
73
        return [
74
            'Negative integer part'        => [-1, null],
75
            'Invalid string value part'    => [0, 'erróneo'],
76
            'Invalid type (float) for string part'  => [0, 23.912],
77
            'Invalid type (object) for string part'  => [0, new \stdClass],
78
            'Invalid type (array) for string part'  => [0, ['no']],
79
        ];
80
    }
81
82
    public function objectInstanceProvider()
83
    {
84
        return [[new VersionComponent(1, '-beta')]];
85
    }
86
87
    public function readOnlyPropertiesProvider()
88
    {
89
        $obj = new VersionComponent(1, '-beta');
90
91
        return [
92
            [$obj, 'intValue', 1],
93
            [$obj, 'stringValue', '-beta'],
94
        ];
95
    }
96
97
    public function IComparableCompareToMethodArgumentsProvider()
0 ignored issues
show
Coding Style introduced by
This method is not in camel caps format.

This check looks for method names that are not written in camelCase.

In camelCase names are written without any punctuation, the start of each new word being marked by a capital letter. Thus the name database connection seeker becomes databaseConnectionSeeker.

Loading history...
98
    {
99
        $v = new VersionComponent(1, '-alpha');
0 ignored issues
show
Coding Style introduced by
Equals sign not aligned with surrounding assignments; expected 16 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...
100
        $obj = new \stdClass();
0 ignored issues
show
Coding Style introduced by
Equals sign not aligned with surrounding assignments; expected 14 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...
101
        $obj->intValue = 1;
0 ignored issues
show
Coding Style introduced by
Equals sign not aligned with surrounding assignments; expected 4 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...
102
        $obj->stringValue = '-alpha';
103
104
        $args = [
105
            'Equals by reference' => [0, $v, $v],
106
            'Equals by value'     => [
107
                0,
108
                new VersionComponent(1, '-alpha'),
109
                VersionComponent::parse('1-alpha')
110
            ],
111
            'VersionComponent: >' => [
112
                1,
113
                new VersionComponent(1, '-beta'),
114
                VersionComponent::parse('1-alpha')
115
            ],
116
            'VersionComponent: <' => [
117
                -1,
118
                new VersionComponent(1, '-alpha'),
119
                VersionComponent::parse('1-beta')
120
            ],
121
            'VersionComponent | stdClass: null' => [
122
                null,
123
                $v,
124
                $obj
125
            ],
126
            'VersionComponent | null' => [
127
                1,
128
                $v,
129
                null
130
            ],
131
            'VersionComponent | VersionComponent (null)' => [
132
                -1,
133
                new VersionComponent(),
134
                new VersionComponent(1)
135
            ],
136
        ];
137
138
        return $args;
139
    }
140
141
142
    public function compareMethodArgumentsProvider()
143
    {
144
        $v = new VersionComponent(1, '-alpha');
0 ignored issues
show
Coding Style introduced by
Equals sign not aligned with surrounding assignments; expected 16 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...
145
        $obj = new \stdClass();
0 ignored issues
show
Coding Style introduced by
Equals sign not aligned with surrounding assignments; expected 14 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...
146
        $obj->intValue = 1;
0 ignored issues
show
Coding Style introduced by
Equals sign not aligned with surrounding assignments; expected 4 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...
147
        $obj->stringValue = '-alpha';
148
149
        return [
150
            [-1, 'array', $v],
151
            [null, $v, $obj],
152
            [-1, [], $v],
153
        ];
154
    }
155
156
    public function compareMethodArraysProvider()
157
    {
158
        return [
159
            'VersionComponent[]' => [[
160
                VersionComponent::parse("0-4-g"),
0 ignored issues
show
Coding Style Comprehensibility introduced by
The string literal 0-4-g does not require double quotes, as per coding-style, please use single quotes.

PHP provides two ways to mark string literals. Either with single quotes 'literal' or with double quotes "literal". The difference between these is that string literals in double quotes may contain variables with are evaluated at run-time as well as escape sequences.

String literals in single quotes on the other hand are evaluated very literally and the only two characters that needs escaping in the literal are the single quote itself (\') and the backslash (\\). Every other character is displayed as is.

Double quoted string literals may contain other variables or more complex escape sequences.

<?php

$singleQuoted = 'Value';
$doubleQuoted = "\tSingle is $singleQuoted";

print $doubleQuoted;

will print an indented: Single is Value

If your string literal does not contain variables or escape sequences, it should be defined using single quotes to make that fact clear.

For more information on PHP string literals and available escape sequences see the PHP core documentation.

Loading history...
161
                VersionComponent::parse("1-4-g"),
0 ignored issues
show
Coding Style Comprehensibility introduced by
The string literal 1-4-g does not require double quotes, as per coding-style, please use single quotes.

PHP provides two ways to mark string literals. Either with single quotes 'literal' or with double quotes "literal". The difference between these is that string literals in double quotes may contain variables with are evaluated at run-time as well as escape sequences.

String literals in single quotes on the other hand are evaluated very literally and the only two characters that needs escaping in the literal are the single quote itself (\') and the backslash (\\). Every other character is displayed as is.

Double quoted string literals may contain other variables or more complex escape sequences.

<?php

$singleQuoted = 'Value';
$doubleQuoted = "\tSingle is $singleQuoted";

print $doubleQuoted;

will print an indented: Single is Value

If your string literal does not contain variables or escape sequences, it should be defined using single quotes to make that fact clear.

For more information on PHP string literals and available escape sequences see the PHP core documentation.

Loading history...
162
                VersionComponent::parse("2-3-g"),
0 ignored issues
show
Coding Style Comprehensibility introduced by
The string literal 2-3-g does not require double quotes, as per coding-style, please use single quotes.

PHP provides two ways to mark string literals. Either with single quotes 'literal' or with double quotes "literal". The difference between these is that string literals in double quotes may contain variables with are evaluated at run-time as well as escape sequences.

String literals in single quotes on the other hand are evaluated very literally and the only two characters that needs escaping in the literal are the single quote itself (\') and the backslash (\\). Every other character is displayed as is.

Double quoted string literals may contain other variables or more complex escape sequences.

<?php

$singleQuoted = 'Value';
$doubleQuoted = "\tSingle is $singleQuoted";

print $doubleQuoted;

will print an indented: Single is Value

If your string literal does not contain variables or escape sequences, it should be defined using single quotes to make that fact clear.

For more information on PHP string literals and available escape sequences see the PHP core documentation.

Loading history...
163
                VersionComponent::parse("2-3-g726356"),
0 ignored issues
show
Coding Style Comprehensibility introduced by
The string literal 2-3-g726356 does not require double quotes, as per coding-style, please use single quotes.

PHP provides two ways to mark string literals. Either with single quotes 'literal' or with double quotes "literal". The difference between these is that string literals in double quotes may contain variables with are evaluated at run-time as well as escape sequences.

String literals in single quotes on the other hand are evaluated very literally and the only two characters that needs escaping in the literal are the single quote itself (\') and the backslash (\\). Every other character is displayed as is.

Double quoted string literals may contain other variables or more complex escape sequences.

<?php

$singleQuoted = 'Value';
$doubleQuoted = "\tSingle is $singleQuoted";

print $doubleQuoted;

will print an indented: Single is Value

If your string literal does not contain variables or escape sequences, it should be defined using single quotes to make that fact clear.

For more information on PHP string literals and available escape sequences see the PHP core documentation.

Loading history...
164
                VersionComponent::parse("2-4-g"),
0 ignored issues
show
Coding Style Comprehensibility introduced by
The string literal 2-4-g does not require double quotes, as per coding-style, please use single quotes.

PHP provides two ways to mark string literals. Either with single quotes 'literal' or with double quotes "literal". The difference between these is that string literals in double quotes may contain variables with are evaluated at run-time as well as escape sequences.

String literals in single quotes on the other hand are evaluated very literally and the only two characters that needs escaping in the literal are the single quote itself (\') and the backslash (\\). Every other character is displayed as is.

Double quoted string literals may contain other variables or more complex escape sequences.

<?php

$singleQuoted = 'Value';
$doubleQuoted = "\tSingle is $singleQuoted";

print $doubleQuoted;

will print an indented: Single is Value

If your string literal does not contain variables or escape sequences, it should be defined using single quotes to make that fact clear.

For more information on PHP string literals and available escape sequences see the PHP core documentation.

Loading history...
165
                VersionComponent::parse("4-3-g"),
0 ignored issues
show
Coding Style Comprehensibility introduced by
The string literal 4-3-g does not require double quotes, as per coding-style, please use single quotes.

PHP provides two ways to mark string literals. Either with single quotes 'literal' or with double quotes "literal". The difference between these is that string literals in double quotes may contain variables with are evaluated at run-time as well as escape sequences.

String literals in single quotes on the other hand are evaluated very literally and the only two characters that needs escaping in the literal are the single quote itself (\') and the backslash (\\). Every other character is displayed as is.

Double quoted string literals may contain other variables or more complex escape sequences.

<?php

$singleQuoted = 'Value';
$doubleQuoted = "\tSingle is $singleQuoted";

print $doubleQuoted;

will print an indented: Single is Value

If your string literal does not contain variables or escape sequences, it should be defined using single quotes to make that fact clear.

For more information on PHP string literals and available escape sequences see the PHP core documentation.

Loading history...
166
                VersionComponent::parse("4-3-gsh4hajk7"),
0 ignored issues
show
Coding Style Comprehensibility introduced by
The string literal 4-3-gsh4hajk7 does not require double quotes, as per coding-style, please use single quotes.

PHP provides two ways to mark string literals. Either with single quotes 'literal' or with double quotes "literal". The difference between these is that string literals in double quotes may contain variables with are evaluated at run-time as well as escape sequences.

String literals in single quotes on the other hand are evaluated very literally and the only two characters that needs escaping in the literal are the single quote itself (\') and the backslash (\\). Every other character is displayed as is.

Double quoted string literals may contain other variables or more complex escape sequences.

<?php

$singleQuoted = 'Value';
$doubleQuoted = "\tSingle is $singleQuoted";

print $doubleQuoted;

will print an indented: Single is Value

If your string literal does not contain variables or escape sequences, it should be defined using single quotes to make that fact clear.

For more information on PHP string literals and available escape sequences see the PHP core documentation.

Loading history...
167
                VersionComponent::parse("4-3-gsh4hbjk7"),
0 ignored issues
show
Coding Style Comprehensibility introduced by
The string literal 4-3-gsh4hbjk7 does not require double quotes, as per coding-style, please use single quotes.

PHP provides two ways to mark string literals. Either with single quotes 'literal' or with double quotes "literal". The difference between these is that string literals in double quotes may contain variables with are evaluated at run-time as well as escape sequences.

String literals in single quotes on the other hand are evaluated very literally and the only two characters that needs escaping in the literal are the single quote itself (\') and the backslash (\\). Every other character is displayed as is.

Double quoted string literals may contain other variables or more complex escape sequences.

<?php

$singleQuoted = 'Value';
$doubleQuoted = "\tSingle is $singleQuoted";

print $doubleQuoted;

will print an indented: Single is Value

If your string literal does not contain variables or escape sequences, it should be defined using single quotes to make that fact clear.

For more information on PHP string literals and available escape sequences see the PHP core documentation.

Loading history...
168
                VersionComponent::parse("11-4-g"),
0 ignored issues
show
Coding Style Comprehensibility introduced by
The string literal 11-4-g does not require double quotes, as per coding-style, please use single quotes.

PHP provides two ways to mark string literals. Either with single quotes 'literal' or with double quotes "literal". The difference between these is that string literals in double quotes may contain variables with are evaluated at run-time as well as escape sequences.

String literals in single quotes on the other hand are evaluated very literally and the only two characters that needs escaping in the literal are the single quote itself (\') and the backslash (\\). Every other character is displayed as is.

Double quoted string literals may contain other variables or more complex escape sequences.

<?php

$singleQuoted = 'Value';
$doubleQuoted = "\tSingle is $singleQuoted";

print $doubleQuoted;

will print an indented: Single is Value

If your string literal does not contain variables or escape sequences, it should be defined using single quotes to make that fact clear.

For more information on PHP string literals and available escape sequences see the PHP core documentation.

Loading history...
169
            ]],
170
            'VersionComponent[] + integer[]' => [[
171
                1,
172
                new VersionComponent(2, '-alpha'),
173
            ]],
174
            'VersionComponent[] + string[]'  => [[
175
                new VersionComponent(1, '-alpha'),
176
                '1-beta',
177
            ]],
178
            'VersionComponent[] + string[] (non parseable)'  => [[
179
                '----------',
180
                new VersionComponent(),
181
            ]],
182
            'VersionComponent[] + array[]'   => [[
183
                [],
184
                [0, 1, 0],
185
                new VersionComponent(1, '-alpha'),
186
            ]],
187
        ];
188
    }
189
190
    public function goodVersionComponentParseMethodArgumentsProvider()
191
    {
192
        return [
193
            [new VersionComponent(1, 'a0'), '1a0'],
194
            [new VersionComponent(2, '-3-g726351'), '2-3-g726351'],
195
            [new VersionComponent(3, '-beta'), '3-beta'],
196
            [new VersionComponent(0, '-alpha'), '0-alpha'],
197
            [new VersionComponent(0, '-beta2'), '0-beta2'],
198
            'string | empty'        => [new VersionComponent(), '      '], // Maybe should throw exception?
1 ignored issue
show
Coding Style introduced by
This line exceeds maximum limit of 100 characters; contains 107 characters

Overly long lines are hard to read on any screen. Most code styles therefor impose a maximum limit on the number of characters in a line.

Loading history...
199
            'string | only spaces'  => [new VersionComponent(), ''], // Maybe should throw exception?
1 ignored issue
show
Coding Style introduced by
This line exceeds maximum limit of 100 characters; contains 101 characters

Overly long lines are hard to read on any screen. Most code styles therefor impose a maximum limit on the number of characters in a line.

Loading history...
200
            'null'                  => [new VersionComponent(), null], // Maybe should throw exception?
1 ignored issue
show
Coding Style introduced by
This line exceeds maximum limit of 100 characters; contains 103 characters

Overly long lines are hard to read on any screen. Most code styles therefor impose a maximum limit on the number of characters in a line.

Loading history...
201
            'integer'               => [new VersionComponent(7), 7],
202
            'VersionComponent'      => [new VersionComponent(999), new VersionComponent(999)],
203
        ];
204
    }
205
206
    public function badVersionComponentParseMethodArgumentsProvider()
207
    {
208
        return [
209
            'string | consecutive "-"'          => ['1a--0'],
210
            'string | invalid char: ó'          => ['1-erróneo'],
211
            'string | not starting in number'   => ['beta0'],
212
            'integer | < 0'                     => [-13],
213
            'stdClass'                          => [new \stdClass],
214
        ];
215
    }
216
217
    public function IEquatableMethodArgumentsProvider()
0 ignored issues
show
Coding Style introduced by
This method is not in camel caps format.

This check looks for method names that are not written in camelCase.

In camelCase names are written without any punctuation, the start of each new word being marked by a capital letter. Thus the name database connection seeker becomes databaseConnectionSeeker.

Loading history...
218
    {
219
        return [
220
            [true, new VersionComponent(1, '-alpha'), new VersionComponent(1, '-alpha')],
221
            [false, new VersionComponent(1, '-beta'), new VersionComponent(1, '-bet')],
222
            [false, new VersionComponent(3, '-dev'), new VersionComponent(1, '-dev')],
223
            [false, new VersionComponent(), null],
224
            [false, new VersionComponent(0), 0],
225
            [false, new VersionComponent(2), 2],
226
            [false, new VersionComponent(23), 2345654675675675673453],
227
            [false, new VersionComponent(0, '-dev'), '0-dev'],
228
            [false, new VersionComponent(1, '-alpha'), [1, '-alpha']],
229
            [false, new VersionComponent(), new \stdClass],
230
        ];
231
    }
232
233
    public function versionComponentToStringMethodArgumentsProvider()
234
    {
235
        return [
236
            ['0', new VersionComponent(0)],
237
            ['', new VersionComponent()],
238
            ['', new VersionComponent(null, '')],
239
            ['', new VersionComponent(null, '  ')],
240
            ['', new VersionComponent(null)],
241
            ['', new VersionComponent(null, null)],
242
            ['1a', new VersionComponent(1, 'a')],
243
            ['1-beta', new VersionComponent(1, '-beta')],
244
            ['2-rc1-20-g8c5b85c', new VersionComponent(2, "-rc1-20-g8c5b85c")],
0 ignored issues
show
Coding Style Comprehensibility introduced by
The string literal -rc1-20-g8c5b85c does not require double quotes, as per coding-style, please use single quotes.

PHP provides two ways to mark string literals. Either with single quotes 'literal' or with double quotes "literal". The difference between these is that string literals in double quotes may contain variables with are evaluated at run-time as well as escape sequences.

String literals in single quotes on the other hand are evaluated very literally and the only two characters that needs escaping in the literal are the single quote itself (\') and the backslash (\\). Every other character is displayed as is.

Double quoted string literals may contain other variables or more complex escape sequences.

<?php

$singleQuoted = 'Value';
$doubleQuoted = "\tSingle is $singleQuoted";

print $doubleQuoted;

will print an indented: Single is Value

If your string literal does not contain variables or escape sequences, it should be defined using single quotes to make that fact clear.

For more information on PHP string literals and available escape sequences see the PHP core documentation.

Loading history...
245
        ];
246
    }
247
248
249
    public function nullOrDefaultStatesProvider()
250
    {
251
        return [
252
            ['default', new VersionComponent(0)],
253
            ['null', new VersionComponent()],
254
            ['null', new VersionComponent(null, '')],
255
            ['null', new VersionComponent(null, '  ')],
256
            ['null', new VersionComponent(null)],
257
            ['null', new VersionComponent(null, null)],
258
            ['defined', new VersionComponent(1, 'a')],
259
            ['defined', new VersionComponent(1, '-beta')],
260
            ['defined', new VersionComponent(2, "-rc1-20-g8c5b85c")],
0 ignored issues
show
Coding Style Comprehensibility introduced by
The string literal -rc1-20-g8c5b85c does not require double quotes, as per coding-style, please use single quotes.

PHP provides two ways to mark string literals. Either with single quotes 'literal' or with double quotes "literal". The difference between these is that string literals in double quotes may contain variables with are evaluated at run-time as well as escape sequences.

String literals in single quotes on the other hand are evaluated very literally and the only two characters that needs escaping in the literal are the single quote itself (\') and the backslash (\\). Every other character is displayed as is.

Double quoted string literals may contain other variables or more complex escape sequences.

<?php

$singleQuoted = 'Value';
$doubleQuoted = "\tSingle is $singleQuoted";

print $doubleQuoted;

will print an indented: Single is Value

If your string literal does not contain variables or escape sequences, it should be defined using single quotes to make that fact clear.

For more information on PHP string literals and available escape sequences see the PHP core documentation.

Loading history...
261
        ];
262
    }
263
}
264