1
|
|
|
<?php |
2
|
|
|
|
3
|
|
|
declare(strict_types=1); |
4
|
|
|
|
5
|
|
|
namespace RoaveTest\ApiCompare\Comparator\BackwardsCompatibility\PropertyBased; |
6
|
|
|
|
7
|
|
|
use PHPUnit\Framework\MockObject\MockObject; |
8
|
|
|
use PHPUnit\Framework\TestCase; |
9
|
|
|
use Roave\ApiCompare\Change; |
10
|
|
|
use Roave\ApiCompare\Changes; |
11
|
|
|
use Roave\ApiCompare\Comparator\BackwardsCompatibility\PropertyBased\AccessiblePropertyChanged; |
12
|
|
|
use Roave\ApiCompare\Comparator\BackwardsCompatibility\PropertyBased\PropertyBased; |
13
|
|
|
use Roave\BetterReflection\Reflection\ReflectionProperty; |
14
|
|
|
|
15
|
|
|
/** |
16
|
|
|
* @covers \Roave\ApiCompare\Comparator\BackwardsCompatibility\PropertyBased\AccessiblePropertyChanged |
17
|
|
|
*/ |
18
|
|
|
final class AccessiblePropertyChangedTest extends TestCase |
19
|
|
|
{ |
20
|
|
|
/** |
21
|
|
|
* @var PropertyBased|MockObject |
22
|
|
|
*/ |
23
|
|
|
private $check; |
24
|
|
|
|
25
|
|
|
/** |
26
|
|
|
* @var ReflectionProperty|MockObject |
27
|
|
|
*/ |
28
|
|
|
private $fromProperty; |
29
|
|
|
|
30
|
|
|
/** |
31
|
|
|
* @var ReflectionProperty|MockObject |
32
|
|
|
*/ |
33
|
|
|
private $toProperty; |
34
|
|
|
|
35
|
|
|
/** |
36
|
|
|
* @var AccessiblePropertyChanged |
37
|
|
|
*/ |
38
|
|
|
private $accessiblePropertyChanged; |
39
|
|
|
|
40
|
|
|
protected function setUp() : void |
41
|
|
|
{ |
42
|
|
|
parent::setUp(); |
43
|
|
|
|
44
|
|
|
$this->check = $this->createMock(PropertyBased::class); |
45
|
|
|
$this->accessiblePropertyChanged = new AccessiblePropertyChanged($this->check); |
46
|
|
|
$this->fromProperty = $this->createMock(ReflectionProperty::class); |
47
|
|
|
$this->toProperty = $this->createMock(ReflectionProperty::class); |
48
|
|
|
} |
49
|
|
|
|
50
|
|
|
public function testSkipsPrivateProperty() : void |
51
|
|
|
{ |
52
|
|
|
$this |
53
|
|
|
->check |
54
|
|
|
->expects(self::never()) |
|
|
|
|
55
|
|
|
->method('compare'); |
56
|
|
|
|
57
|
|
|
$this |
58
|
|
|
->fromProperty |
59
|
|
|
->expects(self::any()) |
|
|
|
|
60
|
|
|
->method('isPrivate') |
61
|
|
|
->willReturn(true); |
62
|
|
|
|
63
|
|
|
self::assertEquals( |
64
|
|
|
Changes::new(), |
65
|
|
|
$this->accessiblePropertyChanged->compare($this->fromProperty, $this->toProperty) |
66
|
|
|
); |
67
|
|
|
} |
68
|
|
|
|
69
|
|
|
public function testChecksAccessibleProperty() : void |
70
|
|
|
{ |
71
|
|
|
$changes = Changes::fromArray([Change::changed(uniqid('potato', true), true)]); |
72
|
|
|
|
73
|
|
|
$this |
74
|
|
|
->check |
75
|
|
|
->expects(self::atLeastOnce()) |
76
|
|
|
->method('compare') |
77
|
|
|
->with($this->fromProperty, $this->toProperty) |
78
|
|
|
->willReturn($changes); |
79
|
|
|
|
80
|
|
|
$this |
81
|
|
|
->fromProperty |
82
|
|
|
->expects(self::any()) |
83
|
|
|
->method('isPrivate') |
84
|
|
|
->willReturn(false); |
85
|
|
|
|
86
|
|
|
self::assertEquals( |
87
|
|
|
$changes, |
88
|
|
|
$this->accessiblePropertyChanged->compare($this->fromProperty, $this->toProperty) |
89
|
|
|
); |
90
|
|
|
} |
91
|
|
|
} |
92
|
|
|
|
This check looks for calls to methods that do not seem to exist on a given type. It looks for the method on the type itself as well as in inherited classes or implemented interfaces.
This is most likely a typographical error or the method has been renamed.