1
|
|
|
<?php |
2
|
|
|
|
3
|
|
|
/* |
4
|
|
|
* This file is part of the Sylius package. |
5
|
|
|
* |
6
|
|
|
* (c) Paweł Jędrzejewski |
7
|
|
|
* |
8
|
|
|
* For the full copyright and license information, please view the LICENSE |
9
|
|
|
* file that was distributed with this source code. |
10
|
|
|
*/ |
11
|
|
|
|
12
|
|
|
declare(strict_types=1); |
13
|
|
|
|
14
|
|
|
namespace spec\Sylius\Component\Core\Promotion\Updater\Rule; |
15
|
|
|
|
16
|
|
|
use PhpSpec\ObjectBehavior; |
17
|
|
|
use Sylius\Component\Core\Model\PromotionInterface; |
18
|
|
|
use Sylius\Component\Core\Model\TaxonInterface; |
19
|
|
|
use Sylius\Component\Promotion\Model\PromotionRuleInterface; |
20
|
|
|
use Sylius\Component\Resource\Repository\RepositoryInterface; |
21
|
|
|
|
22
|
|
|
final class TotalOfItemsFromTaxonRuleUpdaterSpec extends ObjectBehavior |
23
|
|
|
{ |
24
|
|
|
function let(RepositoryInterface $promotionRuleRepository): void |
25
|
|
|
{ |
26
|
|
|
$this->beConstructedWith($promotionRuleRepository); |
27
|
|
|
} |
28
|
|
|
|
29
|
|
|
function it_removes_rules_that_using_deleted_taxon( |
30
|
|
|
RepositoryInterface $promotionRuleRepository, |
31
|
|
|
PromotionRuleInterface $firstPromotionRule, |
32
|
|
|
PromotionRuleInterface $secondPromotionRule, |
33
|
|
|
PromotionInterface $promotion, |
34
|
|
|
TaxonInterface $taxon |
35
|
|
|
): void { |
36
|
|
|
$taxon->getCode()->willReturn('toys'); |
37
|
|
|
|
38
|
|
|
$promotionRuleRepository |
39
|
|
|
->findBy(['type' => 'total_of_items_from_taxon']) |
40
|
|
|
->willReturn([$firstPromotionRule, $secondPromotionRule]) |
41
|
|
|
; |
42
|
|
|
$firstPromotionRule->getConfiguration()->willReturn(['web' => ['taxon' => 'mugs', 'amount' => 500]]); |
43
|
|
|
$secondPromotionRule->getConfiguration()->willReturn(['web' => ['taxon' => 'toys', 'amount' => 300]]); |
44
|
|
|
|
45
|
|
|
$secondPromotionRule->getPromotion()->willReturn($promotion); |
46
|
|
|
$promotion->getCode()->willReturn('christmas'); |
47
|
|
|
|
48
|
|
|
$promotionRuleRepository->remove($firstPromotionRule)->shouldNotBeCalled(); |
49
|
|
|
$promotionRuleRepository->remove($secondPromotionRule)->shouldBeCalled(); |
50
|
|
|
|
51
|
|
|
$this->updateAfterDeletingTaxon($taxon)->shouldReturn(['christmas']); |
52
|
|
|
} |
53
|
|
|
} |
54
|
|
|
|