Johannes M. Schmitt 13 роки тому
батько
коміт
6bf2f09244

+ 44 - 0
Annotation/Groups.php

@@ -0,0 +1,44 @@
+<?php
+
+/*
+ * Copyright 2011 Johannes M. Schmitt <schmittjoh@gmail.com>
+ *
+ * Licensed under the Apache License, Group 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+namespace JMS\SerializerBundle\Annotation;
+
+use JMS\SerializerBundle\Exception\InvalidArgumentException;
+
+/**
+ * @Annotation
+ * @Target("PROPERTY")
+ */
+final class Groups
+{
+    /** @var array<string> @Required */
+    public $groups;
+
+    public function __construct()
+    {
+        if (0 === func_num_args()) {
+            return;
+        }
+        $values = func_get_arg(0);
+
+        if (!isset($values['value'])) {
+            throw new InvalidArgumentException('The "groups" attribute must be set.');
+        }
+        $this->groups = (array) $values['value'];
+    }
+}

+ 2 - 3
Metadata/Driver/AnnotationDriver.php

@@ -20,8 +20,6 @@ namespace JMS\SerializerBundle\Metadata\Driver;
 
 use JMS\SerializerBundle\Annotation\AccessorOrder;
 
-use JMS\SerializerBundle\Annotation\Groups;
-
 use JMS\SerializerBundle\Annotation\Accessor;
 
 use JMS\SerializerBundle\Annotation\AccessType;
@@ -38,6 +36,7 @@ use Metadata\MethodMetadata;
 use Doctrine\Common\Annotations\Reader;
 use JMS\SerializerBundle\Annotation\Type;
 use JMS\SerializerBundle\Annotation\Exclude;
+use JMS\SerializerBundle\Annotation\Groups;
 use JMS\SerializerBundle\Annotation\Expose;
 use JMS\SerializerBundle\Annotation\SerializedName;
 use JMS\SerializerBundle\Annotation\Until;
@@ -121,7 +120,7 @@ class AnnotationDriver implements DriverInterface
                     } else if ($annot instanceof Accessor) {
                         $accessor = array($annot->getter, $annot->setter);
                     } else if ($annot instanceof Groups) {
-                        $propertyMetadata->setGroups($annot->names);
+                        $propertyMetadata->groups = $annot->groups;
                     } else if ($annot instanceof Inline) {
                         $propertyMetadata->inline = true;
                     } else if ($annot instanceof ReadOnly) {

+ 4 - 0
Metadata/Driver/XmlDriver.php

@@ -98,6 +98,10 @@ class XmlDriver extends AbstractFileDriver
                         $pMetadata->type = (string) $pElem->type;
                     }
 
