Skip to content
This repository

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse code

adjust RouteCollectionTest for the addCollection change and refactor …

…the tests to only skip the part that really needs the config component
  • Loading branch information...
commit 3dbe725c88ec2804168db9ebc2bded5c2cc374ae 1 parent ec69fcb
Tobias Schultze authored December 07, 2012

Showing 1 changed file with 19 additions and 33 deletions. Show diff stats Hide diff stats

  1. 52  Tests/RouteCollectionTest.php
52  Tests/RouteCollectionTest.php
@@ -83,30 +83,29 @@ public function testCount()
83 83
 
84 84
     public function testAddCollection()
85 85
     {
86  
-        if (!class_exists('Symfony\Component\Config\Resource\FileResource')) {
87  
-            $this->markTestSkipped('The "Config" component is not available');
88  
-        }
89  
-
90 86
         $collection = new RouteCollection();
91  
-        $collection->add('foo', $foo = new Route('/foo'));
  87
+        $collection->add('foo', new Route('/foo'));
  88
+
92 89
         $collection1 = new RouteCollection();
93  
-        $collection1->add('foo', $foo1 = new Route('/foo1'));
94  
-        $collection1->add('bar', $bar1 = new Route('/bar1'));
  90
+        $collection1->add('bar', $bar = new Route('/bar'));
  91
+        $collection1->add('foo', $foo = new Route('/foo-new'));
  92
+
  93
+        $collection2 = new RouteCollection();
  94
+        $collection2->add('grandchild', $grandchild = new Route('/grandchild'));
  95
+
  96
+        $collection1->addCollection($collection2);
95 97
         $collection->addCollection($collection1);
96  
-        $this->assertEquals(array('foo' => $foo1, 'bar' => $bar1), $collection->all(), '->addCollection() adds routes from another collection');
  98
+        $collection->add('last', $last = new Route('/last'));
97 99
 
98  
-        $collection = new RouteCollection();
99  
-        $collection->add('foo', $foo = new Route('/foo'));
100  
-        $collection1 = new RouteCollection();
101  
-        $collection1->add('foo', $foo1 = new Route('/foo1'));
102  
-        $collection->addCollection($collection1, '/{foo}', array('foo' => 'foo'), array('foo' => '\d+'), array('foo' => 'bar'));
103  
-        $this->assertEquals('/{foo}/foo1', $collection->get('foo')->getPath(), '->addCollection() can add a prefix to all merged routes');
104  
-        $this->assertEquals(array('foo' => 'foo'), $collection->get('foo')->getDefaults(), '->addCollection() can add a prefix to all merged routes');
105  
-        $this->assertEquals(array('foo' => '\d+'), $collection->get('foo')->getRequirements(), '->addCollection() can add a prefix to all merged routes');
106  
-        $this->assertEquals(
107  
-            array('foo' => 'bar', 'compiler_class' => 'Symfony\\Component\\Routing\\RouteCompiler'),
108  
-            $collection->get('foo')->getOptions(), '->addCollection() can add an option to all merged routes'
109  
-        );
  100
+        $this->assertSame(array('bar' => $bar, 'foo' => $foo, 'grandchild' => $grandchild, 'last' => $last), $collection->all(), 
  101
+            '->addCollection() imports routes of another collection, overrides if necessary and adds them at the end');
  102
+    }
  103
+
  104
+    public function testAddCollectionWithResources()
  105
+    {
  106
+        if (!class_exists('Symfony\Component\Config\Resource\FileResource')) {
  107
+            $this->markTestSkipped('The "Config" component is not available');
  108
+        }
110 109
 
111 110
         $collection = new RouteCollection();
112 111
         $collection->addResource($foo = new FileResource(__DIR__.'/Fixtures/foo.xml'));
@@ -150,19 +149,6 @@ public function testAddPrefixOverridesDefaultsAndRequirements()
150 149
         $this->assertEquals('https', $collection->get('bar')->getRequirement('_scheme'), '->addPrefix() overrides existing requirements');
151 150
     }
152 151
 
153  
-    public function testAddCollectionOverridesDefaultsAndRequirements()
154  
-    {
155  
-        $imported = new RouteCollection();
156  
-        $imported->add('foo', $foo = new Route('/foo'));
157  
-        $imported->add('bar', $bar = new Route('/bar', array(), array('_scheme' => 'http')));
158  
-
159  
-        $collection = new RouteCollection();
160  
-        $collection->addCollection($imported, null, array(), array('_scheme' => 'https'));
161  
-
162  
-        $this->assertEquals('https', $collection->get('foo')->getRequirement('_scheme'), '->addCollection() overrides existing requirements');
163  
-        $this->assertEquals('https', $collection->get('bar')->getRequirement('_scheme'), '->addCollection() overrides existing requirements');
164  
-    }
165  
-
166 152
     public function testResource()
167 153
     {
168 154
         if (!class_exists('Symfony\Component\Config\Resource\FileResource')) {

0 notes on commit 3dbe725

Please sign in to comment.
Something went wrong with that request. Please try again.