Sonata\Tests\Component\Basket\BasketEntityFactoryTest::testLoadWithBasketInDbAndInSession PHP Method

testLoadWithBasketInDbAndInSession() public method

    public function testLoadWithBasketInDbAndInSession()
    {
        $basket = $this->getMock('Sonata\\Component\\Basket\\BasketInterface');
        $sessionBasket = $this->getMock('Sonata\\Component\\Basket\\BasketInterface');
        $basketManager = $this->getMock('Sonata\\Component\\Basket\\BasketManagerInterface');
        $basketManager->expects($this->once())->method('loadBasketPerCustomer')->will($this->returnValue($basket));
        $basketBuilder = $this->getMock('Sonata\\Component\\Basket\\BasketBuilderInterface');
        $basketBuilder->expects($this->exactly(2))->method('build');
        $customer = $this->getMock('Sonata\\Component\\Customer\\CustomerInterface');
        $customer->expects($this->exactly(5))->method('getId')->will($this->returnValue(1));
        $session = $this->getMock('Symfony\\Component\\HttpFoundation\\Session\\Session');
        $session->expects($this->exactly(1))->method('get')->will($this->returnValue($sessionBasket));
        $currencyDetector = $this->getMock('Sonata\\Component\\Currency\\CurrencyDetectorInterface');
        $currency = new Currency();
        $currency->setLabel('EUR');
        $currencyDetector->expects($this->any())->method('getCurrency')->will($this->returnValue($currency));
        $factory = new BasketEntityFactory($basketManager, $basketBuilder, $currencyDetector, $session);
        $loadedBasket = $factory->load($customer);
        $this->isInstanceOf('Sonata\\Component\\Basket\\BasketInterface', $loadedBasket);
    }