public function testSaveNoExistingCustomer() { $basket = $this->getMock('Sonata\\Component\\Basket\\BasketInterface'); $basket->expects($this->once())->method('getCustomerId')->will($this->returnValue(false)); $basketManager = $this->getMock('Sonata\\Component\\Basket\\BasketManagerInterface'); $basketBuilder = $this->getMock('Sonata\\Component\\Basket\\BasketBuilderInterface'); $session = $this->getMock('Symfony\\Component\\HttpFoundation\\Session\\SessionInterface'); $tester = $this; $session->expects($this->once())->method('set')->will($this->returnCallback(function ($key, $value) use($tester, $basket) { $tester->assertEquals($basket, $value); $tester->assertEquals('sonata/basket/factory/customer/new', $key); })); $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 BasketEntityFactory($basketManager, $basketBuilder, $currencyDetector, $session); $factory->save($basket); }
public function testReset() { $basket = $this->getMock('Sonata\\Component\\Basket\\BasketInterface'); $basket->expects($this->once())->method('getCustomerId')->will($this->returnValue(1)); $basketManager = $this->getMock('Sonata\\Component\\Basket\\BasketManagerInterface'); $basketManager->expects($this->once())->method('delete'); $basketBuilder = $this->getMock('Sonata\\Component\\Basket\\BasketBuilderInterface'); $session = $this->getMock('Symfony\\Component\\HttpFoundation\\Session\\Session'); $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 BasketEntityFactory($basketManager, $basketBuilder, $currencyDetector, $session); $factory->reset($basket); }