[Validator] Replaced inexistent interface.

ClassMetadataFactoryInterface was removed in 2.3 and replaced with MetadataFactoryInterface.
This commit is contained in:
Jakub Zalas 2013-11-27 23:46:40 +00:00
parent 7921772901
commit 8fd3256248
2 changed files with 49 additions and 3 deletions

View File

@ -11,15 +11,28 @@
namespace Symfony\Component\Validator\Mapping;
use Symfony\Component\Validator\MetadataFactoryInterface;
/**
* Simple implementation of ClassMetadataFactoryInterface that can be used when using ValidatorInterface::validateValue().
* Simple implementation of MetadataFactoryInterface that can be used when using ValidatorInterface::validateValue().
*
* @author Fabien Potencier <fabien@symfony.com>
*/
class BlackholeMetadataFactory implements ClassMetadataFactoryInterface
class BlackholeMetadataFactory implements MetadataFactoryInterface
{
public function getClassMetadata($class)
/**
* @inheritdoc
*/
public function getMetadataFor($value)
{
throw new \LogicException('BlackholeClassMetadataFactory only works with ValidatorInterface::validateValue().');
}
/**
* @inheritdoc
*/
public function hasMetadataFor($value)
{
return false;
}
}

View File

@ -0,0 +1,33 @@
<?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\Validator\Tests\Mapping;
use Symfony\Component\Validator\Mapping\BlackholeMetadataFactory;
class BlackholeMetadataFactoryTest extends \PHPUnit_Framework_TestCase
{
/**
* @expectedException \LogicException
*/
public function testGetMetadataForThrowsALogicException()
{
$metadataFactory = new BlackholeMetadataFactory();
$metadataFactory->getMetadataFor('foo');
}
public function testHasMetadataForReturnsFalse()
{
$metadataFactory = new BlackholeMetadataFactory();
$this->assertFalse($metadataFactory->hasMetadataFor('foo'));
}
}