public function testLoadCatalogPromotions() { $originalCatalogPromotion = $this->dummyData->getCatalogPromotion(); $catalogPromotionRepository = $this->mockRepository->getCatalogPromotionRepository(); $catalogPromotionRepository->shouldreceive('findAll')->andReturn([$originalCatalogPromotion])->once(); $this->pricing->loadCatalogPromotions($catalogPromotionRepository); $catalogPromotions = $this->pricing->getCatalogPromotions(); $this->assertEntitiesEqual($originalCatalogPromotion, $catalogPromotions[0]); }
private function calculateCatalogPromotions() { foreach ($this->pricing->getCatalogPromotions() as $catalogPromotion) { if ($catalogPromotion->isValid($this->pricing->getDate(), $this->product)) { $this->price->unitPrice = $catalogPromotion->getUnitPrice($this->price->unitPrice); $this->price->addCatalogPromotion($catalogPromotion); } } // No prices below zero! $this->price->unitPrice = max(0, $this->price->unitPrice); }