|
@@ -19,6 +19,7 @@
|
|
|
namespace JMS\SerializerBundle\Tests\Metadata\Driver;
|
|
|
|
|
|
use Metadata\Driver\FileLocator;
|
|
|
+use JMS\SerializerBundle\Metadata\PropertyMetadata;
|
|
|
use JMS\SerializerBundle\Metadata\Driver\XmlDriver;
|
|
|
|
|
|
class XmlDriverTest extends BaseDriverTest
|
|
@@ -36,10 +37,38 @@ class XmlDriverTest extends BaseDriverTest
|
|
|
$ref->invoke($driver, new \ReflectionClass('stdClass'), __DIR__.'/xml/invalid.xml');
|
|
|
}
|
|
|
|
|
|
+ public function testBlogPostExcludeAllStrategy()
|
|
|
+ {
|
|
|
+ $m = $this->getDriver('exclude_all')->loadMetadataForClass(new \ReflectionClass('JMS\SerializerBundle\Tests\Fixtures\BlogPost'));
|
|
|
+
|
|
|
+ $this->assertArrayHasKey('title', $m->propertyMetadata);
|
|
|
+
|
|
|
+ $excluded = array('createdAt', 'published', 'comments', 'author');
|
|
|
+ foreach ($excluded as $key) {
|
|
|
+ $this->assertArrayNotHasKey($key, $m->propertyMetadata);
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ public function testBlogPostExcludeNoneStrategy()
|
|
|
+ {
|
|
|
+ $m = $this->getDriver('exclude_none')->loadMetadataForClass(new \ReflectionClass('JMS\SerializerBundle\Tests\Fixtures\BlogPost'));
|
|
|
+
|
|
|
+ $this->assertArrayNotHasKey('title', $m->propertyMetadata);
|
|
|
+
|
|
|
+ $excluded = array('createdAt', 'published', 'comments', 'author');
|
|
|
+ foreach ($excluded as $key) {
|
|
|
+ $this->assertArrayHasKey($key, $m->propertyMetadata);
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
protected function getDriver()
|
|
|
{
|
|
|
+ $append = '';
|
|
|
+ if (func_num_args() == 1) {
|
|
|
+ $append = '/'.func_get_arg(0);
|
|
|
+ }
|
|
|
return new XmlDriver(new FileLocator(array(
|
|
|
- 'JMS\SerializerBundle\Tests\Fixtures' => __DIR__.'/xml',
|
|
|
+ 'JMS\SerializerBundle\Tests\Fixtures' => __DIR__.'/xml'.$append,
|
|
|
)));
|
|
|
}
|
|
|
}
|