File: 0002-Adapt-to-recent-version-of-PHPUnit-9.patch

package info (click to toggle)
php-zend-eventmanager 3.3.0-2
  • links: PTS, VCS
  • area: main
  • in suites: bullseye
  • size: 972 kB
  • sloc: php: 3,295; makefile: 13; xml: 7
file content (142 lines) | stat: -rw-r--r-- 5,472 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
From: =?utf-8?q?David_Pr=C3=A9vot?= <taffit@debian.org>
Date: Fri, 25 Dec 2020 12:49:06 -0400
Subject: Adapt to recent version of PHPUnit (9)

---
 test/EventManagerAwareTraitTest.php | 17 +++++++++++++++--
 test/EventManagerTest.php           | 25 ++++++++++++++++++++++---
 test/LazyListenerTest.php           | 17 ++++++++++++++++-
 3 files changed, 53 insertions(+), 6 deletions(-)

diff --git a/test/EventManagerAwareTraitTest.php b/test/EventManagerAwareTraitTest.php
index 327af68..65d3008 100644
--- a/test/EventManagerAwareTraitTest.php
+++ b/test/EventManagerAwareTraitTest.php
@@ -13,6 +13,7 @@ use Laminas\EventManager\EventManagerAwareTrait;
 use Laminas\EventManager\EventManagerInterface;
 use LaminasTest\EventManager\TestAsset\MockEventManagerAwareTrait;
 use PHPUnit\Framework\TestCase;
+use ReflectionObject;
 
 class EventManagerAwareTraitTest extends TestCase
 {
@@ -20,13 +21,25 @@ class EventManagerAwareTraitTest extends TestCase
     {
         $object = $this->getObjectForTrait(EventManagerAwareTrait::class);
 
-        self::assertAttributeEquals(null, 'events', $object);
+        $reflector = new ReflectionObject($object);
+        $attribute = $reflector->getProperty('events');
+        $attribute->setAccessible(true);
+        $value = $attribute->getValue($object);
+        $attribute->setAccessible(false);
+
+        self::assertEquals(null, $value);
 
         $eventManager = new EventManager;
 
         $object->setEventManager($eventManager);
 
-        self::assertAttributeEquals($eventManager, 'events', $object);
+        $reflector = new ReflectionObject($object);
+        $attribute = $reflector->getProperty('events');
+        $attribute->setAccessible(true);
+        $value = $attribute->getValue($object);
+        $attribute->setAccessible(false);
+
+        self::assertEquals($eventManager, $value);
     }
 
     public function testGetEventManager()
diff --git a/test/EventManagerTest.php b/test/EventManagerTest.php
index 8ccd054..b2790a0 100644
--- a/test/EventManagerTest.php
+++ b/test/EventManagerTest.php
@@ -16,6 +16,7 @@ use Laminas\EventManager\ResponseCollection;
 use Laminas\EventManager\SharedEventManager;
 use Laminas\EventManager\SharedEventManagerInterface;
 use PHPUnit\Framework\TestCase;
+use ReflectionObject;
 use ReflectionProperty;
 use stdClass;
 
@@ -111,7 +112,13 @@ class EventManagerTest extends TestCase
 
     public function testAttachShouldAddEventIfItDoesNotExist()
     {
-        self::assertAttributeEmpty('events', $this->events);
+        $reflector = new ReflectionObject($this->events);
+        $attribute = $reflector->getProperty('events');
+        $attribute->setAccessible(true);
+        $value = $attribute->getValue($this->events);
+        $attribute->setAccessible(false);
+
+        self::assertEmpty($value);
         $listener = $this->events->attach('test', [$this, __METHOD__]);
         $events = $this->getEventListFromManager($this->events);
         self::assertNotEmpty($events);
@@ -423,7 +430,13 @@ class EventManagerTest extends TestCase
 
     public function testCreatesAnEventPrototypeAtInstantiation()
     {
-        self::assertAttributeInstanceOf(EventInterface::class, 'eventPrototype', $this->events);
+        $reflector = new ReflectionObject($this->events);
+        $attribute = $reflector->getProperty('eventPrototype');
+        $attribute->setAccessible(true);
+        $value = $attribute->getValue($this->events);
+        $attribute->setAccessible(false);
+
+        self::assertInstanceOf(EventInterface::class, $value);
     }
 
     public function testSetEventPrototype()
@@ -431,7 +444,13 @@ class EventManagerTest extends TestCase
         $event = $this->prophesize(EventInterface::class)->reveal();
         $this->events->setEventPrototype($event);
 
-        self::assertAttributeSame($event, 'eventPrototype', $this->events);
+        $reflector = new ReflectionObject($this->events);
+        $attribute = $reflector->getProperty('eventPrototype');
+        $attribute->setAccessible(true);
+        $value = $attribute->getValue($this->events);
+        $attribute->setAccessible(false);
+
+        self::assertSame($event, $value);
     }
 
     public function testSharedManagerClearListenersReturnsFalse()
diff --git a/test/LazyListenerTest.php b/test/LazyListenerTest.php
index f684bb4..01d6d59 100644
--- a/test/LazyListenerTest.php
+++ b/test/LazyListenerTest.php
@@ -14,6 +14,7 @@ use Laminas\EventManager\Exception\InvalidArgumentException;
 use Laminas\EventManager\LazyListener;
 use PHPUnit\Framework\TestCase;
 use Prophecy\Argument;
+use ReflectionObject;
 use stdClass;
 
 class LazyListenerTest extends TestCase
@@ -114,7 +115,21 @@ class LazyListenerTest extends TestCase
      */
     public function testInstatiationSetsListenerMethod($listener)
     {
-        self::assertAttributeEquals('method', 'method', $listener);
+        $reflector = new ReflectionObject($listener);
+
+        do {
+            try {
+                $attribute = $reflector->getProperty('method');
+
+                $attribute->setAccessible(true);
+                $value = $attribute->getValue($listener);
+                $attribute->setAccessible(false);
+
+            } catch (\ReflectionException $e) {
+            }
+	} while ($reflector = $reflector->getParentClass());
+
+        self::assertEquals('method', $value);
     }
 
     public function testLazyListenerActsAsInvokableAroundListenerCreation()