8000 [Validator] Minor fixes for the PSR-6 adapter by dunglas · Pull Request #17549 · symfony/symfony · GitHub
[go: up one dir, main page]

Skip to content

[Validator] Minor fixes for the PSR-6 adapter #17549

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
Show file tree
Hide file tree
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
Diff view
Diff view
[Validator] Minor fixes for the PSR-6 adapter
  • Loading branch information
dunglas committed Jan 26, 2016
commit aa60d5be2018f41e193f7bb3e82dcf3f99375b7c
6 changes: 2 additions & 4 deletions src/Symfony/Component/Validator/Mapping/Cache/Psr6Cache.php
Original file line number Diff line number Diff line change
Expand Up @@ -36,9 +36,7 @@ public function __construct(CacheItemPoolInterface $cacheItemPool)
*/
public function has($class)
{
$item = $this->cacheItemPool->getItem($this->escapeClassName($class));

return $item->isHit();
return $this->cacheItemPool->hasItem($this->escapeClassName($class));
}

/**
Expand Down Expand Up @@ -75,6 +73,6 @@ public function write(ClassMetadata $metadata)
*/
private function escapeClassName($class)
{
return strtr($class, '\\', '_');
return str_replace('\\', '_', $class);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@
namespace Symfony\Component\Validator\Tests\Mapping\Cache;

use Symfony\Component\Validator\Mapping\Cache\CacheInterface;
use Symfony\Component\Validator\Mapping\ClassMetadata;

abstract class AbstractCacheTest extends \PHPUnit_Framework_TestCase
{
Expand All @@ -22,7 +23,7 @@ abstract class AbstractCacheTest extends \PHPUnit_Framework_TestCase

public function testWrite()
{
$meta = $this->getMockBuilder('Symfony\\Component\\Validator\\Mapping\\ClassMetadata')
$meta = $this->getMockBuilder(ClassMetadata::class)
->disableOriginalConstructor()
->setMethods(array('getClassName'))
->getMock();
Expand All @@ -34,15 +35,15 @@ public function testWrite()
$this->cache->write($meta);

$this->assertInstanceOf(
'Symfony\\Component\\Validator\\Mapping\\ClassMetadata',
ClassMetadata::class,
$this->cache->read('Foo\\Bar'),
'write() stores metadata'
);
}

public function testHas()
{
$meta = $this->getMockBuilder('Symfony\\Component\\Validator\\Mapping\\ClassMetadata')
$meta = $this->getMockBuilder(ClassMetadata::class)
->disableOriginalConstructor()
->setMethods(array('getClassName'))
->getMock();
Expand All @@ -59,7 +60,7 @@ public function testHas()

public function testRead()
{
$meta = $this->getMockBuilder('Symfony\\Component\\Validator\\Mapping\\ClassMetadata')
$meta = $this->getMockBuilder(ClassMetadata::class)
->disableOriginalConstructor()
->setMethods(array('getClassName'))
->getMock();
Expand All @@ -72,10 +73,6 @@ public function testRead()

$this->cache->write($meta);

$this->assertInstanceOf(
'Symfony\\Component\\Validator\\Mapping\\ClassMetadata',
$this->cache->read('Foo\\Bar'),
'read() returns metadata'
);
$this->assertInstanceOf(ClassMetadata::class, $this->cache->read('Foo\\Bar'), 'read() returns metadata');
}
}
0