Sonata\Tests\Component\Basket\BasketElementTest::testValidity PHP Method

testValidity() public method

public testValidity ( )
    public function testValidity()
    {
        $product = $this->getMock('Sonata\\Component\\Product\\ProductInterface', array(), array(), 'BasketTest_Product');
        $product->expects($this->once())->method('getEnabled')->will($this->returnValue(true));
        $basketElement = new BasketElement();
        $basketElement->setProduct('product_code', $product);
        $this->assertEquals(true, $basketElement->isValid(), 'BasketElement is valid');
        $product = $this->getMock('Sonata\\Component\\Product\\ProductInterface', array(), array(), 'BasketTest_Product');
        $product->expects($this->once())->method('getEnabled')->will($this->returnValue(false));
        $basketElement->setProduct('product_code', $product);
        $this->assertEquals(false, $basketElement->isValid(), 'BasketElement returns the correct default quantity');
    }