From eda331e48325715f841cbae15c45a7b72e18a758 Mon Sep 17 00:00:00 2001 From: victor Date: Wed, 19 Aug 2015 17:13:45 +0300 Subject: [PATCH] Fix tests for PHP 5.3 --- More/EAV/Attribute.php | 2 +- More/EAV/Entity.php | 2 +- More/EAV/Tests/AttributeTest.php | 26 +++++++++---- More/EAV/Tests/EntityTest.php | 67 +++++++++++++++++++------------- 4 files changed, 61 insertions(+), 36 deletions(-) diff --git a/More/EAV/Attribute.php b/More/EAV/Attribute.php index 7103af9..42e9f02 100644 --- a/More/EAV/Attribute.php +++ b/More/EAV/Attribute.php @@ -10,7 +10,7 @@ class Attribute implements ValueAccessInterface /** * @var array|Value[]|ValueInterface[] */ - private $values = []; + private $values = array(); /** * @var string diff --git a/More/EAV/Entity.php b/More/EAV/Entity.php index 5dd7ed1..fc3dc9e 100644 --- a/More/EAV/Entity.php +++ b/More/EAV/Entity.php @@ -10,7 +10,7 @@ class Entity implements ValueAccessInterface /** * @var array|Value[]|ValueInterface[] */ - private $values = []; + private $values = array(); /** * @var string diff --git a/More/EAV/Tests/AttributeTest.php b/More/EAV/Tests/AttributeTest.php index 7a086d3..1561acd 100644 --- a/More/EAV/Tests/AttributeTest.php +++ b/More/EAV/Tests/AttributeTest.php @@ -36,9 +36,15 @@ class AttributeTest extends \PHPUnit_Framework_TestCase $attribute = new Attribute(); $attribute->setName('Color'); - $values[] = (new Value($attribute))->setName('Silver'); - $values[] = (new Value($attribute))->setName('Gold'); - $values[] = (new Value($attribute))->setName('Space Grey'); + $colorSilver = new Value($attribute); + $colorSilver->setName('Silver'); + $values[] = $colorSilver; + $colorGold = new Value($attribute); + $colorGold->setName('Gold'); + $values[] = $colorGold; + $colorSpaceGrey = new Value($attribute); + $colorSpaceGrey->setName('Space Grey'); + $values[] = $colorSpaceGrey; $this->assertEquals($values, $attribute->getValues()); } @@ -48,14 +54,20 @@ class AttributeTest extends \PHPUnit_Framework_TestCase */ public function testRemoveValue() { - $values = []; + $values = array(); $attribute = new Attribute(); $attribute->setName('Color'); - $values[] = (new Value($attribute))->setName('Silver'); - $values[] = (new Value($attribute))->setName('Gold'); - $values[] = (new Value($attribute))->setName('Space Grey'); + $colorSilver = new Value($attribute); + $colorSilver->setName('Silver'); + $values[] = $colorSilver; + $colorGold = new Value($attribute); + $colorGold->setName('Gold'); + $values[] = $colorGold; + $colorSpaceGrey = new Value($attribute); + $colorSpaceGrey->setName('Space Grey'); + $values[] = $colorSpaceGrey; $randomIndex = array_rand($values); $attribute->removeValue($values[$randomIndex]); diff --git a/More/EAV/Tests/EntityTest.php b/More/EAV/Tests/EntityTest.php index 5fa47cc..2e8e58f 100644 --- a/More/EAV/Tests/EntityTest.php +++ b/More/EAV/Tests/EntityTest.php @@ -71,53 +71,66 @@ class EntityTest extends \PHPUnit_Framework_TestCase public function valueProvider() { // color attribute - $color = (new Attribute())->setName('Color'); + $color = new Attribute(); + $color->setName('Color'); // color values - $colorSilver = (new Value($color))->setName('Silver'); - $colorGold = (new Value($color))->setName('Gold'); - $colorSpaceGrey = (new Value($color))->setName('Space Grey'); + $colorSilver = new Value($color); + $colorSilver->setName('Silver'); + $colorGold = new Value($color); + $colorGold->setName('Gold'); + $colorSpaceGrey = new Value($color); + $colorSpaceGrey->setName('Space Grey'); // memory attribute - $memory = (new Attribute())->setName('Memory'); + $memory = new Attribute(); + $memory->setName('Memory'); // memory values - $memory4Gb = (new Value($memory))->setName('4GB'); - $memory8Gb = (new Value($memory))->setName('8GB'); - $memory16Gb = (new Value($memory))->setName('16GB'); + $memory4Gb = new Value($memory); + $memory4Gb->setName('4GB'); + $memory8Gb = new Value($memory); + $memory8Gb->setName('8GB'); + $memory16Gb = new Value($memory); + $memory16Gb->setName('16GB'); // storage attribute - $storage = (new Attribute())->setName('Storage'); + $storage = new Attribute(); + $storage->setName('Storage'); // storage values - $storage128Gb = (new Value($storage))->setName('128GB'); - $storage256Gb = (new Value($storage))->setName('256GB'); - $storage512Gb = (new Value($storage))->setName('512GB'); - $storage1Tb = (new Value($storage))->setName('1TB'); + $storage128Gb = new Value($storage); + $storage128Gb->setName('128GB'); + $storage256Gb = new Value($storage); + $storage256Gb->setName('256GB'); + $storage512Gb = new Value($storage); + $storage512Gb->setName('512GB'); + $storage1Tb = new Value($storage); + $storage1Tb->setName('1TB'); - return [ - [ + return array( + array( 'MacBook', - [ + array( $colorSilver, $colorGold, $colorSpaceGrey, $memory8Gb, $storage256Gb, $storage512Gb, - ], - ], - [ + ), + ), + array( 'MacBook Air', - [ + array( $colorSilver, $memory4Gb, $memory8Gb, $storage128Gb, $storage256Gb, $storage512Gb, - ], - ], - [ + ), + ), + array( 'MacBook Pro', - [ + array( $colorSilver, $memory8Gb, $memory16Gb, @@ -125,8 +138,8 @@ class EntityTest extends \PHPUnit_Framework_TestCase $storage256Gb, $storage512Gb, $storage1Tb, - ], - ], - ]; + ), + ), + ); } }