Sonata\Test\BasketBundle\Controller\Api\BasketControllerTest::testPostBasketAction PHP Method

testPostBasketAction() public method

    public function testPostBasketAction()
    {
        $basket = $this->getMock('Sonata\\Component\\Basket\\BasketInterface');
        $basketManager = $this->getMock('Sonata\\Component\\Basket\\BasketManagerInterface');
        $basketManager->expects($this->once())->method('save')->will($this->returnValue($basket));
        $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($basket));
        $formFactory = $this->getMock('Symfony\\Component\\Form\\FormFactoryInterface');
        $formFactory->expects($this->once())->method('createNamed')->will($this->returnValue($form));
        $view = $this->createBasketController($basketManager, null, null, null, $formFactory)->postBasketAction(new Request());
        $this->assertInstanceOf('FOS\\RestBundle\\View\\View', $view);
    }