Sonata\Test\CustomerBundle\Controller\Api\CustomerControllerTest::testPostCustomerAddressAction PHP Метод

testPostCustomerAddressAction() публичный Метод

    public function testPostCustomerAddressAction()
    {
        $customer = $this->getMock('Sonata\\Component\\Customer\\CustomerInterface');
        $address = $this->getMock('Sonata\\Component\\Customer\\AddressInterface');
        $address->expects($this->once())->method('setCustomer');
        $customerManager = $this->getMock('Sonata\\Component\\Customer\\CustomerManagerInterface');
        $addressManager = $this->getMock('Sonata\\Component\\Customer\\AddressManagerInterface');
        $addressManager->expects($this->once())->method('save')->will($this->returnValue($address));
        $form = $this->getMockBuilder('Symfony\\Component\\Form\\Form')->disableOriginalConstructor()->getMock();
        $form->expects($this->once())->method('bind');
        $form->expects($this->once())->method('isValid')->will($this->returnValue(true));
        $form->expects($this->once())->method('getData')->will($this->returnValue($address));
        $formFactory = $this->getMock('Symfony\\Component\\Form\\FormFactoryInterface');
        $formFactory->expects($this->once())->method('createNamed')->will($this->returnValue($form));
        $view = $this->createCustomerController($customer, $customerManager, $addressManager, $formFactory)->postCustomerAddressAction(1, new Request());
        $this->assertInstanceOf('FOS\\RestBundle\\View\\View', $view);
    }