Skip to content

Commit 88c6ef1

Browse files
committed
tweak test
1 parent 67ca776 commit 88c6ef1

File tree

2 files changed

+9
-17
lines changed

2 files changed

+9
-17
lines changed

spec/Middleware/MezzioFactorySpec.php

Lines changed: 7 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -145,9 +145,8 @@
145145

146146
$config = $this->config;
147147
unset($config['db']);
148-
$container = Double::instance(['extends' => ServiceManager::class, 'methods' => '__construct']);
149-
allow($container)->toReceive('get')->with('config')
150-
->andReturn($config);
148+
$container = new ServiceManager();
149+
$container->setService('config', $config);
151150

152151
allow($container)->toReceive('has')->with(EntityManager::class)->andReturn(true);
153152
$entityManager = Double::instance(['extends' => EntityManager::class, 'methods' => '__construct']);
@@ -170,34 +169,27 @@
170169
);
171170

172171
$logging = Double::instance(['extends' => Logging::class, 'methods' => '__construct']);
173-
allow($container)->toReceive('get')->with(Logging::class)
174-
->andReturn($logging);
172+
$container->setService(Logging::class, $logging);
175173

176174
$renderer = Double::instance(['implements' => TemplateRendererInterface::class]);
177175
allow($container)->toReceive('get')->with(TemplateRendererInterface::class)
178176
->andReturn($renderer);
179177

180-
expect($container->has('ErrorHeroModuleLogger'))->toBeFalsy();
181178
$actual = $this->factory($container);
182179
expect($actual)->toBeAnInstanceOf(Mezzio::class);
183-
expect($container->has('ErrorHeroModuleLogger'))->toBeTruthy();
184-
185180

186181
});
187182

188183
it('returns Mezzio Middleware instance without doctrine to laminas-db conversion', function () {
189184

190-
$container = Double::instance(['extends' => ServiceManager::class, 'methods' => '__construct']);
191-
allow($container)->toReceive('get')->with('config')
192-
->andReturn($this->config);
185+
$container = new ServiceManager();
186+
$container->setService('config', $this->config);
193187

194188
$logging = Double::instance(['extends' => Logging::class, 'methods' => '__construct']);
195-
allow($container)->toReceive('get')->with(Logging::class)
196-
->andReturn($logging);
189+
$container->setService(Logging::class, $logging);
197190

198191
$renderer = Double::instance(['implements' => TemplateRendererInterface::class]);
199-
allow($container)->toReceive('get')->with(TemplateRendererInterface::class)
200-
->andReturn($renderer);
192+
$container->setService(TemplateRendererInterface::class, $renderer);
201193

202194
$actual = $this->factory($container);
203195
expect($actual)->toBeAnInstanceOf(Mezzio::class);

spec/ModuleSpec.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -143,8 +143,8 @@
143143
allow($entityManager)->toReceive('getConnection')->andReturn($connection);
144144
allow($serviceManager)->toReceive('get')->with(EntityManager::class)->andReturn($entityManager);
145145

146+
expect($moduleEvent)->toReceive('getParam')->with('ServiceManager');
146147
$this->module->doctrineTransform($moduleEvent);
147-
expect($serviceManager)->toReceive('get')->with(EntityManager::class);
148148

149149
});
150150

@@ -177,8 +177,8 @@
177177
allow($entityManager)->toReceive('getConnection')->andReturn($connection);
178178
allow($serviceManager)->toReceive('get')->with(EntityManager::class)->andReturn($entityManager);
179179

180+
expect($moduleEvent)->toReceive('getParam')->with('ServiceManager');
180181
$this->module->doctrineTransform($moduleEvent);
181-
expect($serviceManager)->toReceive('get')->with(EntityManager::class);
182182

183183
});
184184

0 commit comments

Comments
 (0)