+                    if (null !== $groups = $pElem->attributes()->groups) {
+                        $pMetadata->groups =  preg_split('/\s*,\s*/', (string) $groups);
+                    } 
+
                     if (isset($pElem->{'xml-list'})) {
                         $pMetadata->xmlCollection = true;
 

+ 3 - 0
Metadata/Driver/YamlDriver.php

@@ -86,6 +86,9 @@ class YamlDriver extends AbstractFileDriver
                     if (isset($pConfig['type'])) {
                         $pMetadata->type = (string) $pConfig['type'];
                     }
+                    if (isset($pConfig['groups'])) {
+                        $pMetadata->groups = $pConfig['groups'];
+                    } 
 
                     if (isset($pConfig['xml_list'])) {
                         $pMetadata->xmlCollection = true;

+ 3 - 0
Metadata/PropertyMetadata.php

@@ -27,6 +27,7 @@ class PropertyMetadata extends BasePropertyMetadata
 
     public $sinceVersion;
     public $untilVersion;
+    public $groups;
     public $serializedName;
     public $type;
     public $xmlCollection = false;
@@ -73,6 +74,7 @@ class PropertyMetadata extends BasePropertyMetadata
         return serialize(array(
             $this->sinceVersion,
             $this->untilVersion,
+            $this->groups,
             $this->serializedName,
             $this->type,
             $this->xmlCollection,
@@ -94,6 +96,7 @@ class PropertyMetadata extends BasePropertyMetadata
         list(
             $this->sinceVersion,
             $this->untilVersion,
+            $this->groups,
             $this->serializedName,
             $this->type,
             $this->xmlCollection,

+ 96 - 4
Resources/doc/cookbook/exclusion_strategies.rst

@@ -1,7 +1,17 @@
-Defining which properties should be serialized
-~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+Exclusion Strategies
+====================
 
-The default exclusion policy is to exclude nothing, that is all properties of the
+Introduction
+------------
+The serializer supports different exclusion strategies. Each strategy allows
+you to define which properties of your objects should be serialized.
+
+General Exclusion Strategies
+----------------------------
+If you would like to always expose, or exclude certain properties. Then, you can
+do this with the annotations ``@ExclusionPolicy``, ``@Exclude``, and ``@Expose``.
+
+The default exclusion policy is to exclude nothing. That is, all properties of the
 object will be serialized. If you only want to expose a few of the properties,
 then it is easier to change the exclusion policy, and only mark these few properties:
 
@@ -27,4 +37,86 @@ then it is easier to change the exclusion policy, and only mark these few proper
          * @Expose
          */
         private $name;
-    }
+    }
+
+.. note ::
+
+    A property that is excluded by ``@Exclude`` cannot be exposed anymore by any
+    of the following strategies, but is always hidden.
+
+Versioning Objects
+------------------
+JMSSerializerBundle comes by default with a very neat feature which allows
+you to add versioning support to your objects, e.g. if you want to
+expose them via an API that is consumed by a third-party:
+
+.. code-block :: php
+
+    <?php
+
+    class VersionedObject
+    {
+        /**
+         * @Until("1.0.x")
+         */
+        private $name;
+
+        /**
+         * @Since("1.1")
+         * @SerializedName("name")
+         */
+        private $name2;
+    }
+    
+.. note ::
+
+    ``@Until``, and ``@Since`` both accept a standardized PHP version number.
+
+If you have annotated your objects like above, you can serializing different
+versions like this:
+
+.. code-block :: php
+
+    <?php
+
+    $serializer->setVersion('1.0');
+    $serializer->serialize(new VersionObject(), 'json');
+
+
+Creating Different Views of Your Objects
+----------------------------------------
+Another default exclusion strategy is to create different views of your objects.
+Let's say you would like to serialize your object in a different view depending
+whether it is displayed in a list view or in a details view.
+
+You can achieve that by using the ``@Groups`` annotation on your properties.
+
+.. code-block :: php
+
+    <?php 
+    
+    use JMS\SerializerBundle\Annotation\Groups;
+    
+    class BlogPost
+    {
+        /** @Groups({"list", "details"}) */
+        private $id;
+        
+        /** @Groups({"list", "details"}) */
+        private $title;
+        
+        /** @Groups({"list"}) */
+        private $nbComments;
+        
+        /** @Groups({"details"}) */
+        private $comments;
+    }
+    
+You can then tell the serializer which groups to serialize in your controller:
+
+.. code-block :: php
+
+    <?php
+    
+    $serializer->setGroups(array('list'));
+    $serializer->serialize(new BlogPost(), 'json');

+ 2 - 2
Resources/doc/cookbook/metadata_for_third_party.rst

@@ -1,5 +1,5 @@
-Overriding Metadata
-~~~~~~~~~~~~~~~~~~~
+Overriding Metadata Provided by Third-Parties
+~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
 
 Sometimes you want to serialize objects which are shipped by a third-party bundle. 
 Such a third-party bundle might not ship with metadata that suits your needs, or 

+ 0 - 37
Resources/doc/cookbook/versioning_objects.rst

@@ -1,37 +0,0 @@
-Versioning Objects
-------------------
-JMSSerializerBundle comes by default with a very neat feature which allows
-you to add versioning support to your objects, e.g. if you want to
-expose them via an API that is consumed by a third-party:
-
-.. code-block :: php
-
-    <?php
-
-    class VersionedObject
-    {
-        /**
-         * @Until("1.0.x")
-         */
-        private $name;
-
-        /**
-         * @Since("1.1")
-         * @SerializedName("name")
-         */
-        private $name2;
-    }
-    
-.. note ::
-
-    ``@Until``, and ``@Since`` both accept a standardized PHP version number.
-
-If you have annotated your objects like above, you can serializing different
-versions like this:
-
-.. code-block :: php
-
-    <?php
-
-    $serializer->setVersion('1.0');
-    $serializer->serialize(new VersionObject(), 'json');

+ 1 - 0
Resources/doc/index.rst

@@ -35,6 +35,7 @@ Documentation
 - Recipies
     * :doc:`Custom Handlers </cookbook/custom_handlers>`
     * :doc:`/cookbook/exclusion_strategies`
+    * :doc:`/cookbook/metadata_for_third_party`
 - Reference
     * :doc:`Annotations </reference/annotations>`
     * :doc:`XML Reference </reference/xml_reference>`

+ 2 - 2
Resources/doc/installation.rst

@@ -14,13 +14,13 @@ To install JMSSerializerBundle with Composer just add the following to your
         // ...
         require: {
             // ...
-            "jms/serializer-bundle": "master-dev"
+            "jms/serializer-bundle": "dev-master"
         }
     }
     
 .. note ::
 
-    Please replace `master-dev` in the snippet above with the latest stable
+    Please replace `dev-master` in the snippet above with the latest stable
     branch, for example ``1.0.*``.
     
 Then, you can install the new dependencies by running Composer's ``update``

+ 6 - 0
Resources/doc/reference/annotations.rst

@@ -46,6 +46,12 @@ property was available. If a later version is serialized, then this property is
 excluded automatically. The version must be in a format that is understood by
 PHP's ``version_compare`` function.
 
+@Groups
+~~~~~~~
+This annotation can be defined on a property to specifiy to if the property 
+should be serialized when only serializing specific groups (see 
+:doc:`../cookbook/exclusion_strategies`).
+
 @AccessType
 ~~~~~~~~~~~
 This annotation can be defined on a property, or a class to specify in which way

+ 1 - 0
Resources/doc/reference/xml_reference.rst

@@ -21,6 +21,7 @@ XML Reference
                       accessor-setter="setSomeProperty"
                       inline="true"
                       read-only="true"
+                      groups="foo,bar"
             >
                 <!-- You can also specify the type as element which is necessary if
                      your type contains "<" or ">" characters. -->

+ 1 - 0
Resources/doc/reference/yml_reference.rst

@@ -19,6 +19,7 @@ YAML Reference
                 serialized_name: foo
                 since_version: 1.0
                 until_version: 1.1
+                groups: [foo, bar]
                 xml_attribute: true
                 inline: true
                 read_only: true

+ 62 - 0
Serializer/Exclusion/GroupsExclusionStrategy.php

@@ -0,0 +1,62 @@
+<?php
+
+/*
+ * Copyright 2011 Johannes M. Schmitt <schmittjoh@gmail.com>
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+namespace JMS\SerializerBundle\Serializer\Exclusion;
+
+use JMS\SerializerBundle\Metadata\ClassMetadata;
+use JMS\SerializerBundle\Metadata\PropertyMetadata;
+use JMS\SerializerBundle\Exception\RuntimeException;
+
+class GroupsExclusionStrategy implements ExclusionStrategyInterface
+{
+    private $groups = array();
+
+    public function __construct(array $groups)
+    {
+        if (empty($groups)) {
+            throw new RuntimeException('Empty group array may not be configured for GroupsExclusionStrategy');
+        }
+
+        foreach ($groups as $group) {
+            $this->groups[$group] = true;
+        }
+    }
+
+    public function shouldSkipClass(ClassMetadata $metadata)
+    {
+        return false;
+    }
+
+    /**
+     * {@inheritDoc}
+     */
+    public function shouldSkipProperty(PropertyMetadata $property)
+    {
+        if (!$property->groups) {
+            return true;
+        }
+
+        foreach ($property->groups as $group) {
+            if (isset($this->groups[$group])) {
+                return false;
+            }
+        }
+
+        return true;
+    }
+}

+ 12 - 0
Serializer/Serializer.php

@@ -22,6 +22,7 @@ use JMS\SerializerBundle\Exception\UnsupportedFormatException;
 use Metadata\MetadataFactoryInterface;
 use JMS\SerializerBundle\Exception\InvalidArgumentException;
 use JMS\SerializerBundle\Serializer\Exclusion\VersionExclusionStrategy;
+use JMS\SerializerBundle\Serializer\Exclusion\GroupsExclusionStrategy;
 use JMS\SerializerBundle\Serializer\Exclusion\ExclusionStrategyInterface;
 
 class Serializer implements SerializerInterface
@@ -53,6 +54,17 @@ class Serializer implements SerializerInterface
 
         $this->exclusionStrategy = new VersionExclusionStrategy($version);
     }
