Sonata\Tests\Component\Basket\BasketTest::testGettersSetters PHP Method

testGettersSetters() public method

public testGettersSetters ( )
    public function testGettersSetters()
    {
        $basket = $this->getPreparedBasket();
        $product = $this->getMockProduct();
        $basketElement = new BasketElement();
        $basketElement->setProduct('product_code', $product);
        $basket->setBasketElements(array($basketElement));
        $this->assertEquals(array($basketElement), $basket->getBasketElements());
        $basket->setDeliveryAddressId(1);
        $this->assertEquals(1, $basket->getDeliveryAddressId());
        $basket->setBillingAddressId(1);
        $this->assertEquals(1, $basket->getBillingAddressId());
        $deliveryMethod = $this->getMock('Sonata\\Component\\Delivery\\ServiceDeliveryInterface');
        $deliveryMethod->expects($this->any())->method('getCode')->will($this->returnValue(1));
        $basket->setDeliveryMethod($deliveryMethod);
        $this->assertEquals(1, $basket->getDeliveryMethodCode());
        $paymentMethod = $this->getMock('Sonata\\Component\\Payment\\PaymentInterface');
        $paymentMethod->expects($this->any())->method('getCode')->will($this->returnValue(1));
        $basket->setPaymentMethod($paymentMethod);
        $this->assertEquals(1, $basket->getPaymentMethodCode());
        $basket->setCustomerId(1);
        $this->assertEquals(1, $basket->getCustomerId());
        $options = array('option1' => 'value1', 'option2' => 'value2');
        $basket->setOptions($options);
        $this->assertNull($basket->getOption('unexisting_option'));
        $this->assertEquals(42, $basket->getOption('unexisting_option', 42));
        $this->assertEquals('value1', $basket->getOption('option1'));
        $this->assertEquals($options, $basket->getOptions());
        $basket->setOption('option3', 'value3');
        $this->assertEquals('value3', $basket->getOption('option3'));
        $basket->setLocale('en');
        $this->assertEquals('en', $basket->getLocale());
    }