Przeglądaj źródła

deprecrate getMock calls

Jordi Sala 8 lat temu
rodzic
commit
88cf2bccc7

+ 5 - 4
Tests/Bridge/Exporter/AdminExporterTest.php

@@ -13,8 +13,9 @@ namespace Sonata\AdminBundle\Tests\Bridge\Exporter;
 
 use Exporter\Exporter;
 use Sonata\AdminBundle\Bridge\Exporter\AdminExporter;
+use Sonata\AdminBundle\Tests\Helpers\PHPUnit_Framework_TestCase;
 
-class AdminExporterTest extends \PHPUnit_Framework_TestCase
+class AdminExporterTest extends PHPUnit_Framework_TestCase
 {
     public function provideExportFormats()
     {
@@ -31,7 +32,7 @@ class AdminExporterTest extends \PHPUnit_Framework_TestCase
     {
         $writers = array();
         foreach ($globalFormats as $exportFormat) {
-            $writer = $this->getMock('Exporter\Writer\TypedWriterInterface');
+            $writer = $this->createMock('Exporter\Writer\TypedWriterInterface');
             $writer->expects($this->once())
                 ->method('getFormat')
                 ->will($this->returnValue($exportFormat));
@@ -39,7 +40,7 @@ class AdminExporterTest extends \PHPUnit_Framework_TestCase
         }
 
         $exporter = new Exporter($writers);
-        $admin = $this->getMock('Sonata\AdminBundle\Admin\AdminInterface');
+        $admin = $this->createMock('Sonata\AdminBundle\Admin\AdminInterface');
         $admin->expects($this->once())
             ->method('getExportFormats')
             ->will($this->returnValue($adminFormats));
@@ -49,7 +50,7 @@ class AdminExporterTest extends \PHPUnit_Framework_TestCase
 
     public function testGetExportFilename()
     {
-        $admin = $this->getMock('Sonata\AdminBundle\Admin\AdminInterface');
+        $admin = $this->createMock('Sonata\AdminBundle\Admin\AdminInterface');
         $admin->expects($this->once())
             ->method('getClass')
             ->will($this->returnValue('MyProject\AppBundle\Model\MyClass'));

+ 8 - 1
Tests/Controller/HelperControllerTest.php

@@ -89,7 +89,13 @@ class HelperControllerTest extends PHPUnit_Framework_TestCase
 
         $twig = new \Twig_Environment($this->createMock('\Twig_LoaderInterface'));
         $helper = new AdminHelper($pool);
-        $validator = $this->createMock('Symfony\Component\Validator\Validator\ValidatorInterface');
+
+        // NEXT_MAJOR: Remove this when dropping support for SF < 2.8
+        if (interface_exists('Symfony\Component\Validator\ValidatorInterface')) {
+            $validator = $this->createMock('Symfony\Component\Validator\ValidatorInterface');
+        } else {
+            $validator = $this->createMock('Symfony\Component\Validator\Validator\ValidatorInterface');
+        }
         $this->controller = new HelperController($twig, $pool, $helper, $validator);
 
         // php 5.3 BC
@@ -274,6 +280,7 @@ class HelperControllerTest extends PHPUnit_Framework_TestCase
 
         $loader = $this->createMock('\Twig_LoaderInterface');
 
+        // NEXT_MAJOR: Remove this check when dropping support for twig < 2
         if (method_exists('\Twig_LoaderInterface', 'getSourceContext')) {
             $loader->method('getSourceContext')->will($this->returnValue(new \Twig_Source('<foo />', 'foo')));
         } else {