ObjectsTestProvider::compareMethodArraysProvider()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 5
Code Lines 3

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
cc 1
eloc 3
c 1
b 0
f 0
nc 1
nop 0
dl 0
loc 5
rs 10
1
<?php
2
3
/**
4
 * PHP: Nelson Martell Library file
5
 *
6
 * Copyright © 2016-2021 Nelson Martell (http://nelson6e65.github.io)
7
 *
8
 * Licensed under The MIT License (MIT)
9
 * For full copyright and license information, please see the LICENSE
10
 * Redistributions of files must retain the above copyright notice.
11
 *
12
 * @copyright 2016-2021 Nelson Martell
13
 * @link      http://nelson6e65.github.io/php_nml/
14
 * @since     1.0.0
15
 * @license   http://www.opensource.org/licenses/mit-license.php The MIT License (MIT)
16
 * */
17
18
declare(strict_types=1);
19
20
namespace NelsonMartell\Test\DataProviders\Extensions;
21
22
use stdClass;
23
use NelsonMartell\Extensions\Objects;
24
use NelsonMartell\Test\DataProviders\ExampleClass\A;
25
use NelsonMartell\Test\Helpers\ExporterPlugin;
26
use NelsonMartell\Test\Helpers\IComparerTester;
27
28
/**
29
 *
30
 * @author Nelson Martell <[email protected]>
31
 * @since  1.0.0
32
 * @internal
33
 * */
34
trait ObjectsTestProvider
35
{
36
    use ExporterPlugin;
37
    use IComparerTester;
38
39
    public function getTargetClassName(): string
40
    {
41
        return Objects::class;
42
    }
43
44
45
    // IComparerTester
46
    public function compareMethodArgumentsProvider(): array
47
    {
48
        $obj       = new \stdClass();
49
        $obj->one  = 1;
50
        $obj->nine = 9;
51
52
        $args = [
53
            'integers: same value, +-'      => [1, 5, -5],
54
            'integers: same value, -+'      => [-1, -5, 5],
55
            'integers: same value, --'      => [0, -5, -5],
56
            'integers: same value, ++'      => [0, 5, 5],
57
            'integers: different value, +-' => [1, 90, -8],
58
            'integers: different value, -+' => [-1, -8, 90],
59
            'integers: different value, --' => [1, -8, -90],
60
            'integers: different value, ++' => [-1, 8, 90],
61
            'strings: same'                 => [0, 'world', 'world'],
62
            'strings: leading space, <'     => [-1, 'world', 'world '],
63
            'strings: leading space, >'     => [1, 'world ', 'world'],
64
            'strings: different chars, >'   => [1, 'hola', 'hello'],
65
            'strings: different chars, <'   => [-1, 'hello', 'hola'],
66
            'arrays: same'                  => [0, ['one' => 'world'], ['one' => 'world']],
67
            'arrays: different count, >'    => [1, ['hola', 'mundo'], ['hello']],
68
            'arrays: different count, <'    => [-1, ['hello'], ['hola', 'mundo']],
69
            'array > array (values)'        => [1, ['hola', 'mundo'], ['hello', 'world']],
70
            'array < array (values)'        => [-1, ['hello', 'world'], ['hola', 'mundo']],
71
            'array < array (keys)'          => [-1, ['hola', 'mundo'], ['one' => 'hello', 'two' => 'world']],
72
            'array < stdClass'              => [-1, [], new stdClass()],
73
            'stdClass > array'              => [1, new stdClass(), []],
74
            'array > null'                  => [1, [], null],
75
            'null < array'                  => [-1, null, []],
76
            'array > int'                   => [1, [], 1],
77
            'int < array'                   => [-1, 1, []],
78
            'array > string'                => [1, [], '1'],
79
            'string < array'                => [-1, '1', []],
80
            'same reference =='             => [0, $obj, $obj],
81
            'empty classes =='              => [0, new A(), new A()],
82
            'different class'               => [null, new A(), new stdClass()],
83
            'stdClass (empty) < stdClass'   => [-1, new \stdClass(), $obj],
84
            'stdClass > stdClass (empty)'   => [1, $obj, new \stdClass()],
85
            'stdClass > integer'            => [1, $obj, 1234],
86
            'integer < stdClass'            => [-1, 1234, $obj],
87
            'stdClass > string'             => [1, $obj, '1234'],
88
            'string < stdClass'             => [-1, '1234', $obj],
89
            'stdClass > null'               => [1, $obj, null],
90
            'null < stdClass'               => [-1, null, $obj],
91
            'float > null'                  => [1, 1.23, null],
92
            'null < float'                  => [-1, null, 1.23],
93
            'null < float (negative)'       => [-1, null, -1.23],
94
            'float (negative) > null'       => [1, -1.23, null],
95
            'float == integer'              => [0, 1.00, 1],
96
            'float != integer'              => [1, 1.0000001, 1],
97
            'floats near to zero'           => [1, 0.00000000001, -0.00000000001],
98
            'float > integer'               => [1, 1.23, 1],
99
            'integer < float'               => [-1, 1, 1.23],
100
            'floats <'                      => [-1, 1.234, 1.2345],
101
            'bool cant integer'             => [null, false, 19],
102
            'integer cant bool'             => [null, 1, true],
103
            'boolean < boolean'             => [-1, false, true],
104
            'boolean > boolean'             => [1, true, false],
105
        ];
106
107
        return $args;
108
    }
109
110
    public function compareMethodArraysProvider(): array
111
    {
112
        return [
113
            'integer[]' => [[-67, -9, 0, 4, 5, 6]],
114
            'string[]'  => [['a', 'b', 'c', 'd', 'z', 'z1']],
115
        ];
116
    }
117
    //
118
}
119