10000 [Serializer] Use ::class in new tests by dunglas · Pull Request #17564 · symfony/symfony · GitHub
[go: up one dir, main page]

Skip to content

[Serializer] Use ::class in new tests #17564

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Jan 27, 2016
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
D 10000 iff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,9 @@

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>
Expand All @@ -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')
Expand All @@ -33,14 +35,14 @@ public function testGetMetadataFor()

$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')
Expand All @@ -49,15 +51,15 @@ public function testHasMetadataFor()

$factory = new CacheClassMetadataFactory($decorated, new ArrayAdapter());

$this->assertTrue($factory->hasMetadataFor('Symfony\Component\Serializer\Tests\Fixtures\Dummy'));
$this->assertTrue($factory->hasMetadataFor(Dummy::class));
}

/**
* @expectedException \Symfony\Component\Serializer\Exception\InvalidArgumentException
*/
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');
Expand Down
0