Test Failed
Push — master ( 0a806b...30218b )
by Nelson
02:34
created

getTargetClassName()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 3
Code Lines 1

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
cc 1
eloc 1
nc 1
nop 0
dl 0
loc 3
rs 10
c 0
b 0
f 0
1
<?php
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     v0.6.0
14
 * @license   http://www.opensource.org/licenses/mit-license.php The MIT License (MIT)
15
 * */
16
17
namespace NelsonMartell\Test\DataProviders;
18
19
use NelsonMartell\Test\Helpers\ExporterPlugin;
20
use NelsonMartell\Test\Helpers\HasReadOnlyProperties;
21
use NelsonMartell\Test\Helpers\HasReadWriteProperties;
22
use NelsonMartell\Test\Helpers\HasWriteOnlyProperties;
23
use NelsonMartell\Test\Helpers\HasUnaccesibleProperties;
24
use NelsonMartell\Test\Helpers\ImplementsIStrictPropertiesContainer;
25
26
use NelsonMartell\PropertiesHandler;
27
28
/**
29
 * Data providers for NelsonMartell\Test\TestCase\PropertiesHandlerTest.
30
 *
31
 * @author Nelson Martell <[email protected]>
32
 * @internal
33
 * */
34
trait PropertiesHandlerTestProvider
35
{
36
    use ExporterPlugin;
37
    use ImplementsIStrictPropertiesContainer;
38
    use HasUnaccesibleProperties;
39
    use HasWriteOnlyProperties;
40
    use HasReadWriteProperties;
41
    use HasReadOnlyProperties;
42
43
    public function getTargetClassName() : string
44
    {
45
        return PropertiesHandler::class;
46
    }
47
48
    public function objectInstanceProvider()
49
    {
50
        $a = new ExampleClass\A;
51
        $b = new ExampleClass\B;
52
        $c = new ExampleClass\C;
53
        $d = new ExampleClass\D;
54
55
        return [
56
            [$a],
57
            [$b],
58
            [$c],
59
            [$d],
60
        ];
61
    }
62
63
64
    public function writeonlyPropertiesProvider()
65
    {
66
        $a = new ExampleClass\A;
67
        $b = new ExampleClass\B;
68
        $c = new ExampleClass\C;
69
        $d = new ExampleClass\D;
70
71
        return [
72
            'Set parent attribute accesible from parent (write-only property)' => [$b, 'property2', 2],
73
        ];
74
    }
75
76
    public function readwritePropertiesProvider()
77
    {
78
        $a = new ExampleClass\A;
79
        $c = new ExampleClass\C;
80
        $d = new ExampleClass\D;
81
82
        return [
83
            'Set attribute with setter'                                     => [$a, 'property3', 3, (3 * 100)],
84
            'Custom prefix (parent using default): Own property directly'   => [$c, 'property6', 6, (6 * 99)],
85
            'Custom prefix (parent using custom): Own property directly'    => [$d, 'property9', -9, -(9 * 10)],
86
            'Custom prefix (parent using default)): Parent property '       => [$c, 'property3', -3, -(3 * 100)],
87
        ];
88
    }
89
90
91
    public function readonlyPropertiesProvider()
92
    {
93
        $a = new ExampleClass\A;
94
        $b = new ExampleClass\B;
95
        $c = new ExampleClass\C;
96
        $d = new ExampleClass\D;
97
        return [
98
            'Get property accesible via a wrapper'                  => [$a, 'property1', -1],
99
            'Get property accesible using attribute name'           => [$a, 'attribute2', -2],
100
            'Get property accesible from parent only'               => [$b, 'property4', -4],
101
            'Custom prefix: Own attribute directly'                 => [$c, 'attribute5', (-5 * 2)],
102
            'Custom prefix: Parent property'                        => [$d, 'property1', -1],
103
        ];
104
    }
105
106
    public function unaccesiblePropertiesProvider()
107
    {
108
        $a = new ExampleClass\A;
109
        $b = new ExampleClass\B;
110
        $c = new ExampleClass\C;
111
        $d = new ExampleClass\D;
112
113
        return [
114
            'Get inexistent property in base'      => [$a, 'property4'],
115
            'Get existent property with case changed' => [$a, 'Property1'],
116
            'Get inexistent property in child'     => [$b, 'property5'],
117
            'Set inexistent property'              => [$a, 'property6', 6],
118
            'Set read-only property'               => [$b, 'property4', 4],
119
            'Set read-only attribute'              => [$a, 'attribute4', 4],
120
            'Set write-only property'              => [$a, 'property2', 2],
121
            'Set unaccesible property from parent' => [$b, 'property1', 1],
122
            'Existent, but wrong prefixes'         => [$b, 'property7'],
123
            'Existent, but wrong prefixes'         => [$b, 'property7', 7],
124
            'Double definition of custom getter prefix: D::C' => [$d, 'property6'],
125
            'Double definition of custom setter prefix: D::C' => [$d, 'property6', 6],
126
        ];
127
    }
128
}
129