-
-
Notifications
You must be signed in to change notification settings - Fork 2.1k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add missing spec for ContainsProductRuleChecker
- Loading branch information
Piotr Walkow
committed
Sep 23, 2015
1 parent
3d24d6f
commit 76ce9ec
Showing
1 changed file
with
96 additions
and
0 deletions.
There are no files selected for viewing
96 changes: 96 additions & 0 deletions
96
src/Sylius/Component/Core/spec/Promotion/Checker/ContainsProductRuleCheckerSpec.php
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,96 @@ | ||
<?php | ||
|
||
/* | ||
* This file is part of the Sylius package. | ||
* | ||
* (c) Paweł Jędrzejewski | ||
* | ||
* For the full copyright and license information, please view the LICENSE | ||
* file that was distributed with this source code. | ||
*/ | ||
|
||
namespace spec\Sylius\Component\Core\Promotion\Checker; | ||
|
||
use PhpSpec\ObjectBehavior; | ||
use Sylius\Component\Core\Model\OrderInterface; | ||
use Sylius\Component\Core\Model\OrderItem; | ||
use Sylius\Component\Core\Model\ProductVariant; | ||
use Sylius\Component\Promotion\Exception\UnsupportedTypeException; | ||
use Sylius\Component\Promotion\Model\PromotionSubjectInterface; | ||
|
||
/** | ||
* @author Piotr Walków <[email protected]> | ||
*/ | ||
class ContainsProductRuleCheckerSpec extends ObjectBehavior | ||
{ | ||
function it_should_be_initializable() | ||
{ | ||
$this->shouldHaveType('Sylius\Component\Core\Promotion\Checker\ContainsProductRuleChecker'); | ||
} | ||
|
||
function it_should_be_Sylius_rule_checker() | ||
{ | ||
$this->shouldImplement('Sylius\Component\Promotion\Checker\RuleCheckerInterface'); | ||
} | ||
|
||
function it_throw_exception_on_invalid_subject(PromotionSubjectInterface $subject) | ||
{ | ||
$this->shouldThrow(UnsupportedTypeException::class)->duringIsEligible($subject, []); | ||
} | ||
|
||
function it_returns_true_if_variant_is_right_and_exclude_is_not_set( | ||
OrderInterface $subject, | ||
OrderItem $orderItem, | ||
ProductVariant $variant | ||
) { | ||
$subject->getItems()->shouldBeCalled(); | ||
$subject->getItems()->willReturn([$orderItem]); | ||
$orderItem->getVariant()->shouldBeCalled(); | ||
$orderItem->getVariant()->willReturn($variant); | ||
$variant->getId()->willReturn(1); | ||
|
||
$this->isEligible($subject, ['variant' => 1, 'exclude' => false])->shouldReturn(true); | ||
} | ||
|
||
function it_returns_false_if_variant_is_right_and_exclude_is_set( | ||
OrderInterface $subject, | ||
OrderItem $orderItem, | ||
ProductVariant $variant | ||
) { | ||
$subject->getItems()->shouldBeCalled(); | ||
$subject->getItems()->willReturn([$orderItem]); | ||
$orderItem->getVariant()->shouldBeCalled(); | ||
$orderItem->getVariant()->willReturn($variant); | ||
$variant->getId()->willReturn(1); | ||
|
||
$this->isEligible($subject, ['variant' => 1, 'exclude' => true])->shouldReturn(false); | ||
} | ||
|
||
function it_returns_true_if_variant_is_not_included_and_exclude_is_not_set( | ||
OrderInterface $subject, | ||
OrderItem $orderItem, | ||
ProductVariant $variant | ||
) { | ||
$subject->getItems()->shouldBeCalled(); | ||
$subject->getItems()->willReturn([$orderItem]); | ||
$orderItem->getVariant()->shouldBeCalled(); | ||
$orderItem->getVariant()->willReturn($variant); | ||
$variant->getId()->willReturn(2); | ||
|
||
$this->isEligible($subject, ['variant' => 1, 'exclude' => true])->shouldReturn(true); | ||
} | ||
|
||
function it_returns_false_if_variant_is_not_included_and_exclude_is_not_set( | ||
OrderInterface $subject, | ||
OrderItem $orderItem, | ||
ProductVariant $variant | ||
) { | ||
$subject->getItems()->shouldBeCalled(); | ||
$subject->getItems()->willReturn([$orderItem]); | ||
$orderItem->getVariant()->shouldBeCalled(); | ||
$orderItem->getVariant()->willReturn($variant); | ||
$variant->getId()->willReturn(2); | ||
|
||
$this->isEligible($subject, ['variant' => 1, 'exclude' => false])->shouldReturn(false); | ||
} | ||
} |