2015-08-19 15:52:10 +03:00
|
|
|
<?php
|
|
|
|
|
|
|
|
namespace DesignPatterns\More\EAV\Tests;
|
|
|
|
|
|
|
|
use DesignPatterns\More\EAV\Attribute;
|
|
|
|
use DesignPatterns\More\EAV\Value;
|
|
|
|
|
|
|
|
/**
|
2015-12-21 07:28:20 -05:00
|
|
|
* ValueTest tests the Value model of EAV pattern.
|
2015-08-19 15:52:10 +03:00
|
|
|
*/
|
|
|
|
class ValueTest extends \PHPUnit_Framework_TestCase
|
|
|
|
{
|
|
|
|
public function testCreationSuccessWithAttribute()
|
|
|
|
{
|
|
|
|
$attribute = new Attribute();
|
|
|
|
$attribute->setName('Color');
|
|
|
|
|
|
|
|
$value = new Value($attribute);
|
|
|
|
|
|
|
|
$this->assertInstanceOf('\DesignPatterns\More\EAV\Value', $value);
|
|
|
|
}
|
|
|
|
|
|
|
|
public function testSetGetName()
|
|
|
|
{
|
|
|
|
$attribute = new Attribute();
|
|
|
|
$attribute->setName('Color');
|
|
|
|
|
|
|
|
$value = new Value($attribute);
|
|
|
|
$value->setName('Silver');
|
|
|
|
|
|
|
|
$this->assertEquals('Silver', $value->getName());
|
|
|
|
}
|
|
|
|
|
|
|
|
public function testSetGetAttribute()
|
|
|
|
{
|
|
|
|
$attribute = new Attribute();
|
|
|
|
$attribute->setName('Color');
|
|
|
|
|
|
|
|
$value = new Value($attribute);
|
|
|
|
$value->setName('Silver');
|
|
|
|
$this->assertSame($attribute, $value->getAttribute());
|
|
|
|
|
|
|
|
$value->setAttribute($attribute);
|
|
|
|
$this->assertSame($attribute, $value->getAttribute());
|
|
|
|
}
|
|
|
|
}
|