public function matches(CartItem $cartItem)
 {
     if ($cartItem->getProduct()->getId() == $this->product->getId() and $cartItem->getQuantity() >= $this->quantity) {
         return true;
     }
     return false;
 }
示例#2
0
 public function testRandWithSeed()
 {
     $qb = $this->entityManager->createQueryBuilder();
     $randomProducts = $qb->select('Product')->from(Product::class, 'Product')->addSelect('RAND(:rand) as HIDDEN rand')->orderBy('rand')->setParameter('rand', crc32($this->product1->getId()))->getQuery()->getResult();
     $this->assertSame(3, count($randomProducts));
     $this->assertTrue(in_array($this->product1, $randomProducts));
     $this->assertTrue(in_array($this->product2, $randomProducts));
     $this->assertTrue(in_array($this->product3, $randomProducts));
 }
示例#3
0
 public function testCreateDefaults()
 {
     $product = new Product();
     $this->assertTrue($product->getId() instanceof UuidInterface);
     $this->assertTrue($product->getCreated() instanceof DateTime);
     $this->assertSame(null, $product->getSku());
     $this->assertSame(null, $product->getName());
     $this->assertSame(null, $product->getDescription());
     $this->assertSame(null, $product->getDefaultImage());
     $this->assertSame(0, $product->getUnitPrice());
     $this->assertSame(0, $product->getQuantity());
     $this->assertSame(0, $product->getShippingWeight());
     $this->assertSame(null, $product->getRating());
     $this->assertFalse($product->isInventoryRequired());
     $this->assertFalse($product->isPriceVisible());
     $this->assertFalse($product->isActive());
     $this->assertFalse($product->isVisible());
     $this->assertFalse($product->isTaxable());
     $this->assertFalse($product->isShippable());
     $this->assertSame(0, count($product->getTags()));
     $this->assertSame(0, count($product->getImages()));
     $this->assertSame(0, count($product->getProductQuantityDiscounts()));
     $this->assertSame(0, count($product->getOptionProducts()));
     $this->assertSame(0, count($product->getProductAttributes()));
 }
 /**
  * @param Product $product
  * @return InventoryTransaction[]
  */
 public function findAllByProduct(Product $product)
 {
     return $this->getQueryBuilder()->select('InventoryTransaction')->from(InventoryTransaction::class, 'InventoryTransaction')->where('InventoryTransaction.product = :productId')->setIdParameter('productId', $product->getId())->getQuery()->getResult();
 }