9
9
use Symfony \Cmf \Bundle \RoutingBundle \Doctrine \Phpcr \Route ;
10
10
use Symfony \Cmf \Bundle \RoutingBundle \Doctrine \Phpcr \RedirectRoute ;
11
11
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 ;
14
13
use PHPCR \Util \NodeHelper ;
15
14
16
15
class RedirectControllerTest extends BaseTestCase
@@ -26,29 +25,28 @@ public function setUp()
26
25
{
27
26
parent ::setUp ();
28
27
$ 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 );
31
29
32
30
$ router = $ this ->getContainer ()->get ('router ' );
33
31
$ this ->controller = new RedirectController ($ router );
34
32
}
35
33
36
34
public function testRedirectUri ()
37
35
{
38
- $ root = $ this ->dm ->find (null , self ::ROUTE_ROOT );
36
+ $ root = $ this ->getDm () ->find (null , self ::ROUTE_ROOT );
39
37
40
38
$ redirect = new RedirectRoute ;
41
39
$ redirect ->setPosition ($ root , 'redirectUri ' );
42
40
$ redirect ->setUri ('http://example.com/test-url ' );
43
41
$ redirect ->setParameters (array ('test ' => 7 )); // parameters should be ignored in this case
44
42
$ redirect ->setPermanent (true );
45
- $ this ->dm ->persist ($ redirect );
43
+ $ this ->getDm () ->persist ($ redirect );
46
44
47
- $ this ->dm ->flush ();
45
+ $ this ->getDm () ->flush ();
48
46
49
- $ this ->dm ->clear ();
47
+ $ this ->getDm () ->clear ();
50
48
51
- $ redirect = $ this ->dm ->find (null , self ::ROUTE_ROOT .'/redirectUri ' );
49
+ $ redirect = $ this ->getDm () ->find (null , self ::ROUTE_ROOT .'/redirectUri ' );
52
50
$ response = $ this ->controller ->redirectAction ($ redirect );
53
51
54
52
$ this ->assertInstanceOf ('Symfony\Component\HttpFoundation\RedirectResponse ' , $ response );
@@ -58,30 +56,26 @@ public function testRedirectUri()
58
56
59
57
public function testRedirectContent ()
60
58
{
61
- $ root = $ this ->dm -> find ( null , self :: ROUTE_ROOT );
59
+ $ content = $ this ->createContent ( ' /test/content ' );
62
60
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 );
68
62
69
63
$ route = new Route ;
70
64
$ route ->setContent ($ content );
71
65
$ route ->setPosition ($ root , 'testroute ' );
72
- $ this ->dm ->persist ($ route );
66
+ $ this ->getDm () ->persist ($ route );
73
67
74
68
$ redirect = new RedirectRoute ;
75
69
$ redirect ->setPosition ($ root , 'redirectContent ' );
76
70
$ redirect ->setRouteTarget ($ route );
77
71
$ redirect ->setParameters (array ('test ' => 'content ' ));
78
- $ this ->dm ->persist ($ redirect );
72
+ $ this ->getDm () ->persist ($ redirect );
79
73
80
- $ this ->dm ->flush ();
74
+ $ this ->getDm () ->flush ();
81
75
82
- $ this ->dm ->clear ();
76
+ $ this ->getDm () ->clear ();
83
77
84
- $ redirect = $ this ->dm ->find (null , self ::ROUTE_ROOT .'/redirectContent ' );
78
+ $ redirect = $ this ->getDm () ->find (null , self ::ROUTE_ROOT .'/redirectContent ' );
85
79
$ response = $ this ->controller ->redirectAction ($ redirect );
86
80
87
81
$ this ->assertInstanceOf ('Symfony \\Component \\HttpFoundation \\RedirectResponse ' , $ response );
@@ -91,19 +85,19 @@ public function testRedirectContent()
91
85
92
86
public function testRedirectName ()
93
87
{
94
- $ root = $ this ->dm ->find (null , self ::ROUTE_ROOT );
88
+ $ root = $ this ->getDm () ->find (null , self ::ROUTE_ROOT );
95
89
96
90
$ redirect = new RedirectRoute ;
97
91
$ redirect ->setPosition ($ root , 'redirectName ' );
98
92
$ redirect ->setRouteName ('symfony_route ' );
99
93
$ redirect ->setParameters (array ('param ' =>7 )); // parameters should be ignored in this case
100
- $ this ->dm ->persist ($ redirect );
94
+ $ this ->getDm () ->persist ($ redirect );
101
95
102
- $ this ->dm ->flush ();
96
+ $ this ->getDm () ->flush ();
103
97
104
- $ this ->dm ->clear ();
98
+ $ this ->getDm () ->clear ();
105
99
106
- $ redirect = $ this ->dm ->find (null , self ::ROUTE_ROOT .'/redirectName ' );
100
+ $ redirect = $ this ->getDm () ->find (null , self ::ROUTE_ROOT .'/redirectName ' );
107
101
$ response = $ this ->controller ->redirectAction ($ redirect );
108
102
$ this ->assertInstanceOf ('Symfony \\Component \\HttpFoundation \\RedirectResponse ' , $ response );
109
103
$ this ->assertSame (302 , $ response ->getStatusCode ());
0 commit comments