Skip to content

Commit a88f009

Browse files
committed
merged 2.1
1 parent 4dbb688 commit a88f009

File tree

1 file changed

+33
-10
lines changed

1 file changed

+33
-10
lines changed

src/Codeception/Module/Symfony.php

Lines changed: 33 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -142,8 +142,8 @@ public function _initialize()
142142
"modules:\n enabled:\n" .
143143
" - Symfony:\n" .
144144
" var_path: '../../app'\n" .
145-
" app_path: '../../app'");
146-
145+
" app_path: '../../app'"
146+
);
147147
}
148148
require_once $cache;
149149
$this->kernelClass = $this->getKernelClass();
@@ -226,14 +226,22 @@ protected function getKernelClass()
226226
{
227227
$path = \Codeception\Configuration::projectDir() . $this->config['app_path'];
228228
if (!file_exists(\Codeception\Configuration::projectDir() . $this->config['app_path'])) {
229-
throw new ModuleRequireException(__CLASS__, "Can't load Kernel from $path.\nDirectory does not exists. Use `app_path` parameter to provide valid application path");
229+
throw new ModuleRequireException(
230+
__CLASS__,
231+
"Can't load Kernel from $path.\n"
232+
. "Directory does not exists. Use `app_path` parameter to provide valid application path"
233+
);
230234
}
231235

232236
$finder = new Finder();
233237
$finder->name('*Kernel.php')->depth('0')->in($path);
234238
$results = iterator_to_array($finder);
235239
if (!count($results)) {
236-
throw new ModuleRequireException(__CLASS__, "AppKernel was not found at $path. Specify directory where Kernel class for your application is located with `app_path` parameter.");
240+
throw new ModuleRequireException(
241+
__CLASS__,
242+
"AppKernel was not found at $path. "
243+
. "Specify directory where Kernel class for your application is located with `app_path` parameter."
244+
);
237245
}
238246

239247
$file = current($results);
@@ -331,8 +339,18 @@ public function seeCurrentRouteIs($routeName, array $params = [])
331339
if (!$router->getRouteCollection()->get($routeName)) {
332340
$this->fail(sprintf('Route with name "%s" does not exists.', $routeName));
333341
}
334-
$url = $router->generate($routeName, $params);
335-
$this->seeCurrentUrlEquals($url);
342+
343+
$uri = explode('?', $this->grabFromCurrentUrl())[0];
344+
try {
345+
$match = $router->match($uri);
346+
} catch (\Symfony\Component\Routing\Exception\ResourceNotFoundException $e) {
347+
$this->fail(sprintf('The "%s" url does not match with any route', $uri));
348+
}
349+
$expected = array_merge(array('_route' => $routeName), $params);
350+
$intersection = array_intersect_assoc($expected, $match);
351+
352+
$this->assertEquals($expected, $intersection);
353+
336354
}
337355

338356
/**
@@ -354,10 +372,11 @@ public function seeInCurrentRoute($routeName)
354372
$this->fail(sprintf('Route with name "%s" does not exists.', $routeName));
355373
}
356374

375+
$uri = explode('?', $this->grabFromCurrentUrl())[0];
357376
try {
358-
$matchedRouteName = $router->match($this->grabFromCurrentUrl())['_route'];
359-
} catch (\Exception\ResourceNotFoundException $e) {
360-
$this->fail(sprintf('The "%s" url does not match with any route', $routeName));
377+
$matchedRouteName = $router->match($uri)['_route'];
378+
} catch (\Symfony\Component\Routing\Exception\ResourceNotFoundException $e) {
379+
$this->fail(sprintf('The "%s" url does not match with any route', $uri));
361380
}
362381

363382
$this->assertEquals($matchedRouteName, $routeName);
@@ -447,7 +466,11 @@ protected function debugResponse($url)
447466
if ($profile = $this->getProfile()) {
448467
if ($profile->hasCollector('security')) {
449468
if ($profile->getCollector('security')->isAuthenticated()) {
450-
$this->debugSection('User', $profile->getCollector('security')->getUser() . ' [' . implode(',', $profile->getCollector('security')->getRoles()) . ']');
469+
$this->debugSection(
470+
'User',
471+
$profile->getCollector('security')->getUser()
472+
. ' [' . implode(',', $profile->getCollector('security')->getRoles()) . ']'
473+
);
451474
} else {
452475
$this->debugSection('User', 'Anonymous');
453476
}

0 commit comments

Comments
 (0)