[EAV] Value::setAttribute add return this

This commit is contained in:
ftwbzhao 2015-11-16 13:52:07 +08:00
parent 3bf84ae0f6
commit 115dd3bdb3
2 changed files with 4 additions and 2 deletions

View File

@ -40,7 +40,6 @@ class ValueTest extends \PHPUnit_Framework_TestCase
$value->setName('Silver');
$this->assertSame($attribute, $value->getAttribute());
$value->setAttribute($attribute);
$this->assertSame($attribute, $value->getAttribute());
$this->assertSame($attribute, $value->setAttribute($attribute)->getAttribute());
}
}

View File

@ -28,12 +28,15 @@ class Value implements ValueInterface
/**
* @param Attribute $attribute
* @return $this
*/
public function setAttribute(Attribute $attribute)
{
$this->attribute->removeValue($this); // Remove value from current attribute
$attribute->addValue($this); // Add value to new attribute
$this->attribute = $attribute;
return $this;
}
/**