mirror of
https://github.com/DesignPatternsPHP/DesignPatternsPHP.git
synced 2025-07-28 10:40:17 +02:00
Fix tests for PHP 5.3
This commit is contained in:
@@ -10,7 +10,7 @@ class Attribute implements ValueAccessInterface
|
|||||||
/**
|
/**
|
||||||
* @var array|Value[]|ValueInterface[]
|
* @var array|Value[]|ValueInterface[]
|
||||||
*/
|
*/
|
||||||
private $values = [];
|
private $values = array();
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @var string
|
* @var string
|
||||||
|
@@ -10,7 +10,7 @@ class Entity implements ValueAccessInterface
|
|||||||
/**
|
/**
|
||||||
* @var array|Value[]|ValueInterface[]
|
* @var array|Value[]|ValueInterface[]
|
||||||
*/
|
*/
|
||||||
private $values = [];
|
private $values = array();
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @var string
|
* @var string
|
||||||
|
@@ -36,9 +36,15 @@ class AttributeTest extends \PHPUnit_Framework_TestCase
|
|||||||
$attribute = new Attribute();
|
$attribute = new Attribute();
|
||||||
$attribute->setName('Color');
|
$attribute->setName('Color');
|
||||||
|
|
||||||
$values[] = (new Value($attribute))->setName('Silver');
|
$colorSilver = new Value($attribute);
|
||||||
$values[] = (new Value($attribute))->setName('Gold');
|
$colorSilver->setName('Silver');
|
||||||
$values[] = (new Value($attribute))->setName('Space Grey');
|
$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());
|
$this->assertEquals($values, $attribute->getValues());
|
||||||
}
|
}
|
||||||
@@ -48,14 +54,20 @@ class AttributeTest extends \PHPUnit_Framework_TestCase
|
|||||||
*/
|
*/
|
||||||
public function testRemoveValue()
|
public function testRemoveValue()
|
||||||
{
|
{
|
||||||
$values = [];
|
$values = array();
|
||||||
|
|
||||||
$attribute = new Attribute();
|
$attribute = new Attribute();
|
||||||
$attribute->setName('Color');
|
$attribute->setName('Color');
|
||||||
|
|
||||||
$values[] = (new Value($attribute))->setName('Silver');
|
$colorSilver = new Value($attribute);
|
||||||
$values[] = (new Value($attribute))->setName('Gold');
|
$colorSilver->setName('Silver');
|
||||||
$values[] = (new Value($attribute))->setName('Space Grey');
|
$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);
|
$randomIndex = array_rand($values);
|
||||||
$attribute->removeValue($values[$randomIndex]);
|
$attribute->removeValue($values[$randomIndex]);
|
||||||
|
@@ -71,53 +71,66 @@ class EntityTest extends \PHPUnit_Framework_TestCase
|
|||||||
public function valueProvider()
|
public function valueProvider()
|
||||||
{
|
{
|
||||||
// color attribute
|
// color attribute
|
||||||
$color = (new Attribute())->setName('Color');
|
$color = new Attribute();
|
||||||
|
$color->setName('Color');
|
||||||
// color values
|
// color values
|
||||||
$colorSilver = (new Value($color))->setName('Silver');
|
$colorSilver = new Value($color);
|
||||||
$colorGold = (new Value($color))->setName('Gold');
|
$colorSilver->setName('Silver');
|
||||||
$colorSpaceGrey = (new Value($color))->setName('Space Grey');
|
$colorGold = new Value($color);
|
||||||
|
$colorGold->setName('Gold');
|
||||||
|
$colorSpaceGrey = new Value($color);
|
||||||
|
$colorSpaceGrey->setName('Space Grey');
|
||||||
|
|
||||||
// memory attribute
|
// memory attribute
|
||||||
$memory = (new Attribute())->setName('Memory');
|
$memory = new Attribute();
|
||||||
|
$memory->setName('Memory');
|
||||||
// memory values
|
// memory values
|
||||||
$memory4Gb = (new Value($memory))->setName('4GB');
|
$memory4Gb = new Value($memory);
|
||||||
$memory8Gb = (new Value($memory))->setName('8GB');
|
$memory4Gb->setName('4GB');
|
||||||
$memory16Gb = (new Value($memory))->setName('16GB');
|
$memory8Gb = new Value($memory);
|
||||||
|
$memory8Gb->setName('8GB');
|
||||||
|
$memory16Gb = new Value($memory);
|
||||||
|
$memory16Gb->setName('16GB');
|
||||||
|
|
||||||
// storage attribute
|
// storage attribute
|
||||||
$storage = (new Attribute())->setName('Storage');
|
$storage = new Attribute();
|
||||||
|
$storage->setName('Storage');
|
||||||
// storage values
|
// storage values
|
||||||
$storage128Gb = (new Value($storage))->setName('128GB');
|
$storage128Gb = new Value($storage);
|
||||||
$storage256Gb = (new Value($storage))->setName('256GB');
|
$storage128Gb->setName('128GB');
|
||||||
$storage512Gb = (new Value($storage))->setName('512GB');
|
$storage256Gb = new Value($storage);
|
||||||
$storage1Tb = (new Value($storage))->setName('1TB');
|
$storage256Gb->setName('256GB');
|
||||||
|
$storage512Gb = new Value($storage);
|
||||||
|
$storage512Gb->setName('512GB');
|
||||||
|
$storage1Tb = new Value($storage);
|
||||||
|
$storage1Tb->setName('1TB');
|
||||||
|
|
||||||
return [
|
return array(
|
||||||
[
|
array(
|
||||||
'MacBook',
|
'MacBook',
|
||||||
[
|
array(
|
||||||
$colorSilver,
|
$colorSilver,
|
||||||
$colorGold,
|
$colorGold,
|
||||||
$colorSpaceGrey,
|
$colorSpaceGrey,
|
||||||
$memory8Gb,
|
$memory8Gb,
|
||||||
$storage256Gb,
|
$storage256Gb,
|
||||||
$storage512Gb,
|
$storage512Gb,
|
||||||
],
|
),
|
||||||
],
|
),
|
||||||
[
|
array(
|
||||||
'MacBook Air',
|
'MacBook Air',
|
||||||
[
|
array(
|
||||||
$colorSilver,
|
$colorSilver,
|
||||||
$memory4Gb,
|
$memory4Gb,
|
||||||
$memory8Gb,
|
$memory8Gb,
|
||||||
$storage128Gb,
|
$storage128Gb,
|
||||||
$storage256Gb,
|
$storage256Gb,
|
||||||
$storage512Gb,
|
$storage512Gb,
|
||||||
],
|
),
|
||||||
],
|
),
|
||||||
[
|
array(
|
||||||
'MacBook Pro',
|
'MacBook Pro',
|
||||||
[
|
array(
|
||||||
$colorSilver,
|
$colorSilver,
|
||||||
$memory8Gb,
|
$memory8Gb,
|
||||||
$memory16Gb,
|
$memory16Gb,
|
||||||
@@ -125,8 +138,8 @@ class EntityTest extends \PHPUnit_Framework_TestCase
|
|||||||
$storage256Gb,
|
$storage256Gb,
|
||||||
$storage512Gb,
|
$storage512Gb,
|
||||||
$storage1Tb,
|
$storage1Tb,
|
||||||
],
|
),
|
||||||
],
|
),
|
||||||
];
|
);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user