Sfoglia il codice sorgente

Making test running against phpunit 4.*, and fix phpunit version for dev

l3l0 10 anni fa
parent
commit
aa0278835f

+ 1 - 1
.travis.yml

@@ -14,7 +14,7 @@ before_script:
     - composer self-update
     - composer install --dev
 
-script: phpunit --coverage-clover clover
+script: vendor/bin/phpunit --coverage-clover clover
 
 after_success:
     - wget https://scrutinizer-ci.com/ocular.phar

+ 2 - 1
composer.json

@@ -32,7 +32,8 @@
         "symfony/translation": "~2.0",
         "symfony/validator": "~2.0",
         "symfony/form": "~2.1",
-        "symfony/filesystem": "2.*"
+        "symfony/filesystem": "2.*",
+        "phpunit/phpunit": "~4.0"
     },
     "autoload": {
         "psr-0": {

File diff suppressed because it is too large
+ 1021 - 172
composer.lock


+ 26 - 25
phpunit.xml.dist

@@ -1,25 +1,26 @@
-<?xml version="1.0" encoding="UTF-8"?>
-
-<phpunit backupGlobals="false"
-         backupStaticAttributes="false"
-         convertErrorsToExceptions="true"
-         convertNoticesToExceptions="true"
-         convertWarningsToExceptions="true"
-         processIsolation="false"
-         stopOnFailure="false"
-         syntaxCheck="false"
-         bootstrap="tests/bootstrap.php"
->
-         
-    <testsuites>
-        <testsuite name="JMS Serializer Test Suite">
-            <directory>./tests</directory>
-        </testsuite>
-    </testsuites>
-    
-    <groups>
-        <exclude>
-            <group>performance</group>
-        </exclude>
-    </groups>
-</phpunit>
+<?xml version="1.0" encoding="UTF-8"?>
+
+<phpunit
+    backupGlobals               = "false"
+    backupStaticAttributes      = "false"
+    colors                      = "true"
+    convertErrorsToExceptions   = "true"
+    convertNoticesToExceptions  = "true"
+    convertWarningsToExceptions = "true"
+    processIsolation            = "false"
+    stopOnFailure               = "false"
+    syntaxCheck                 = "false"
+    bootstrap                   = "tests/bootstrap.php"
+>
+    <testsuites>
+        <testsuite name="JMS Serializer Test Suite">
+            <directory>./tests</directory>
+        </testsuite>
+    </testsuites>
+
+    <groups>
+        <exclude>
+            <group>performance</group>
+        </exclude>
+    </groups>
+</phpunit>

+ 9 - 6
tests/JMS/Serializer/Tests/Serializer/Doctrine/IntegrationTest.php

@@ -58,14 +58,17 @@ class IntegrationTest extends \PHPUnit_Framework_TestCase
 
     protected function setUp()
     {
-        $this->registry = new SimpleManagerRegistry(
-            function($id) {
+        $connection    = $this->createConnection();
+        $entityManager = $this->createEntityManager($connection);
+
+        $this->registry = $registry = new SimpleManagerRegistry(
+            function($id) use($connection, $entityManager) {
                 switch ($id) {
                     case 'default_connection':
-                        return $this->createConnection();
+                        return $connection;
 
                     case 'default_manager':
-                        return $this->createEntityManager($this->registry->getConnection());
+                        return $entityManager;
 
                     default:
                         throw new \RuntimeException(sprintf('Unknown service id "%s".', $id));
@@ -75,10 +78,10 @@ class IntegrationTest extends \PHPUnit_Framework_TestCase
 
         $this->serializer = SerializerBuilder::create()
             ->setMetadataDriverFactory(new CallbackDriverFactory(
-                function(array $metadataDirs, Reader $annotationReader) {
+                function(array $metadataDirs, Reader $annotationReader) use($registry) {
                     $defaultFactory = new DefaultDriverFactory();
 
-                    return new DoctrineTypeDriver($defaultFactory->createDriver($metadataDirs, $annotationReader), $this->registry);
+                    return new DoctrineTypeDriver($defaultFactory->createDriver($metadataDirs, $annotationReader), $registry);
                 }
             ))
             ->build()

+ 15 - 16
tests/JMS/Serializer/Tests/Serializer/GraphNavigatorTest.php

@@ -22,6 +22,7 @@ use JMS\Serializer\Construction\UnserializeObjectConstructor;
 use JMS\Serializer\Handler\HandlerRegistry;
 use JMS\Serializer\EventDispatcher\EventDispatcher;
 use Doctrine\Common\Annotations\AnnotationReader;
+use JMS\Serializer\Handler\SubscribingHandlerInterface;
 use JMS\Serializer\Metadata\Driver\AnnotationDriver;
 use JMS\Serializer\GraphNavigator;
 use Metadata\MetadataFactory;
@@ -131,22 +132,7 @@ class GraphNavigatorTest extends \PHPUnit_Framework_TestCase
             $event->setType($type['name'], $type['params']);
         });
 
-        $subscribingHandlerClass = $this->getMockClass('JMS\Serializer\Handler\SubscribingHandlerInterface', array('getSubscribingMethods', 'serialize'));
-        $subscribingHandlerClass::staticExpects($this->once())
-            ->method('getSubscribingMethods')
-            ->will($this->returnValue(array(array(
-                'type' => $typeName,
-                'format' => 'foo',
-                'direction' => GraphNavigator::DIRECTION_SERIALIZATION,
-                'method' => 'serialize'
-            ))));
-
-        $subscribingHandler = new $subscribingHandlerClass();
-        $subscribingHandler->expects($this->once())
-            ->method('serialize')
-            ->with($this->equalTo($this->context), $this->equalTo($object));
-
-        $this->handlerRegistry->registerSubscribingHandler($subscribingHandler);
+        $this->handlerRegistry->registerSubscribingHandler(new TestSubscribingHandler());
 
         $this->context->expects($this->any())
             ->method('getDirection')
@@ -176,3 +162,16 @@ class SerializableClass
 {
     public $foo = 'bar';
 }
+
+class TestSubscribingHandler implements SubscribingHandlerInterface
+{
+    public static function getSubscribingMethods()
+    {
+        return array(array(
+            'type' => 'JsonSerializable',
+            'format' => 'foo',
+            'direction' => GraphNavigator::DIRECTION_SERIALIZATION,
+            'method' => 'serialize'
+        ));
+    }
+}