File tree 2 files changed +49
-3
lines changed
src/Symfony/Component/Validator 2 files changed +49
-3
lines changed Original file line number Diff line number Diff line change 11
11
12
12
namespace Symfony \Component \Validator \Mapping ;
13
13
14
+ use Symfony \Component \Validator \MetadataFactoryInterface ;
15
+
14
16
/**
15
- * Simple implementation of ClassMetadataFactoryInterface that can be used when using ValidatorInterface::validateValue().
17
+ * Simple implementation of MetadataFactoryInterface that can be used when using ValidatorInterface::validateValue().
16
18
*
17
19
* @author Fabien Potencier <fabien@symfony.com>
18
20
*/
19
- class BlackholeMetadataFactory implements ClassMetadataFactoryInterface
21
+ class BlackholeMetadataFactory implements MetadataFactoryInterface
20
22
{
21
- public function getClassMetadata ($ class )
23
+ /**
24
+ * @inheritdoc
25
+ */
26
+ public function getMetadataFor ($ value )
22
27
{
23
28
throw new \LogicException ('BlackholeClassMetadataFactory only works with ValidatorInterface::validateValue(). ' );
24
29
}
30
+
31
+ /**
32
+ * @inheritdoc
33
+ */
34
+ public function hasMetadataFor ($ value )
35
+ {
36
+ return false ;
37
+ }
25
38
}
Original file line number Diff line number Diff line change
1
+ <?php
2
+
3
+ /*
4
+ * This file is part of the Symfony package.
5
+ *
6
+ * (c) Fabien Potencier <fabien@symfony.com>
7
+ *
8
+ * For the full copyright and license information, please view the LICENSE
9
+ * file that was distributed with this source code.
10
+ */
11
+
12
+ namespace Symfony \Component \Validator \Tests \Mapping ;
13
+
14
+ use Symfony \Component \Validator \Mapping \BlackholeMetadataFactory ;
15
+
16
+ class BlackholeMetadataFactoryTest extends \PHPUnit_Framework_TestCase
17
+ {
18
+ /**
19
+ * @expectedException \LogicException
20
+ */
21
+ public function testGetMetadataForThrowsALogicException ()
22
+ {
23
+ $ metadataFactory = new BlackholeMetadataFactory ();
24
+ $ metadataFactory ->getMetadataFor ('foo ' );
25
+ }
26
+
27
+ public function testHasMetadataForReturnsFalse ()
28
+ {
29
+ $ metadataFactory = new BlackholeMetadataFactory ();
30
+
31
+ $ this ->assertFalse ($ metadataFactory ->hasMetadataFor ('foo ' ));
32
+ }
33
+ }
You can’t perform that action at this time.
0 commit comments