Skip to content

Commit 4040e32

Browse files
committed
Finalized
1 parent 0fb73ac commit 4040e32

File tree

14 files changed

+37
-147
lines changed

14 files changed

+37
-147
lines changed

Tests/Functional/Admin/RouteAdminTest.php

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88

99
use Symfony\Cmf\Bundle\RoutingBundle\Admin\RouteAdmin;
1010
use Symfony\Component\Routing\Route;
11-
use Symfony\Cmf\Component\Testing\Functional\BaseTestCase;
11+
use Symfony\Cmf\Bundle\RoutingBundle\Tests\Functional\BaseTestCase;
1212

1313
class RouteAdminTest extends BaseTestCase
1414
{
@@ -24,6 +24,7 @@ class RouteAdminTest extends BaseTestCase
2424

2525
protected function setUp()
2626
{
27+
parent::setUp();
2728
$this->db('PHPCR')->createTestNode();
2829
$this->routeAdmin = $this->getContainer()->get('cmf_routing.route_admin');
2930
$this->errorElement = $this->getMockBuilder('Sonata\AdminBundle\Validator\ErrorElement')

Tests/Functional/BaseTestCase.php

Lines changed: 14 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,16 +7,17 @@
77
use Symfony\Bundle\FrameworkBundle\Test\WebTestCase;
88
use Symfony\Cmf\Component\Testing\Functional\BaseTestCase as ComponentBaseTestCase;
99
use PHPCR\Util\PathHelper;
10+
use Symfony\Cmf\Component\Testing\Document\Content;
1011

1112
class BaseTestCase extends ComponentBaseTestCase
1213
{
13-
public function getDm()
14+
protected function getDm()
1415
{
1516
$dm = $this->db('PHPCR')->getOm();
1617
return $dm;
1718
}
1819

19-
public function createRoute($path)
20+
protected function createRoute($path)
2021
{
2122
$parentPath = PathHelper::getParentPath($path);
2223
$parent = $this->getDm()->find(null, $parentPath);
@@ -28,4 +29,15 @@ public function createRoute($path)
2829

2930
return $route;
3031
}
32+
33+
protected function createContent($path)
34+
{
35+
$content = new Content;
36+
$content->setId('/test/content');
37+
$content->setTitle('Foo Content');
38+
$this->getDm()->persist($content);
39+
$this->getDm()->flush();
40+
41+
return $content;
42+
}
3143
}

Tests/Functional/Controller/RedirectControllerTest.php

Lines changed: 19 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -9,8 +9,7 @@
99
use Symfony\Cmf\Bundle\RoutingBundle\Doctrine\Phpcr\Route;
1010
use Symfony\Cmf\Bundle\RoutingBundle\Doctrine\Phpcr\RedirectRoute;
1111
use Symfony\Cmf\Bundle\RoutingBundle\Controller\RedirectController;
12-
use Symfony\Cmf\Component\Testing\Functional\BaseTestCase;
13-
use Symfony\Cmf\Component\Testing\Document\Content;
12+
use Symfony\Cmf\Bundle\RoutingBundle\Tests\Functional\BaseTestCase;
1413
use PHPCR\Util\NodeHelper;
1514

1615
class RedirectControllerTest extends BaseTestCase
@@ -26,29 +25,28 @@ public function setUp()
2625
{
2726
parent::setUp();
2827
$this->db('PHPCR')->createTestNode();
29-
$this->db('PHPCR')->createPath(self::ROUTE_ROOT);
30-
$this->dm = $this->db('PHPCR')->getOm();
28+
$this->createRoute(self::ROUTE_ROOT);
3129

3230
$router = $this->getContainer()->get('router');
3331
$this->controller = new RedirectController($router);
3432
}
3533

3634
public function testRedirectUri()
3735
{
38-
$root = $this->dm->find(null, self::ROUTE_ROOT);
36+
$root = $this->getDm()->find(null, self::ROUTE_ROOT);
3937

4038
$redirect = new RedirectRoute;
4139
$redirect->setPosition($root, 'redirectUri');
4240
$redirect->setUri('http://example.com/test-url');
4341
$redirect->setParameters(array('test' => 7)); // parameters should be ignored in this case
4442
$redirect->setPermanent(true);
45-
$this->dm->persist($redirect);
43+
$this->getDm()->persist($redirect);
4644

47-
$this->dm->flush();
45+
$this->getDm()->flush();
4846

49-
$this->dm->clear();
47+
$this->getDm()->clear();
5048

51-
$redirect = $this->dm->find(null, self::ROUTE_ROOT.'/redirectUri');
49+
$redirect = $this->getDm()->find(null, self::ROUTE_ROOT.'/redirectUri');
5250
$response = $this->controller->redirectAction($redirect);
5351

5452
$this->assertInstanceOf('Symfony\Component\HttpFoundation\RedirectResponse', $response);
@@ -58,30 +56,26 @@ public function testRedirectUri()
5856

5957
public function testRedirectContent()
6058
{
61-
$root = $this->dm->find(null, self::ROUTE_ROOT);
59+
$content = $this->createContent('/test/content');
6260

63-
$content = new Content;
64-
$content->setId('/test/content');
65-
$content->setTitle('Foo Content');
66-
$this->dm->persist($content);
67-
$this->dm->flush();
61+
$root = $this->getDm()->find(null, self::ROUTE_ROOT);
6862

6963
$route = new Route;
7064
$route->setContent($content);
7165
$route->setPosition($root, 'testroute');
72-
$this->dm->persist($route);
66+
$this->getDm()->persist($route);
7367

7468
$redirect = new RedirectRoute;
7569
$redirect->setPosition($root, 'redirectContent');
7670
$redirect->setRouteTarget($route);
7771
$redirect->setParameters(array('test' => 'content'));
78-
$this->dm->persist($redirect);
72+
$this->getDm()->persist($redirect);
7973

80-
$this->dm->flush();
74+
$this->getDm()->flush();
8175

82-
$this->dm->clear();
76+
$this->getDm()->clear();
8377

84-
$redirect = $this->dm->find(null, self::ROUTE_ROOT.'/redirectContent');
78+
$redirect = $this->getDm()->find(null, self::ROUTE_ROOT.'/redirectContent');
8579
$response = $this->controller->redirectAction($redirect);
8680

8781
$this->assertInstanceOf('Symfony\\Component\\HttpFoundation\\RedirectResponse', $response);
@@ -91,19 +85,19 @@ public function testRedirectContent()
9185

9286
public function testRedirectName()
9387
{
94-
$root = $this->dm->find(null, self::ROUTE_ROOT);
88+
$root = $this->getDm()->find(null, self::ROUTE_ROOT);
9589

9690
$redirect = new RedirectRoute;
9791
$redirect->setPosition($root, 'redirectName');
9892
$redirect->setRouteName('symfony_route');
9993
$redirect->setParameters(array('param'=>7)); // parameters should be ignored in this case
100-
$this->dm->persist($redirect);
94+
$this->getDm()->persist($redirect);
10195

102-
$this->dm->flush();
96+
$this->getDm()->flush();
10397

104-
$this->dm->clear();
98+
$this->getDm()->clear();
10599

106-
$redirect = $this->dm->find(null, self::ROUTE_ROOT.'/redirectName');
100+
$redirect = $this->getDm()->find(null, self::ROUTE_ROOT.'/redirectName');
107101
$response = $this->controller->redirectAction($redirect);
108102
$this->assertInstanceOf('Symfony\\Component\\HttpFoundation\\RedirectResponse', $response);
109103
$this->assertSame(302, $response->getStatusCode());

Tests/Functional/Doctrine/Phpcr/RedirectRouteTest.php

Lines changed: 1 addition & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,6 @@
66
use Symfony\Cmf\Bundle\RoutingBundle\Doctrine\Phpcr\RedirectRoute;
77
use PHPCR\Util\PathHelper;
88
use Symfony\Cmf\Bundle\RoutingBundle\Tests\Functional\BaseTestCase;
9-
use Symfony\Cmf\Component\Testing\Document\Content;
109

1110
class RedirectRouteTest extends BaseTestCase
1211
{
@@ -21,14 +20,9 @@ public function setUp()
2120

2221
public function testRedirectDoctrine()
2322
{
23+
$content = $this->createContent('/test/content');
2424
$root = $this->getDm()->find(null, self::ROUTE_ROOT);
2525

26-
$content = new Content;
27-
$content->setId('/test/content');
28-
$content->setTitle('Foo Content');
29-
$this->getDm()->persist($content);
30-
$this->getDm()->flush();
31-
3226
$route = new Route;
3327
$route->setContent($content);
3428
$route->setPosition($root, 'testroute');

Tests/Functional/config/cmf-routing.yml

Lines changed: 0 additions & 16 deletions
This file was deleted.

Tests/Functional/config/default.yml

Lines changed: 0 additions & 7 deletions
This file was deleted.

Tests/Functional/config/doctrine.yml

Lines changed: 0 additions & 5 deletions
This file was deleted.

Tests/Functional/config/framework.yml

Lines changed: 0 additions & 15 deletions
This file was deleted.

Tests/Functional/config/monolog.yml

Lines changed: 0 additions & 10 deletions
This file was deleted.

Tests/Functional/config/parameters.yml

Lines changed: 0 additions & 14 deletions
This file was deleted.

0 commit comments

Comments
 (0)