Merge branch '5.2' into 5.x
* 5.2: [PropertyInfo][Serializer] Fixed extracting ignored properties [travis] fix checking if the current branch has same major as the next release
This commit is contained in:
commit
c6de408c60
@ -233,7 +233,7 @@ install:
|
|||||||
|
|
||||||
- |
|
- |
|
||||||
# Legacy tests are skipped when deps=high and when the current branch version has not the same major version number as the next one
|
# Legacy tests are skipped when deps=high and when the current branch version has not the same major version number as the next one
|
||||||
[[ $deps = high && ${SYMFONY_VERSION%.*} != $(git ls-remote -q --heads | cut -f2 | grep -FA1 /$SYMFONY_VERSION | tail -n 1 | grep -o '[0-9]*') ]] && export LEGACY=,legacy
|
[[ $deps = high && ${SYMFONY_VERSION%.*} != $(git ls-remote -q --heads | cut -f2 | grep -FA1 /$SYMFONY_VERSION | tail -n 1 | grep -o '[0-9]*' | head -n 1) ]] && export LEGACY=,legacy
|
||||||
|
|
||||||
export COMPOSER_ROOT_VERSION=$SYMFONY_VERSION.x-dev
|
export COMPOSER_ROOT_VERSION=$SYMFONY_VERSION.x-dev
|
||||||
if [[ $deps ]]; then mv composer.json.phpunit composer.json; fi
|
if [[ $deps ]]; then mv composer.json.phpunit composer.json; fi
|
||||||
|
@ -47,7 +47,7 @@ class SerializerExtractor implements PropertyListExtractorInterface
|
|||||||
$serializerClassMetadata = $this->classMetadataFactory->getMetadataFor($class);
|
$serializerClassMetadata = $this->classMetadataFactory->getMetadataFor($class);
|
||||||
|
|
||||||
foreach ($serializerClassMetadata->getAttributesMetadata() as $serializerAttributeMetadata) {
|
foreach ($serializerClassMetadata->getAttributesMetadata() as $serializerAttributeMetadata) {
|
||||||
$ignored = method_exists($serializerClassMetadata, 'isIgnored') && $serializerAttributeMetadata->isIgnored();
|
$ignored = method_exists($serializerAttributeMetadata, 'isIgnored') && $serializerAttributeMetadata->isIgnored();
|
||||||
if (!$ignored && (null === $context['serializer_groups'] || array_intersect($context['serializer_groups'], $serializerAttributeMetadata->getGroups()))) {
|
if (!$ignored && (null === $context['serializer_groups'] || array_intersect($context['serializer_groups'], $serializerAttributeMetadata->getGroups()))) {
|
||||||
$properties[] = $serializerAttributeMetadata->getName();
|
$properties[] = $serializerAttributeMetadata->getName();
|
||||||
}
|
}
|
||||||
|
@ -14,6 +14,9 @@ namespace Symfony\Component\PropertyInfo\Tests\Extractor;
|
|||||||
use Doctrine\Common\Annotations\AnnotationReader;
|
use Doctrine\Common\Annotations\AnnotationReader;
|
||||||
use PHPUnit\Framework\TestCase;
|
use PHPUnit\Framework\TestCase;
|
||||||
use Symfony\Component\PropertyInfo\Extractor\SerializerExtractor;
|
use Symfony\Component\PropertyInfo\Extractor\SerializerExtractor;
|
||||||
|
use Symfony\Component\PropertyInfo\Tests\Fixtures\AdderRemoverDummy;
|
||||||
|
use Symfony\Component\PropertyInfo\Tests\Fixtures\IgnorePropertyDummy;
|
||||||
|
use Symfony\Component\Serializer\Annotation\Ignore;
|
||||||
use Symfony\Component\Serializer\Mapping\Factory\ClassMetadataFactory;
|
use Symfony\Component\Serializer\Mapping\Factory\ClassMetadataFactory;
|
||||||
use Symfony\Component\Serializer\Mapping\Loader\AnnotationLoader;
|
use Symfony\Component\Serializer\Mapping\Loader\AnnotationLoader;
|
||||||
|
|
||||||
@ -41,8 +44,17 @@ class SerializerExtractorTest extends TestCase
|
|||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public function testGetPropertiesWithIgnoredProperties()
|
||||||
|
{
|
||||||
|
if (!class_exists(Ignore::class)) {
|
||||||
|
$this->markTestSkipped('Ignore annotation is not implemented in current symfony/serializer version');
|
||||||
|
}
|
||||||
|
|
||||||
|
$this->assertSame(['visibleProperty'], $this->extractor->getProperties(IgnorePropertyDummy::class, ['serializer_groups' => ['a']]));
|
||||||
|
}
|
||||||
|
|
||||||
public function testGetPropertiesWithAnyGroup()
|
public function testGetPropertiesWithAnyGroup()
|
||||||
{
|
{
|
||||||
$this->assertSame(['analyses', 'feet'], $this->extractor->getProperties('Symfony\Component\PropertyInfo\Tests\Fixtures\AdderRemoverDummy', ['serializer_groups' => null]));
|
$this->assertSame(['analyses', 'feet'], $this->extractor->getProperties(AdderRemoverDummy::class, ['serializer_groups' => null]));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -0,0 +1,32 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
/*
|
||||||
|
* This file is part of the Symfony package.
|
||||||
|
*
|
||||||
|
* (c) Fabien Potencier <fabien@symfony.com>
|
||||||
|
*
|
||||||
|
* For the full copyright and license information, please view the LICENSE
|
||||||
|
* file that was distributed with this source code.
|
||||||
|
*/
|
||||||
|
|
||||||
|
namespace Symfony\Component\PropertyInfo\Tests\Fixtures;
|
||||||
|
|
||||||
|
use Symfony\Component\Serializer\Annotation\Groups;
|
||||||
|
use Symfony\Component\Serializer\Annotation\Ignore;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @author Vadim Borodavko <vadim.borodavko@gmail.com>
|
||||||
|
*/
|
||||||
|
class IgnorePropertyDummy
|
||||||
|
{
|
||||||
|
/**
|
||||||
|
* @Groups({"a"})
|
||||||
|
*/
|
||||||
|
public $visibleProperty;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @Groups({"a"})
|
||||||
|
* @Ignore
|
||||||
|
*/
|
||||||
|
private $ignoredProperty;
|
||||||
|
}
|
Reference in New Issue
Block a user