Skip to content

Commit 4cda770

Browse files
committed
Improve exception messages.
1 parent 6ed2071 commit 4cda770

File tree

2 files changed

+23
-3
lines changed

2 files changed

+23
-3
lines changed

Tests/Mapping/Loader/YamlFileLoaderTest.php

Lines changed: 14 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -31,15 +31,26 @@ public function testLoadClassMetadataReturnsFalseIfEmpty()
3131
$this->assertFalse($loader->loadClassMetadata($metadata));
3232
}
3333

34-
public function testLoadClassMetadataThrowsExceptionIfNotAnArray()
34+
/**
35+
* @dataProvider provideInvalidYamlFiles
36+
* @expectedException \InvalidArgumentException
37+
*/
38+
public function testInvalidYamlFiles($path)
3539
{
36-
$loader = new YamlFileLoader(__DIR__.'/nonvalid-mapping.yml');
40+
$loader = new YamlFileLoader(__DIR__.'/'.$path);
3741
$metadata = new ClassMetadata('Symfony\Component\Validator\Tests\Fixtures\Entity');
3842

39-
$this->setExpectedException('\InvalidArgumentException');
4043
$loader->loadClassMetadata($metadata);
4144
}
4245

46+
public function provideInvalidYamlFiles()
47+
{
48+
return array(
49+
array('nonvalid-mapping.yml'),
50+
array('bad-format.yml'),
51+
);
52+
}
53+
4354
/**
4455
* @see https://github.com/symfony/symfony/pull/12158
4556
*/

Tests/Mapping/Loader/bad-format.yml

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
namespaces:
2+
custom: Symfony\Component\Validator\Tests\Fixtures\
3+
4+
Symfony\Component\Validator\Tests\Fixtures\Entity:
5+
constraints:
6+
# Custom constraint
7+
- Symfony\Component\Validator\Tests\Fixtures\ConstraintA: ~
8+
# Custom constraint with namespaces prefix
9+
- "custom:ConstraintB": ~

0 commit comments

Comments
 (0)