示例#1
0
 /**
  *
  * @param Attribute $attribute
  *
  * @return $this
  */
 public function addAttribute(Attribute $attribute)
 {
     $this->attributes[] = $attribute;
     $attribute->setUser($this);
     return $this;
 }
示例#2
0
 /**
  * asserts that the User is being passed to the Attribute by reference
  * by making changes to the behavior of the User after it is injected
  * into the Attribute
  *
  * @param string $methodName
  * @param string $expectedValue
  *
  * @dataProvider providerTestThatUserPropertyIsPassedByReference
  */
 public function testThatUserPropertyIsPassedByReference($methodName, $expectedValue)
 {
     /*
      * create a mock User
      */
     $user = $this->getMockBuilder('Acl\\Entity\\User')->getMock();
     /*
      * instatiate the Attribute and inject the mock User
      */
     $attribute = new Attribute();
     $attribute->setUser($user);
     /*
      * change the behavior of the original mock User
      */
     $user->expects($this->once())->method($methodName)->will($this->returnValue($expectedValue));
     $actualValue = $attribute->getUser()->{$methodName}();
     $errorMessage = sprintf("call to User::%s on user injected into Attribute is not consistent with the test value ofg injected", $methodName);
     $this->assertEquals($expectedValue, $actualValue, $errorMessage);
 }