1
|
|
|
<?php |
2
|
|
|
|
3
|
|
|
/* |
4
|
|
|
* This file is part of the PHP Translation package. |
5
|
|
|
* |
6
|
|
|
* (c) PHP Translation team <[email protected]> |
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 Translation\Extractor\Tests\Functional\Visitor\Php\Symfony; |
13
|
|
|
|
14
|
|
|
use Symfony\Component\Validator\Mapping\Factory\LazyLoadingMetadataFactory; |
15
|
|
|
use Translation\Extractor\Tests\Functional\Visitor\Php\BasePHPVisitorTest; |
16
|
|
|
use Translation\Extractor\Tests\Resources; |
17
|
|
|
use Translation\Extractor\Visitor\Php\Symfony\ValidationAnnotation; |
18
|
|
|
use Symfony\Component\Validator\Mapping\Loader\AnnotationLoader; |
19
|
|
|
use Doctrine\Common\Annotations\AnnotationReader; |
20
|
|
|
|
21
|
|
|
/** |
22
|
|
|
* @author Tobias Nyholm <[email protected]> |
23
|
|
|
*/ |
24
|
|
|
final class ValidationAnnotationTest extends BasePHPVisitorTest |
25
|
|
|
{ |
26
|
|
|
public function testExtractAnnotation() |
27
|
|
|
{ |
28
|
|
|
$factory = new LazyLoadingMetadataFactory(new AnnotationLoader(new AnnotationReader())); |
29
|
|
|
$extractor = new ValidationAnnotation($factory); |
30
|
|
|
$collection = $this->getSourceLocations($extractor, Resources\Php\Symfony\ValidatorAnnotation::class); |
31
|
|
|
|
32
|
|
|
$this->assertCount(2, $collection); |
33
|
|
|
$source = $collection->get(0); |
34
|
|
|
$this->assertEquals('start.null', $source->getMessage()); |
35
|
|
|
$this->assertEquals('validators', $source->getContext()['domain']); |
36
|
|
|
|
37
|
|
|
$source = $collection->get(1); |
38
|
|
|
$this->assertEquals('end.blank', $source->getMessage()); |
39
|
|
|
$this->assertEquals('validators', $source->getContext()['domain']); |
40
|
|
|
} |
41
|
|
|
|
42
|
|
|
public function testExtractAnnotationError() |
43
|
|
|
{ |
44
|
|
|
$factory = new LazyLoadingMetadataFactory(new AnnotationLoader(new AnnotationReader())); |
45
|
|
|
$extractor = new ValidationAnnotation($factory); |
46
|
|
|
$collection = $this->getSourceLocations($extractor, Resources\Php\Symfony\ValidatorAnnotationError::class); |
47
|
|
|
|
48
|
|
|
$errors = $collection->getErrors(); |
49
|
|
|
$this->assertCount(1, $errors); |
50
|
|
|
} |
51
|
|
|
} |
52
|
|
|
|