save() public method

public save ( Sonata\Component\Basket\BasketInterface $basket )
$basket Sonata\Component\Basket\BasketInterface
コード例 #1
0
 public function testSave()
 {
     $basketManager = $this->getMock('Sonata\\Component\\Basket\\BasketManagerInterface');
     $basketBuilder = $this->getMock('Sonata\\Component\\Basket\\BasketBuilderInterface');
     $session = $this->getMock('Symfony\\Component\\HttpFoundation\\Session\\SessionInterface');
     $customer = $this->getMock('Sonata\\Component\\Customer\\CustomerInterface');
     $customer->expects($this->any())->method('getId')->will($this->returnValue(1));
     $basket = $this->getMock('Sonata\\Component\\Basket\\BasketInterface');
     $basket->expects($this->once())->method('getCustomer')->will($this->returnValue($customer));
     $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 BasketSessionFactory($basketManager, $basketBuilder, $currencyDetector, $session);
     $factory->save($basket);
 }