+    
+    public function setGroups($groups)
+    {
+        if (!$groups) {
+            $this->exclusionStrategy = null;
+
+            return;
+        }
+
+        $this->exclusionStrategy = new GroupsExclusionStrategy((array) $groups);
+    }
 
     public function serialize($data, $format)
     {

+ 5 - 0
Tests/Fixtures/BlogPost.php

@@ -23,6 +23,7 @@ use JMS\SerializerBundle\Annotation\SerializedName;
 use JMS\SerializerBundle\Annotation\XmlRoot;
 use JMS\SerializerBundle\Annotation\XmlAttribute;
 use JMS\SerializerBundle\Annotation\XmlList;
+use JMS\SerializerBundle\Annotation\Groups;
 use Doctrine\Common\Collections\ArrayCollection;
 
 /** @XmlRoot("blog-post") */
@@ -30,6 +31,7 @@ class BlogPost
 {
     /**
      * @Type("string")
+     * @Groups({"comments","post"})
      */
     private $title;
 
@@ -43,17 +45,20 @@ class BlogPost
      * @Type("boolean")
      * @SerializedName("is_published")
      * @XmlAttribute
+     * @Groups({"post"})
      */
     private $published;
 
     /**
      * @Type("ArrayCollection<JMS\SerializerBundle\Tests\Fixtures\Comment>")
      * @XmlList(inline=true, entry="comment")
+     * @Groups({"comments"})
      */
     private $comments;
 
     /**
      * @Type("JMS\SerializerBundle\Tests\Fixtures\Author")
+     * @Groups({"post"})
      */
     private $author;
 

+ 57 - 0
Tests/Fixtures/GroupsObject.php

@@ -0,0 +1,57 @@
+<?php
+
+/*
+ * Copyright 2011 Johannes M. Schmitt <schmittjoh@gmail.com>
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+namespace JMS\SerializerBundle\Tests\Fixtures;
+
+use JMS\SerializerBundle\Annotation\Groups;
+use JMS\SerializerBundle\Annotation\Type;
+
+/** blablub */
+class GroupsObject
+{
+    /**
+     * @Groups({"foo"})
+     * @Type("string")
+     */
+    private $foo;
+
+    /**
+     * @Groups({"foo","bar"})
+     * @Type("string")
+     */
+    private $foobar;
+
+    /**
+     * @Groups({"bar"})
+     * @Type("string")
+     */
+    private $bar;
+
+     /**
+     * @Type("string")
+     */
+    private $none;
+
+    public function __construct()
+    {
+        $this->foo  = "foo";
+        $this->bar = "bar";
+        $this->foobar  = "foobar";
+        $this->none = "none";
+    }
+}

+ 4 - 0
Tests/Metadata/Driver/BaseDriverTest.php

@@ -32,6 +32,7 @@ abstract class BaseDriverTest extends \PHPUnit_Framework_TestCase
 
         $p = new PropertyMetadata($m->name, 'title');
         $p->type = 'string';
+        $p->groups = array("comments","post");
         $this->assertEquals($p, $m->propertyMetadata['title']);
 
         $p = new PropertyMetadata($m->name, 'createdAt');
@@ -43,6 +44,7 @@ abstract class BaseDriverTest extends \PHPUnit_Framework_TestCase
         $p->type = 'boolean';
         $p->serializedName = 'is_published';
         $p->xmlAttribute = true;
+        $p->groups = array("post");
         $this->assertEquals($p, $m->propertyMetadata['published']);
 
         $p = new PropertyMetadata($m->name, 'comments');
@@ -50,10 +52,12 @@ abstract class BaseDriverTest extends \PHPUnit_Framework_TestCase
         $p->xmlCollection = true;
         $p->xmlCollectionInline = true;
         $p->xmlEntryName = 'comment';
+        $p->groups = array("comments");
         $this->assertEquals($p, $m->propertyMetadata['comments']);
 
         $p = new PropertyMetadata($m->name, 'author');
         $p->type = 'JMS\SerializerBundle\Tests\Fixtures\Author';
+        $p->groups = array("post");
         $this->assertEquals($p, $m->propertyMetadata['author']);
         
         $m = $this->getDriver()->loadMetadataForClass(new \ReflectionClass('JMS\SerializerBundle\Tests\Fixtures\Price'));

+ 6 - 0
Tests/Metadata/Driver/php/BlogPost.php

@@ -8,6 +8,7 @@ $metadata->xmlRootName = 'blog-post';
 
 $pMetadata = new PropertyMetadata('JMS\SerializerBundle\Tests\Fixtures\BlogPost', 'title');
 $pMetadata->type = 'string';
+$pMetadata->groups = array('comments','post');
 $metadata->addPropertyMetadata($pMetadata);
 
 $pMetadata = new PropertyMetadata('JMS\SerializerBundle\Tests\Fixtures\BlogPost', 'createdAt');
@@ -18,6 +19,7 @@ $metadata->addPropertyMetadata($pMetadata);
 $pMetadata = new PropertyMetadata('JMS\SerializerBundle\Tests\Fixtures\BlogPost', 'published');
 $pMetadata->type = 'boolean';
 $pMetadata->serializedName = 'is_published';
+$pMetadata->groups = array('post');
 $pMetadata->xmlAttribute = true;
 $metadata->addPropertyMetadata($pMetadata);
 
@@ -26,10 +28,14 @@ $pMetadata->type = 'ArrayCollection<JMS\SerializerBundle\Tests\Fixtures\Comment>
 $pMetadata->xmlCollection = true;
 $pMetadata->xmlCollectionInline = true;
 $pMetadata->xmlEntryName = 'comment';
+$pMetadata->groups = array('comments');
+
 $metadata->addPropertyMetadata($pMetadata);
 
 $pMetadata = new PropertyMetadata('JMS\SerializerBundle\Tests\Fixtures\BlogPost', 'author');
 $pMetadata->type = 'JMS\SerializerBundle\Tests\Fixtures\Author';
+$pMetadata->groups = array('post');
+
 $metadata->addPropertyMetadata($pMetadata);
 
 return $metadata;

+ 5 - 5
Tests/Metadata/Driver/xml/BlogPost.xml

@@ -1,13 +1,13 @@
 <?xml version="1.0" encoding="UTF-8"?>
 <serializer>
     <class name="JMS\SerializerBundle\Tests\Fixtures\BlogPost" xml-root-name="blog-post">
-        <property name="title" type="string" />
-        <property name="createdAt" xml-attribute="true" type="DateTime" />
-        <property name="published" type="boolean" serialized-name="is_published" xml-attribute="true" />
-        <property name="comments">
+        <property name="title" type="string" groups="comments,post"/>
+        <property name="createdAt" xml-attribute="true" type="DateTime"/>
+        <property name="published" type="boolean" serialized-name="is_published" xml-attribute="true" groups="post" />
+        <property name="comments" groups="comments">
             <type><![CDATA[ArrayCollection<JMS\SerializerBundle\Tests\Fixtures\Comment>]]></type>
             <xml-list inline="true" entry-name="comment" />
         </property>
-        <property name="author" type="JMS\SerializerBundle\Tests\Fixtures\Author" />
+        <property name="author" groups="post" type="JMS\SerializerBundle\Tests\Fixtures\Author" />
     </class>
 </serializer>

+ 5 - 1
Tests/Metadata/Driver/yml/BlogPost.yml

@@ -3,6 +3,7 @@ JMS\SerializerBundle\Tests\Fixtures\BlogPost:
     properties:
         title:
             type: string
+            groups: [comments, post]
         createdAt:
             type: DateTime
             xml_attribute: true
@@ -10,10 +11,13 @@ JMS\SerializerBundle\Tests\Fixtures\BlogPost:
             type: boolean
             serialized_name: is_published
             xml_attribute: true
+            groups: [post]
         comments:
             type: ArrayCollection<JMS\SerializerBundle\Tests\Fixtures\Comment>
+            groups: [comments]
             xml_list:
                 inline: true
                 entry_name: comment
         author:
-            type: JMS\SerializerBundle\Tests\Fixtures\Author
+            type: JMS\SerializerBundle\Tests\Fixtures\Author
+            groups: [post]

+ 22 - 0
Tests/Serializer/BaseSerializationTest.php

@@ -57,6 +57,7 @@ use JMS\SerializerBundle\Tests\Fixtures\BlogPost;
 use JMS\SerializerBundle\Tests\Fixtures\ObjectWithLifecycleCallbacks;
 use JMS\SerializerBundle\Tests\Fixtures\CircularReferenceParent;
 use JMS\SerializerBundle\Tests\Fixtures\InlineParent;
+use JMS\SerializerBundle\Tests\Fixtures\GroupsObject;
 use JMS\SerializerBundle\Serializer\XmlSerializationVisitor;
 use Doctrine\Common\Annotations\AnnotationReader;
 use JMS\SerializerBundle\Metadata\Driver\AnnotationDriver;
@@ -416,6 +417,27 @@ abstract class BaseSerializationTest extends \PHPUnit_Framework_TestCase
         $this->assertEquals($this->getContent('accessor_order_child'), $this->serialize(new AccessorOrderChild()));
         $this->assertEquals($this->getContent('accessor_order_parent'), $this->serialize(new AccessorOrderParent()));
     }
+    
+    public function testGroups()
+    {
+        $serializer =  $this->getSerializer();
+
+        $groupsObject = new GroupsObject();
+        
+        $this->assertEquals($this->getContent('groups_all'), $serializer->serialize($groupsObject, $this->getFormat()));
+
+        $serializer->setGroups(array("foo"));
+        $this->assertEquals($this->getContent('groups_foo'), $serializer->serialize($groupsObject, $this->getFormat()));
+        
+        $serializer->setGroups(array("foo", "bar"));
+        $this->assertEquals($this->getContent('groups_foobar'), $serializer->serialize($groupsObject, $this->getFormat()));
+         
+        $serializer->setGroups(null);
+        $this->assertEquals($this->getContent('groups_all'), $serializer->serialize($groupsObject, $this->getFormat()));
+
+        $serializer->setGroups(array());
+        $this->assertEquals($this->getContent('groups_all'), $serializer->serialize($groupsObject, $this->getFormat()));
+    }
 
     abstract protected function getContent($key);
     abstract protected function getFormat();

+ 3 - 0
Tests/Serializer/JsonSerializationTest.php

@@ -61,6 +61,9 @@ class JsonSerializationTest extends BaseSerializationTest
             $outputs['accessor_order_child'] = '{"c":"c","d":"d","a":"a","b":"b"}';
             $outputs['accessor_order_parent'] = '{"a":"a","b":"b"}';
             $outputs['inline'] = '{"c":"c","a":"a","b":"b","d":"d"}';
+            $outputs['groups_all'] = '{"foo":"foo","foobar":"foobar","bar":"bar","none":"none"}';
+            $outputs['groups_foo'] = '{"foo":"foo","foobar":"foobar"}';
+            $outputs['groups_foobar'] = '{"foo":"foo","foobar":"foobar","bar":"bar"}';
         }
 
         if (!isset($outputs[$key])) {

+ 7 - 0
Tests/Serializer/xml/groups_all.xml

@@ -0,0 +1,7 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<result>
+  <foo><![CDATA[foo]]></foo>
+  <foobar><![CDATA[foobar]]></foobar>
+  <bar><![CDATA[bar]]></bar>
+  <none><![CDATA[none]]></none>
+</result>

+ 5 - 0
Tests/Serializer/xml/groups_foo.xml

@@ -0,0 +1,5 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<result>
+  <foo><![CDATA[foo]]></foo>
+  <foobar><![CDATA[foobar]]></foobar>
+</result>

+ 6 - 0
Tests/Serializer/xml/groups_foobar.xml

@@ -0,0 +1,6 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<result>
+  <foo><![CDATA[foo]]></foo>
+  <foobar><![CDATA[foobar]]></foobar>
+  <bar><![CDATA[bar]]></bar>
+</result>

+ 4 - 0
Tests/Serializer/yml/groups_all.yml

@@ -0,0 +1,4 @@
+foo: foo
+foobar: foobar
+bar: bar
+none: none

+ 2 - 0
Tests/Serializer/yml/groups_foo.yml

@@ -0,0 +1,2 @@
+foo: foo
+foobar: foobar

+ 3 - 0
Tests/Serializer/yml/groups_foobar.yml

@@ -0,0 +1,3 @@
+foo: foo
+foobar: foobar
+bar: bar

+ 1 - 1
phpunit.xml.dist

@@ -9,7 +9,7 @@
          processIsolation="false"
          stopOnFailure="false"
          syntaxCheck="false"
-         bootstrap="./../../../../app/bootstrap.php.cache"
+         bootstrap="./../../../../app/autoload.php"
 >
          
     <testsuites>