Exemplo n.º 1
0
 /**
  * Given there are no security token
  *   and a customer factory F
  * When  I ask the wrapper to load a customer
  * Then  it calls F to create a new customer C
  *  and  it returns C.
  */
 public function testCreateCustomerWhenNoSecurityContext()
 {
     $customer = $this->mockCustomer();
     $factory = $this->mockCustomerFactory();
     $factory->expects($this->once())->method('create')->willReturn($customer);
     $wrapper = new CustomerWrapper($factory, null);
     $actual = $wrapper->get();
     $this->assertSame($customer, $actual);
 }
Exemplo n.º 2
0
 /**
  * Load cart
  *
  * This method, first of all tries to retrieve cart from session
  *
  * If this does not exists nor the id is not valid, a new cart is created
  * using Cart factory
  *
  * This behavior can be overriden just overwritting the wrapper
  *
  * @return CartInterface Instance of Cart loaded
  */
 public function loadCart()
 {
     $customer = $this->customerWrapper->loadCustomer();
     $cartFromCustomer = $this->getCustomerCart($customer);
     $cartFromSession = $this->getCartFromSession();
     $this->cart = $this->resolveCarts($customer, $cartFromCustomer, $cartFromSession);
     $this->cartEventDispatcher->dispatchCartLoadEvents($this->cart);
     return $this->cart;
 }
Exemplo n.º 3
0
 /**
  * Get loaded object. If object is not loaded yet, then load it and save it
  * locally. Otherwise, just return the pre-loaded object.
  *
  * @return mixed Loaded object
  */
 public function get()
 {
     if ($this->cart instanceof CartInterface) {
         return $this->cart;
     }
     $customer = $this->customerWrapper->get();
     $cartFromCustomer = $this->getCustomerCart($customer);
     $cartFromSession = $this->cartSessionWrapper->get();
     $this->cart = $this->resolveCarts($customer, $cartFromCustomer, $cartFromSession);
     $this->cartEventDispatcher->dispatchCartLoadEvents($this->cart);
     return $this->cart;
 }