Skip to content

Commit

Permalink
Merge pull request #2 from Kunstmaan/fix-unit-tests-for-php53
Browse files Browse the repository at this point in the history
fix unit tests for php 5.3
  • Loading branch information
Roderik van der Veer committed Apr 17, 2014
2 parents d0dec59 + da08098 commit 05edb04
Showing 1 changed file with 30 additions and 8 deletions.
38 changes: 30 additions & 8 deletions Tests/Router/RedirectRouterTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -37,13 +37,35 @@ protected function setUp()
$this->object = new RedirectRouter($this->repository);
}

/**
* @param int $id
* @param string $origin
* @param string $target
* @param boolean $permanent
*
* @return Redirect
*/
private function getRedirect($id, $origin, $target, $permanent)
{
$redirect = new Redirect();
$redirect
->setOrigin($origin)
->setTarget($target)
->setPermanent($permanent)
->setId($id);

return $redirect;
}

/**
* @return \Kunstmaan\RedirectBundle\Entity\Redirect[]
*/
private function getRedirects()
{
if (!isset($this->redirects)) {
$this->redirects = array(
(new Redirect())->setOrigin('test')->setTarget('/target1')->setPermanent(false)->setId(1),
(new Redirect())->setOrigin('test2')->setTarget('/target2')->setPermanent(true)->setId(2)
);
$this->redirects = array();
$this->redirects[] = $this->getRedirect(1, 'test', '/target1', false);
$this->redirects[] = $this->getRedirect(2, 'test2', '/target2', true);
}

return $this->redirects;
Expand Down Expand Up @@ -99,13 +121,13 @@ public function testGenerate()
*/
public function testMatch()
{
$redirect = $this->object->match('/test');
$redirect = $this->object->match('/test2');
$this->assertEquals(
array(
'_controller' => 'FrameworkBundle:Redirect:urlRedirect',
'path' => '/target1',
'permanent' => false,
'_route' => '_redirect_route_1'
'path' => '/target2',
'permanent' => true,
'_route' => '_redirect_route_2'
),
$redirect
);
Expand Down

0 comments on commit 05edb04

Please sign in to comment.