public function testBuild()
{
$productProvider = $this->getMock('Sonata\\Component\\Product\\ProductProviderInterface');
$productManager = $this->getMock('Sonata\\Component\\Product\\ProductManagerInterface');
$definition = new ProductDefinition($productProvider, $productManager);
$productPool = new ProductPool();
$productPool->addProduct('test', $definition);
$deliveryPool = new DeliveryPool();
$paymentPool = new PaymentPool();
$address = $this->getMock('Sonata\\Component\\Customer\\AddressInterface');
$addressManager = $this->getMock('Sonata\\Component\\Customer\\AddressManagerInterface');
$addressManager->expects($this->exactly(2))->method('findOneBy')->will($this->returnValue($address));
$basketBuilder = new BasketBuilder($productPool, $addressManager, $deliveryPool, $paymentPool);
$basketElement_1 = $this->getMock('Sonata\\Component\\Basket\\BasketElementInterface');
$basketElement_1->expects($this->exactly(2))->method('getProductCode')->will($this->returnValue('test'));
$basketElement_1->expects($this->once())->method('setProductDefinition');
$basketElements = array($basketElement_1);
$basket = $this->getMock('Sonata\\Component\\Basket\\BasketInterface');
$basket->expects($this->once())->method('getBasketElements')->will($this->returnValue($basketElements));
$basket->expects($this->once())->method('getDeliveryAddressId')->will($this->returnValue(1));
$basket->expects($this->once())->method('getDeliveryMethodCode')->will($this->returnValue('ups'));
$basket->expects($this->once())->method('getBillingAddressId')->will($this->returnValue(2));
$basket->expects($this->once())->method('getPaymentMethodCode')->will($this->returnValue('credit_cart'));
$basket->expects($this->once())->method('setDeliveryAddress');
$basket->expects($this->once())->method('setDeliveryMethod');
$basket->expects($this->once())->method('setBillingAddress');
$basket->expects($this->once())->method('setPaymentMethod');
$basket->expects($this->once())->method('buildPrices');
$basketBuilder->build($basket);
}