minor #17564 [Serializer] Use ::class in new tests (dunglas)
This PR was merged into the 3.1-dev branch.
Discussion
----------
[Serializer] Use ::class in new tests
| Q | A
| ------------- | ---
| Bug fix? | no
| New feature? | no
| BC breaks? | no
| Deprecations? | no
| Tests pass? | yes
| Fixed tickets | https://github.com/symfony/symfony/pull/17446#discussion_r50965366
| License | MIT
| Doc PR | n/a
Commits
-------
48e8041
[Serializer] Use ::class in new tests
This commit is contained in:
commit
5b5970364e
@ -13,7 +13,9 @@ namespace Symfony\Component\Serializer\Tests\Mapping\Factory;
|
||||
|
||||
use Symfony\Component\Cache\Adapter\ArrayAdapter;
|
||||
use Symfony\Component\Serializer\Mapping\ClassMetadata;
|
||||
use Symfony\Component\Serializer\Mapping\Factory\ClassMetadataFactoryInterface;
|
||||
use Symfony\Component\Serializer\Mapping\Factory\CacheClassMetadataFactory;
|
||||
use Symfony\Component\Serializer\Tests\Fixtures\Dummy;
|
||||
|
||||
/**
|
||||
* @author Kévin Dunglas <dunglas@gmail.com>
|
||||
@ -22,9 +24,9 @@ class CacheMetadataFactoryTest extends \PHPUnit_Framework_TestCase
|
||||
{
|
||||
public function testGetMetadataFor()
|
||||
{
|
||||
$metadata = new ClassMetadata('Symfony\Component\Serializer\Tests\Fixtures\Dummy');
|
||||
$metadata = new ClassMetadata(Dummy::class);
|
||||
|
||||
$decorated = $this->getMock('Symfony\Component\Serializer\Mapping\Factory\ClassMetadataFactoryInterface');
|
||||
$decorated = $this->getMock(ClassMetadataFactoryInterface::class);
|
||||
$decorated
|
||||
->expects($this->once())
|
||||
->method('getMetadataFor')
|
||||
@ -33,14 +35,14 @@ class CacheMetadataFactoryTest extends \PHPUnit_Framework_TestCase
|
||||
|
||||
$factory = new CacheClassMetadataFactory($decorated, new ArrayAdapter());
|
||||
|
||||
$this->assertEquals($metadata, $factory->getMetadataFor('Symfony\Component\Serializer\Tests\Fixtures\Dummy'));
|
||||
$this->assertEquals($metadata, $factory->getMetadataFor(Dummy::class));
|
||||
// The second call should retrieve the value from the cache
|
||||
$this->assertEquals($metadata, $factory->getMetadataFor('Symfony\Component\Serializer\Tests\Fixtures\Dummy'));
|
||||
$this->assertEquals($metadata, $factory->getMetadataFor(Dummy::class));
|
||||
}
|
||||
|
||||
public function testHasMetadataFor()
|
||||
{
|
||||
$decorated = $this->getMock('Symfony\Component\Serializer\Mapping\Factory\ClassMetadataFactoryInterface');
|
||||
$decorated = $this->getMock(ClassMetadataFactoryInterface::class);
|
||||
$decorated
|
||||
->expects($this->once())
|
||||
->method('hasMetadataFor')
|
||||
@ -49,7 +51,7 @@ class CacheMetadataFactoryTest extends \PHPUnit_Framework_TestCase
|
||||
|
||||
$factory = new CacheClassMetadataFactory($decorated, new ArrayAdapter());
|
||||
|
||||
$this->assertTrue($factory->hasMetadataFor('Symfony\Component\Serializer\Tests\Fixtures\Dummy'));
|
||||
$this->assertTrue($factory->hasMetadataFor(Dummy::class));
|
||||
}
|
||||
|
||||
/**
|
||||
@ -57,7 +59,7 @@ class CacheMetadataFactoryTest extends \PHPUnit_Framework_TestCase
|
||||
*/
|
||||
public function testInvalidClassThrowsException()
|
||||
{
|
||||
$decorated = $this->getMock('Symfony\Component\Serializer\Mapping\Factory\ClassMetadataFactoryInterface');
|
||||
$decorated = $this->getMock(ClassMetadataFactoryInterface::class);
|
||||
$factory = new CacheClassMetadataFactory($decorated, new ArrayAdapter());
|
||||
|
||||
$factory->getMetadataFor('Not\Exist');
|
||||
|
Reference in New Issue
Block a user