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

testLoadWithNoBasketInDbButBasketInSession() public method

    public function testLoadWithNoBasketInDbButBasketInSession()
    {
        $basket = $this->getMock('Sonata\\Component\\Basket\\BasketInterface');
        $basket->expects($this->once())->method('setCustomer');
        $basketManager = $this->getMock('Sonata\\Component\\Basket\\BasketManagerInterface');
        $basketManager->expects($this->once())->method('loadBasketPerCustomer')->will($this->returnValue(false));
        $basketBuilder = $this->getMock('Sonata\\Component\\Basket\\BasketBuilderInterface');
        $customer = $this->getMock('Sonata\\Component\\Customer\\CustomerInterface');
        $customer->expects($this->exactly(3))->method('getId')->will($this->returnValue(1));
        $session = $this->getMock('Symfony\\Component\\HttpFoundation\\Session\\Session');
        $session->expects($this->exactly(1))->method('get')->will($this->returnValue($basket));
        $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);
        $basket = $factory->load($customer);
        $this->isInstanceOf('Sonata\\Component\\Basket\\BasketInterface', $basket);
    }