From f9ddaebe09bca1228509c1f9d6ffae1cb8245e5d Mon Sep 17 00:00:00 2001 From: Tobias Schultze Date: Sat, 21 Feb 2015 13:54:33 +0100 Subject: [PATCH] [PropertyAccess] use data provider for isReadable/isWritable tests --- .../Tests/PropertyAccessorTest.php | 34 ++++++------------- 1 file changed, 10 insertions(+), 24 deletions(-) diff --git a/src/Symfony/Component/PropertyAccess/Tests/PropertyAccessorTest.php b/src/Symfony/Component/PropertyAccess/Tests/PropertyAccessorTest.php index 39606a4032..58d4d74402 100644 --- a/src/Symfony/Component/PropertyAccess/Tests/PropertyAccessorTest.php +++ b/src/Symfony/Component/PropertyAccess/Tests/PropertyAccessorTest.php @@ -316,19 +316,12 @@ class PropertyAccessorTest extends \PHPUnit_Framework_TestCase $this->assertTrue($this->propertyAccessor->isReadable(new TestClassMagicCall('Bernhard'), 'magicCallProperty')); } - public function testIsReadableThrowsExceptionIfNotObjectOrArray() + /** + * @dataProvider getPathsWithUnexpectedType + */ + public function testIsReadableReturnsFalseIfNotObjectOrArray($objectOrArray, $path) { - $this->assertFalse($this->propertyAccessor->isReadable('baz', 'foobar')); - } - - public function testIsReadableThrowsExceptionIfNull() - { - $this->assertFalse($this->propertyAccessor->isReadable(null, 'foobar')); - } - - public function testIsReadableThrowsExceptionIfEmpty() - { - $this->assertFalse($this->propertyAccessor->isReadable('', 'foobar')); + $this->assertFalse($this->propertyAccessor->isReadable($objectOrArray, $path)); } /** @@ -384,19 +377,12 @@ class PropertyAccessorTest extends \PHPUnit_Framework_TestCase $this->assertTrue($this->propertyAccessor->isWritable(new TestClassMagicCall('Bernhard'), 'magicCallProperty')); } - public function testNotObjectOrArrayIsNotWritable() + /** + * @dataProvider getPathsWithUnexpectedType + */ + public function testIsWritableReturnsFalseIfNotObjectOrArray($objectOrArray, $path) { - $this->assertFalse($this->propertyAccessor->isWritable('baz', 'foobar')); - } - - public function testNullIsNotWritable() - { - $this->assertFalse($this->propertyAccessor->isWritable(null, 'foobar')); - } - - public function testEmptyIsNotWritable() - { - $this->assertFalse($this->propertyAccessor->isWritable('', 'foobar')); + $this->assertFalse($this->propertyAccessor->isWritable($objectOrArray, $path)); } public function getValidPropertyPaths()