public function addProductToUserShoppingCart(Product $product)
 {
     $customer = $this->customerModel->getCustomer();
     $shoppingCart = new ShoppingCart();
     $shoppingCart->setCustomer($customer);
     $shoppingCart->setProduct($product);
     $this->entityManager->persist($shoppingCart);
     $this->entityManager->flush();
 }
 public function test_create_customer_from_session()
 {
     $sessionid = md5(microtime());
     $session = Mockery::mock('Symfony\\Component\\HttpFoundation\\Session\\Session');
     $session->shouldReceive('getId')->twice()->andReturn($sessionid);
     $customerRepository = Mockery::mock('WebstoreBundle\\Entity\\CustomerRepository');
     $customerRepository->shouldReceive('findOneBySessionId')->once()->andReturn(false);
     $entityManager = Mockery::mock('Doctrine\\ORM\\EntityManager');
     $entityManager->shouldReceive('persist')->once();
     $entityManager->shouldReceive('flush')->once();
     $customerModel = new CustomerModel($session, $customerRepository, $entityManager);
     $customer = $customerModel->getCustomer();
     $this->assertEquals($sessionid, $customer->getSessionId());
 }