Sonata\Tests\Component\Delivery\SelectorTest::testGetAvailableMethodsWithAlreadySelectedCode PHP Method

testGetAvailableMethodsWithAlreadySelectedCode() public method

Provide twice the same delivery code.
    public function testGetAvailableMethodsWithAlreadySelectedCode()
    {
        $deliveryPool = $this->getMock('Sonata\\Component\\Delivery\\Pool');
        $basket = $this->getMock('Sonata\\Component\\Basket\\Basket');
        $basketElement = $this->getMock('Sonata\\Component\\Basket\\BasketElement');
        $product = $this->getMock('Sonata\\Tests\\Component\\Delivery\\Product');
        $delivery1 = $this->getMock('Sonata\\Component\\Product\\DeliveryInterface');
        $delivery1->expects($this->any())->method('getCode')->will($this->returnValue('deliveryTest'));
        $delivery2 = $this->getMock('Sonata\\Component\\Product\\DeliveryInterface');
        $delivery2->expects($this->any())->method('getCode')->will($this->returnValue('deliveryTest'));
        $serviceDelivery = $this->getMock('Sonata\\Component\\Delivery\\BaseServiceDelivery');
        $serviceDelivery->expects($this->any())->method('getCode')->will($this->returnValue('deliveryTest'));
        $serviceDelivery->expects($this->any())->method('getEnabled')->will($this->returnValue(true));
        $serviceDelivery->expects($this->any())->method('isAddressRequired')->will($this->returnValue(false));
        $deliveryPool->expects($this->once())->method('getMethod')->will($this->returnValue($serviceDelivery));
        $basket->expects($this->once())->method('getBasketElements')->will($this->returnValue(array($basketElement)));
        $basketElement->expects($this->once())->method('getProduct')->will($this->returnValue($product));
        $product->expects($this->once())->method('getDeliveries')->will($this->returnValue(array($delivery1, $delivery2)));
        $selector = new Selector($deliveryPool, new ProductPool());
        $this->assertEquals(array($serviceDelivery), $selector->getAvailableMethods($basket));
    }