1212namespace Symfony \Cmf \Bundle \RoutingBundle \Tests \WebTest ;
1313
1414use Symfony \Cmf \Component \Testing \Functional \BaseTestCase ;
15+ use Symfony \Component \DomCrawler \Crawler ;
1516
1617class RedirectRouteAdminTest extends BaseTestCase
1718{
19+ /**
20+ * @var \Symfony\Bundle\FrameworkBundle\Client
21+ */
22+ private $ client ;
23+
1824 public function setUp ()
1925 {
2026 $ this ->db ('PHPCR ' )->loadFixtures (array (
@@ -37,11 +43,15 @@ public function testRedirectRouteEdit()
3743 $ res = $ this ->client ->getResponse ();
3844 $ this ->assertEquals (200 , $ res ->getStatusCode ());
3945 $ this ->assertCount (1 , $ crawler ->filter ('input[value="redirect-route-1"] ' ));
46+
47+ $ this ->assertFrontendLinkPresent ($ crawler );
4048 }
4149
4250 public function testRedirectRouteShow ()
4351 {
44- $ this ->markTestSkipped ('Not implemented yet. ' );
52+ $ crawler = $ this ->client ->request ('GET ' , '/admin/cmf/routing/redirectroute/test/routing/redirect-route-1/show ' );
53+ $ res = $ this ->client ->getResponse ();
54+ $ this ->assertEquals (200 , $ res ->getStatusCode ());
4555 }
4656
4757 public function testRedirectRouteCreate ()
@@ -50,19 +60,38 @@ public function testRedirectRouteCreate()
5060 $ res = $ this ->client ->getResponse ();
5161 $ this ->assertEquals (200 , $ res ->getStatusCode ());
5262
63+ $ this ->assertFrontendLinkNotPresent ($ crawler );
64+
5365 $ button = $ crawler ->selectButton ('Create ' );
5466 $ form = $ button ->form ();
5567 $ node = $ form ->getFormNode ();
5668 $ actionUrl = $ node ->getAttribute ('action ' );
5769 $ uniqId = substr (strchr ($ actionUrl , '= ' ), 1 );
5870
59- $ form [$ uniqId. '[parent] ' ] = '/test/routing ' ;
60- $ form [$ uniqId. '[name] ' ] = 'foo-test ' ;
71+ $ form [$ uniqId . '[parent] ' ] = '/test/routing ' ;
72+ $ form [$ uniqId . '[name] ' ] = 'foo-test ' ;
6173
6274 $ this ->client ->submit ($ form );
6375 $ res = $ this ->client ->getResponse ();
6476
6577 // If we have a 302 redirect, then all is well
6678 $ this ->assertEquals (302 , $ res ->getStatusCode ());
6779 }
80+
81+ /**
82+ * @param Crawler $crawler
83+ */
84+ private function assertFrontendLinkPresent (Crawler $ crawler )
85+ {
86+ $ this ->assertCount (1 , $ link = $ crawler ->filter ('a[class="sonata-admin-frontend-link"] ' ));
87+ $ this ->assertEquals ('/redirect-route-1 ' , $ link ->attr ('href ' ));
88+ }
89+
90+ /**
91+ * @param Crawler $crawler
92+ */
93+ private function assertFrontendLinkNotPresent (Crawler $ crawler )
94+ {
95+ $ this ->assertCount (0 , $ crawler ->filter ('a[class="sonata-admin-frontend-link"] ' ));
96+ }
6897}
0 commit comments