|
1
|
|
|
<?php |
|
2
|
|
|
/** |
|
3
|
|
|
* PHP: Nelson Martell Library file |
|
4
|
|
|
* |
|
5
|
|
|
* Content: |
|
6
|
|
|
* - Trait definition. |
|
7
|
|
|
* |
|
8
|
|
|
* Copyright © 2016 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 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\Object; |
|
23
|
|
|
use NelsonMartell\Test\Helpers\ExporterPlugin; |
|
24
|
|
|
use NelsonMartell\Test\Helpers\ConstructorMethodTester; |
|
25
|
|
|
use NelsonMartell\Test\Helpers\IComparerTester; |
|
26
|
|
|
|
|
27
|
|
|
/** |
|
28
|
|
|
* |
|
29
|
|
|
* @author Nelson Martell <[email protected]> |
|
30
|
|
|
* @internal |
|
31
|
|
|
* */ |
|
32
|
|
|
trait ObjectTestProvider |
|
33
|
|
|
{ |
|
34
|
|
|
use ExporterPlugin; |
|
35
|
|
|
use ConstructorMethodTester; |
|
36
|
|
|
use IComparerTester; |
|
37
|
|
|
|
|
38
|
|
|
# ConstructorMethodTester |
|
|
|
|
|
|
39
|
|
|
|
|
40
|
|
|
public function getTargetClassName() |
|
|
|
|
|
|
41
|
|
|
{ |
|
42
|
|
|
return Object::class; |
|
43
|
|
|
} |
|
44
|
|
|
|
|
45
|
|
|
public function goodConstructorArgumentsProvider() |
|
46
|
|
|
{ |
|
47
|
|
|
return [[]]; |
|
48
|
|
|
} |
|
49
|
|
|
|
|
50
|
|
|
|
|
51
|
|
|
public function badConstructorArgumentsProvider() |
|
52
|
|
|
{ |
|
53
|
|
|
return null; |
|
54
|
|
|
} |
|
55
|
|
|
# |
|
|
|
|
|
|
56
|
|
|
|
|
57
|
|
|
|
|
58
|
|
|
# IComparerTester |
|
|
|
|
|
|
59
|
|
|
public function compareMethodArgumentsProvider() |
|
60
|
|
|
{ |
|
61
|
|
|
$obj = new \stdClass(); |
|
|
|
|
|
|
62
|
|
|
$obj->one = 1; |
|
|
|
|
|
|
63
|
|
|
$obj->nine = 9; |
|
64
|
|
|
|
|
65
|
|
|
$args = [ |
|
66
|
|
|
'integers: same value, +-' => [1, 5, -5], |
|
67
|
|
|
'integers: same value, -+' => [-1, -5, 5], |
|
68
|
|
|
'integers: same value, --' => [0, -5, -5], |
|
69
|
|
|
'integers: same value, ++' => [0, 5, 5], |
|
70
|
|
|
'integers: different value, +-' => [1, 90, -8], |
|
71
|
|
|
'integers: different value, -+' => [-1, -8, 90], |
|
72
|
|
|
'integers: different value, --' => [1, -8, -90], |
|
73
|
|
|
'integers: different value, ++' => [-1, 8, 90], |
|
74
|
|
|
'strings: same' => [0, 'world', 'world'], |
|
75
|
|
|
'strings: leading space, <' => [-1, 'world', 'world '], |
|
76
|
|
|
'strings: leading space, >' => [1, 'world ', 'world'], |
|
77
|
|
|
'strings: different chars, >' => [1, 'hola', 'hello'], |
|
78
|
|
|
'strings: different chars, <' => [-1, 'hello', 'hola'], |
|
79
|
|
|
'arrays: same' => [0, ['one' => 'world'], ['one' => 'world']], |
|
80
|
|
|
'arrays: different count, >' => [1, ['hola', 'mundo'], ['hello']], |
|
81
|
|
|
'arrays: different count, <' => [-1, ['hello'], ['hola', 'mundo']], |
|
82
|
|
|
'array > array (values)' => [1, ['hola', 'mundo'], ['hello', 'world']], |
|
83
|
|
|
'array < array (values)' => [-1, ['hello', 'world'], ['hola', 'mundo']], |
|
84
|
|
|
'array < array (keys)' => [-1, ['hola', 'mundo'], ['one' => 'hello', 'two' => 'world']], |
|
85
|
|
|
'stdClass = stdClass' => [0, $obj, $obj], |
|
86
|
|
|
'stdClass (empty) < stdClass' => [-1, new \stdClass, $obj], |
|
87
|
|
|
]; |
|
88
|
|
|
|
|
89
|
|
|
return $args; |
|
90
|
|
|
} |
|
91
|
|
|
|
|
92
|
|
|
public function compareMethodArraysProvider() |
|
93
|
|
|
{ |
|
94
|
|
|
return [ |
|
95
|
|
|
'integer[]' => [[-67, -9, 0, 4, 5, 6]], |
|
96
|
|
|
'string[]' => [['a', 'b', 'c', 'd', 'z', 'z1']], |
|
97
|
|
|
]; |
|
98
|
|
|
} |
|
99
|
|
|
# |
|
|
|
|
|
|
100
|
|
|
} |
|
|
|
|
|
|
101
|
|
|
|