Sonata\tests\CustomerBundle\Entity\AddressManagerTest::testSetCurrent PHP Method

testSetCurrent() public method

public testSetCurrent ( )
    public function testSetCurrent()
    {
        $currentAddress = $this->getMock('Sonata\\Component\\Customer\\AddressInterface');
        $currentAddress->expects($this->once())->method('getCurrent')->will($this->returnValue(true));
        $currentAddress->expects($this->once())->method('setCurrent');
        $custAddresses = array($currentAddress);
        $customer = $this->getMock('Sonata\\Component\\Customer\\CustomerInterface');
        $customer->expects($this->once())->method('getAddressesByType')->will($this->returnValue($custAddresses));
        $address = $this->getMock('Sonata\\Component\\Customer\\AddressInterface');
        $address->expects($this->once())->method('setCurrent');
        $address->expects($this->once())->method('getCustomer')->will($this->returnValue($customer));
        $em = $this->getMockBuilder('Doctrine\\ORM\\EntityManager')->disableOriginalConstructor()->getMock();
        $em->expects($this->any())->method('persist');
        $registry = $this->getMock('Doctrine\\Common\\Persistence\\ManagerRegistry');
        $registry->expects($this->any())->method('getManagerForClass')->will($this->returnValue($em));
        $addressManager = new AddressManager('Sonata\\Component\\Customer\\AddressInterface', $registry);
        $addressManager->setCurrent($address);
    }