示例#1
0
 public function testGetCartWithExistingCartAndCustomerAndReferencesEachOther()
 {
     $session = $this->session;
     //create a fake customer just for test. If not persists test fails !
     $customer = new Customer();
     $customer->setFirstname("john test session");
     $customer->setLastname("doe");
     $customer->setTitleId(1);
     $customer->save();
     $session->setCustomerUser($customer);
     $testCart = new Cart();
     $testCart->setToken(uniqid("testSessionGetCart3", true));
     $testCart->setCustomerId($customer->getId());
     $testCart->save();
     $this->request->cookies->set(ConfigQuery::read("cart.cookie_name", 'thelia_cart'), $testCart->getToken());
     $cart = $session->getSessionCart($this->dispatcher);
     $this->assertNotNull($cart);
     $this->assertInstanceOf("\\Thelia\\Model\\Cart", $cart, '$cart must be an instance of Thelia\\Model\\Cart');
 }