public function testAddProduct() { $product = $this->dummyData->getProduct(); $inventoryLocation = $this->dummyData->getInventoryLocation($this->warehouse); $initialTransaction = $this->dummyData->getInventoryTransaction($inventoryLocation, $product); $this->entityManager->persist($product); $this->entityManager->persist($inventoryLocation); $this->entityManager->persist($initialTransaction); $this->entityManager->flush(); $this->inventoryService->addProduct($product, 3, $inventoryLocation->getId()); $transactions = $this->inventoryTransactionRepository->findAllByProduct($product); $transactions = $this->getDebitCreditTransactions($transactions); $debitTransaction = $transactions[0]; $creditTransaction = $transactions[1]; $this->assertSame(null, $debitTransaction->getInventoryLocation()); $this->assertTrue($debitTransaction->getType()->isNewProducts()); $this->assertSame(-3, $debitTransaction->getQuantity()); $this->assertSame('Adjusting inventory: New Products', $debitTransaction->getMemo()); $this->assertTrue($creditTransaction->getInventoryLocation() instanceof InventoryLocation); $this->assertTrue($creditTransaction->getType()->isNewProducts()); $this->assertSame(3, $creditTransaction->getQuantity()); $this->assertSame('Adjusting inventory: New Products', $creditTransaction->getMemo()); }