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 Doctrine\ORM\EntityManagerInterface; |
17
|
|
|
use PhpSpec\ObjectBehavior; |
18
|
|
|
use Prophecy\Argument; |
19
|
|
|
use Sylius\Component\Core\Model\PromotionInterface; |
20
|
|
|
use Sylius\Component\Core\Model\TaxonInterface; |
21
|
|
|
use Sylius\Component\Promotion\Model\PromotionRuleInterface; |
22
|
|
|
use Sylius\Component\Resource\Repository\RepositoryInterface; |
23
|
|
|
|
24
|
|
|
final class HasTaxonRuleUpdaterSpec extends ObjectBehavior |
25
|
|
|
{ |
26
|
|
|
function let(RepositoryInterface $promotionRuleRepository, EntityManagerInterface $manager): void |
27
|
|
|
{ |
28
|
|
|
$this->beConstructedWith($promotionRuleRepository, $manager); |
29
|
|
|
} |
30
|
|
|
|
31
|
|
|
function it_removes_deleted_taxon_from_rules_configurations( |
32
|
|
|
RepositoryInterface $promotionRuleRepository, |
33
|
|
|
EntityManagerInterface $manager, |
34
|
|
|
PromotionRuleInterface $firstPromotionRule, |
35
|
|
|
PromotionRuleInterface $secondPromotionRule, |
36
|
|
|
PromotionInterface $promotion, |
37
|
|
|
TaxonInterface $taxon |
38
|
|
|
): void { |
39
|
|
|
$taxon->getCode()->willReturn('toys'); |
40
|
|
|
|
41
|
|
|
$promotionRuleRepository |
42
|
|
|
->findBy(['type' => 'has_taxon']) |
43
|
|
|
->willReturn([$firstPromotionRule, $secondPromotionRule]) |
44
|
|
|
; |
45
|
|
|
$firstPromotionRule->getConfiguration()->willReturn(['taxons' => ['mugs', 'toys']]); |
46
|
|
|
$secondPromotionRule->getConfiguration()->willReturn(['taxons' => ['mugs']]); |
47
|
|
|
|
48
|
|
|
$firstPromotionRule->getPromotion()->willReturn($promotion); |
49
|
|
|
$promotion->getCode()->willReturn('christmas'); |
50
|
|
|
|
51
|
|
|
$firstPromotionRule->setConfiguration(['taxons' => ['mugs']])->shouldBeCalled(); |
52
|
|
|
$secondPromotionRule->setConfiguration(Argument::any())->shouldNotBeCalled(); |
53
|
|
|
|
54
|
|
|
$manager->flush()->shouldBeCalled(); |
55
|
|
|
|
56
|
|
|
$this->updateAfterDeletingTaxon($taxon)->shouldReturn(['christmas']); |
57
|
|
|
} |
58
|
|
|
} |
59
|
|
|
|