@@ -95,32 +95,35 @@ public function testThatDecoratorReturnsTheSameInstanceIfFactoryFails(): void
95
95
#[TestDox('Test that `decorate` method decorates possible inner objects / services ' )]
96
96
public function testThatDecoratorAlsoDecoratesInnerObjects (): void
97
97
{
98
- self ::markTestSkipped ('Skipped for now, as this is not working as expected... ' );
99
-
100
- //$managerRegistry = $this->getMockBuilder(ManagerRegistry::class)->disableOriginalConstructor()->getMock();
101
- //$entityManager = $this->getMockBuilder(EntityManager::class)->disableOriginalConstructor()->getMock();
102
- //$stopWatch = $this->getMockBuilder(Stopwatch::class)->disableOriginalConstructor()->getMock();
103
- //
104
- //$managerRegistry
105
- // ->expects($this->once())
106
- // ->method('getManagerForClass')
107
- // ->willReturn($entityManager);
108
- //
109
- //$stopWatch
110
- // ->expects($this->exactly(2))
111
- // ->method('start');
112
- //
113
- //$stopWatch
114
- // ->expects($this->exactly(2))
115
- // ->method('stop');
116
- //
117
- //$decorator = new StopwatchDecorator(new AccessInterceptorValueHolderFactory(), $stopWatch);
118
- //$repository = new ApiKeyRepository($managerRegistry);
119
- //$resource = new ApiKeyResource($repository);
120
- //
121
- ///** @var ApiKeyResource $decoratedService */
122
- //$decoratedService = $decorator->decorate($resource);
123
- //$decoratedService->getRepository()->getEntityManager();
98
+ $ managerRegistry = $ this ->getMockBuilder (ManagerRegistry::class)->disableOriginalConstructor ()->getMock ();
99
+ $ entityManager = $ this ->getMockBuilder (EntityManager::class)->disableOriginalConstructor ()->getMock ();
100
+ $ stopWatch = $ this ->getMockBuilder (Stopwatch::class)->disableOriginalConstructor ()->getMock ();
101
+
102
+ $ managerRegistry
103
+ ->expects ($ this ->once ())
104
+ ->method ('getManagerForClass ' )
105
+ ->willReturn ($ entityManager );
106
+
107
+ $ entityManager
108
+ ->expects ($ this ->once ())
109
+ ->method ('isOpen ' )
110
+ ->willReturn (true );
111
+
112
+ $ stopWatch
113
+ ->expects ($ this ->exactly (2 ))
114
+ ->method ('start ' );
115
+
116
+ $ stopWatch
117
+ ->expects ($ this ->exactly (2 ))
118
+ ->method ('stop ' );
119
+
120
+ $ decorator = new StopwatchDecorator (new AccessInterceptorValueHolderFactory (), $ stopWatch );
121
+ $ repository = new ApiKeyRepository ($ managerRegistry );
122
+ $ resource = new ApiKeyResource ($ repository );
123
+
124
+ /** @var ApiKeyResource $decoratedService */
125
+ $ decoratedService = $ decorator ->decorate ($ resource );
126
+ $ decoratedService ->getRepository ()->getEntityManager ();
124
127
}
125
128
126
129
/**
@@ -129,39 +132,42 @@ public function testThatDecoratorAlsoDecoratesInnerObjects(): void
129
132
#[TestDox('Test that `decorate` method does not decorate entity objects ' )]
130
133
public function testThatDecoratorDoesNotTryToDecorateEntityObjects (): void
131
134
{
132
- self ::markTestSkipped ('Skipped for now, as this is not working as expected... ' );
133
-
134
- //$apiKey = new ApiKey();
135
- //
136
- //$managerRegistry = $this->getMockBuilder(ManagerRegistry::class)->disableOriginalConstructor()->getMock();
137
- //$entityManager = $this->getMockBuilder(EntityManager::class)->disableOriginalConstructor()->getMock();
138
- //$stopWatch = $this->getMockBuilder(Stopwatch::class)->disableOriginalConstructor()->getMock();
139
- //
140
- //$managerRegistry
141
- // ->expects($this->once())
142
- // ->method('getManagerForClass')
143
- // ->willReturn($entityManager);
144
- //
145
- //$entityManager
146
- // ->expects($this->once())
147
- // ->method('find')
148
- // ->willReturn($apiKey);
149
- //
150
- //$stopWatch
151
- // ->expects($this->once())
152
- // ->method('start');
153
- //
154
- //$stopWatch
155
- // ->expects($this->once())
156
- // ->method('stop');
157
- //
158
- //$decorator = new StopwatchDecorator(new AccessInterceptorValueHolderFactory(), $stopWatch);
159
- //$repository = new ApiKeyRepository($managerRegistry);
160
- //
161
- ///** @var ApiKeyRepository $decoratedService */
162
- //$decoratedService = $decorator->decorate($repository);
163
- //
164
- //self::assertSame($apiKey, $decoratedService->find($apiKey->getId()));
135
+ $ apiKey = new ApiKey ();
136
+
137
+ $ managerRegistry = $ this ->getMockBuilder (ManagerRegistry::class)->disableOriginalConstructor ()->getMock ();
138
+ $ entityManager = $ this ->getMockBuilder (EntityManager::class)->disableOriginalConstructor ()->getMock ();
139
+ $ stopWatch = $ this ->getMockBuilder (Stopwatch::class)->disableOriginalConstructor ()->getMock ();
140
+
141
+ $ managerRegistry
142
+ ->expects ($ this ->once ())
143
+ ->method ('getManagerForClass ' )
144
+ ->willReturn ($ entityManager );
145
+
146
+ $ entityManager
147
+ ->expects ($ this ->once ())
148
+ ->method ('find ' )
149
+ ->willReturn ($ apiKey );
150
+
151
+ $ entityManager
152
+ ->expects ($ this ->once ())
153
+ ->method ('isOpen ' )
154
+ ->willReturn (true );
155
+
156
+ $ stopWatch
157
+ ->expects ($ this ->once ())
158
+ ->method ('start ' );
159
+
160
+ $ stopWatch
161
+ ->expects ($ this ->once ())
162
+ ->method ('stop ' );
163
+
164
+ $ decorator = new StopwatchDecorator (new AccessInterceptorValueHolderFactory (), $ stopWatch );
165
+ $ repository = new ApiKeyRepository ($ managerRegistry );
166
+
167
+ /** @var ApiKeyRepository $decoratedService */
168
+ $ decoratedService = $ decorator ->decorate ($ repository );
169
+
170
+ self ::assertSame ($ apiKey , $ decoratedService ->find ($ apiKey ->getId ()));
165
171
}
166
172
167
173
/**
0 commit comments