8000 Ensure exact exception with message was thrown on access to non-publi… · symfony/symfony@d0c70d4 · GitHub
[go: up one dir, main page]

Skip to content

Commit d0c70d4

Browse files
committed
Ensure exact exception with message was thrown on access to non-public property.
1 parent 17b79ed commit d0c70d4

File tree

1 file changed

+11
-0
lines changed

1 file changed

+11
-0
lines changed

src/Symfony/Component/PropertyAccess/Tests/PropertyAccessorTest.php

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -110,6 +110,17 @@ public function testGetDynamicValue()
110110
$this->assertSame($value, $this->propertyAccessor->getValue($object, $path));
111111
}
112112

113+
/**
114+
* Ensure exact exception with message was thrown on access to non-public property.
115+
*/
116+
public function testGetInaccessibleProperty()
117+
{
118+
$this->expectException('Symfony\Component\PropertyAccess\Exception\NoSuchPropertyException');
119+
$this->expectExceptionMessage(sprintf('Can\'t read protected or private property "%s" in class "%s".', 'protectedProperty', TestClass::class));
120+
121+
$this->propertyAccessor->getValue(new TestClass('Bernhard'), 'protectedProperty');
122+
}
123+
113124
/**
114125
* @dataProvider getPathsWithMissingProperty
115126
*/

0 commit comments

Comments
 (0)
0