Thomas Rabaix 13 vuotta sitten
vanhempi
commit
b747c50b9c

+ 2 - 1
Tests/Admin/BaseAdminTest.php

@@ -166,7 +166,8 @@ class BaseAdminTest extends \PHPUnit_Framework_TestCase
 
     public function testGetBaseRouteNameWithChildAdmin()
     {
-        $pathInfo = new \Sonata\AdminBundle\Route\PathInfoBuilder();
+
+        $pathInfo = new \Sonata\AdminBundle\Route\PathInfoBuilder($this->getMock('Sonata\AdminBundle\Model\AuditManagerInterface'));
         $postAdmin = new PostAdmin('sonata.post.admin.post', 'Application\Sonata\NewsBundle\Entity\Post', 'SonataNewsBundle:PostAdmin');
         $postAdmin->setRouteBuilder($pathInfo);
         $postAdmin->initialize();

+ 36 - 0
Tests/Route/PathInfoBuilderTest.php

@@ -0,0 +1,36 @@
+<?php
+
+/*
+ * This file is part of the Sonata package.
+ *
+ * (c) Thomas Rabaix <thomas.rabaix@sonata-project.org>
+ *
+ * For the full copyright and license information, please view the LICENSE
+ * file that was distributed with this source code.
+ */
+
+namespace Sonata\AdminBundle\Tests\Route;
+
+use Sonata\AdminBundle\Route\PathInfoBuilder;
+use Sonata\AdminBundle\Route\RouteCollection;
+
+class PathInfoBuilderTest extends \PHPUnit_Framework_TestCase
+{
+
+    public function testBuild()
+    {
+        $audit = $this->getMock('Sonata\AdminBundle\Model\AuditManagerInterface');
+        $audit->expects($this->once())->method('hasReader')->will($this->returnValue(true));
+
+        $admin = $this->getMock('Sonata\AdminBundle\Admin\AdminInterface');
+        $admin->expects($this->once())->method('getChildren')->will($this->returnValue(array()));
+
+        $routeCollection = new RouteCollection('base.Code.Route', 'baseRouteName', 'baseRoutePattern', 'baseControllerName');
+
+        $pathBuilder = new PathInfoBuilder($audit);
+
+        $pathBuilder->build($admin, $routeCollection);
+
+        $this->assertCount(8,$routeCollection->getElements());
+    }
+}

+ 36 - 0
Tests/Route/QueryStringBuilderTest.php

@@ -0,0 +1,36 @@
+<?php
+
+/*
+ * This file is part of the Sonata package.
+ *
+ * (c) Thomas Rabaix <thomas.rabaix@sonata-project.org>
+ *
+ * For the full copyright and license information, please view the LICENSE
+ * file that was distributed with this source code.
+ */
+
+namespace Sonata\AdminBundle\Tests\Route;
+
+use Sonata\AdminBundle\Route\QueryStringBuilder;
+use Sonata\AdminBundle\Route\RouteCollection;
+
+class QueryStringBuilderTest extends \PHPUnit_Framework_TestCase
+{
+
+    public function testBuild()
+    {
+        $audit = $this->getMock('Sonata\AdminBundle\Model\AuditManagerInterface');
+        $audit->expects($this->once())->method('hasReader')->will($this->returnValue(true));
+
+        $admin = $this->getMock('Sonata\AdminBundle\Admin\AdminInterface');
+        $admin->expects($this->once())->method('getChildren')->will($this->returnValue(array()));
+
+        $routeCollection = new RouteCollection('base.Code.Route', 'baseRouteName', 'baseRoutePattern', 'baseControllerName');
+
+        $pathBuilder = new QueryStringBuilder($audit);
+
+        $pathBuilder->build($admin, $routeCollection);
+
+        $this->assertCount(8,$routeCollection->getElements());
+    }
+}