Browse Source

Simplify some tests

Konstantin.Myakshin 9 năm trước cách đây
mục cha
commit
de2ce746ff

+ 3 - 10
Tests/Controller/CRUDControllerTest.php

@@ -24,6 +24,7 @@ use Symfony\Bridge\Twig\Extension\FormExtension;
 use Symfony\Component\DependencyInjection\ContainerInterface;
 use Symfony\Component\Form\Extension\Csrf\CsrfProvider\CsrfProviderInterface;
 use Symfony\Component\HttpFoundation\Request;
+use Symfony\Component\HttpFoundation\RequestStack;
 use Symfony\Component\HttpFoundation\Response;
 use Symfony\Component\HttpFoundation\Session\Session;
 use Symfony\Component\HttpFoundation\Session\Storage\MockArraySessionStorage;
@@ -175,8 +176,6 @@ class CRUDControllerTest extends \PHPUnit_Framework_TestCase
                     case 'form':
                         return $formExtension;
                 }
-
-                return;
             }));
 
         $exporter = $this->getMock('Sonata\AdminBundle\Export\Exporter');
@@ -251,8 +250,8 @@ class CRUDControllerTest extends \PHPUnit_Framework_TestCase
         $logger       = $this->logger; // php 5.3 BC
 
         $requestStack = null;
-        if ((Kernel::MAJOR_VERSION == 2 && Kernel::MINOR_VERSION > 3) || Kernel::MAJOR_VERSION >= 3) {
-            $requestStack = new \Symfony\Component\HttpFoundation\RequestStack();
+        if (class_exists('Symfony\Component\HttpFoundation\RequestStack')) {
+            $requestStack = new RequestStack();
             $requestStack->push($request);
         }
 
@@ -305,8 +304,6 @@ class CRUDControllerTest extends \PHPUnit_Framework_TestCase
                     case 'kernel':
                         return $kernel;
                 }
-
-                return;
             }));
 
         // php 5.3
@@ -345,8 +342,6 @@ class CRUDControllerTest extends \PHPUnit_Framework_TestCase
                     case 'security.role_hierarchy.roles':
                        return array('ROLE_SUPER_ADMIN' => array('ROLE_USER', 'ROLE_SONATA_ADMIN', 'ROLE_ADMIN'));
                 }
-
-                return;
             }));
 
         $this->admin->expects($this->any())
@@ -382,8 +377,6 @@ class CRUDControllerTest extends \PHPUnit_Framework_TestCase
                     case 'batch_confirmation':
                         return 'SonataAdminBundle:CRUD:batch_confirmation.html.twig';
                 }
-
-                return;
             }));
 
         $this->admin->expects($this->any())

+ 5 - 5
Tests/Controller/CoreControllerTest.php

@@ -14,7 +14,7 @@ namespace Sonata\AdminBundle\Tests\Controller;
 use Sonata\AdminBundle\Admin\Pool;
 use Sonata\AdminBundle\Controller\CoreController;
 use Symfony\Component\HttpFoundation\Request;
-use Symfony\Component\HttpKernel\Kernel;
+use Symfony\Component\HttpFoundation\RequestStack;
 
 class CoreControllerTest extends \PHPUnit_Framework_TestCase
 {
@@ -31,8 +31,8 @@ class CoreControllerTest extends \PHPUnit_Framework_TestCase
         $request = new Request();
 
         $requestStack = null;
-        if (Kernel::MINOR_VERSION > 3) {
-            $requestStack = new \Symfony\Component\HttpFoundation\RequestStack();
+        if (class_exists('Symfony\Component\HttpFoundation\RequestStack')) {
+            $requestStack = new RequestStack();
             $requestStack->push($request);
         }
 
@@ -81,8 +81,8 @@ class CoreControllerTest extends \PHPUnit_Framework_TestCase
         $request->headers->set('X-Requested-With', 'XMLHttpRequest');
 
         $requestStack = null;
-        if (Kernel::MINOR_VERSION > 3) {
-            $requestStack = new \Symfony\Component\HttpFoundation\RequestStack();
+        if (class_exists('Symfony\Component\HttpFoundation\RequestStack')) {
+            $requestStack = new RequestStack();
             $requestStack->push($request);
         }
 

+ 0 - 10
Tests/Controller/HelperControllerTest.php

@@ -99,11 +99,7 @@ class HelperControllerTest extends \PHPUnit_Framework_TestCase
                     case 'foo.admin':
                         return $admin;
                 }
-
-                return;
             }));
-
-        return;
     }
 
     /**
@@ -430,8 +426,6 @@ class HelperControllerTest extends \PHPUnit_Framework_TestCase
 
         $validator = $this->getMock($validatorInterface);
 
-        $dispatcher = $this->getMock('Symfony\Component\EventDispatcher\EventDispatcherInterface');
-
         $helper = $this->getMock('Sonata\AdminBundle\Admin\AdminHelper', array('getChildFormView'), array($pool));
         $helper->expects($this->once())->method('getChildFormView')->will($this->returnValue($mockView));
 
@@ -624,8 +618,6 @@ class HelperControllerTest extends \PHPUnit_Framework_TestCase
             ->with('CREATE')
             ->will($this->returnValue(true));
 
-        $entity = new Foo();
-
         $fieldDescription = $this->getMock('Sonata\AdminBundle\Admin\FieldDescriptionInterface');
 
         $fieldDescription->expects($this->once())
@@ -700,8 +692,6 @@ class HelperControllerTest extends \PHPUnit_Framework_TestCase
                     case 'to_string_callback':
                         return;
                 }
-
-                return;
             }));
 
         $request = new Request(array(