setMembers() public method

public setMembers ( Doctrine\Common\Collections\Collection $members )
$members Doctrine\Common\Collections\Collection
Example #1
0
 /**
  * @covers ::match
  *
  * @uses \CommerceGuys\Zone\Model\Zone::__construct
  * @uses \CommerceGuys\Zone\Model\Zone::setMembers
  */
 public function testMatch()
 {
     $address = $this->getMockBuilder('CommerceGuys\\Addressing\\Model\\Address')->getMock();
     $matchingZoneMember = $this->getMockBuilder('CommerceGuys\\Zone\\Model\\ZoneMember')->getMock();
     $matchingZoneMember->expects($this->any())->method('match')->with($address)->will($this->returnValue(true));
     $nonMatchingZoneMember = $this->getMockBuilder('CommerceGuys\\Zone\\Model\\ZoneMember')->getMock();
     $nonMatchingZoneMember->expects($this->any())->method('match')->with($address)->will($this->returnValue(false));
     $members = new ArrayCollection([$matchingZoneMember, $nonMatchingZoneMember]);
     $this->zone->setMembers($members);
     $this->assertEquals(true, $this->zone->match($address));
     $members = new ArrayCollection([$nonMatchingZoneMember]);
     $this->zone->setMembers($members);
     $this->assertEquals(false, $this->zone->match($address));
 }