Completed
Push — master ( 4f4b30...79d213 )
by Kamil
49:20 queued 33s
created

OrderContext   A

Complexity

Total Complexity 4

Size/Duplication

Total Lines 40
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 2

Importance

Changes 2
Bugs 1 Features 0
Metric Value
wmc 4
c 2
b 1
f 0
lcom 1
cbo 2
dl 0
loc 40
rs 10

3 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 4 1
A iDeleteTheOrder() 0 10 2
A orderShouldNotExistInTheRegistry() 0 7 1
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
namespace Sylius\Behat\Context\Domain;
13
14
use Behat\Behat\Context\Context;
15
use Sylius\Component\Core\Model\OrderInterface;
16
use Sylius\Component\Core\Repository\OrderRepositoryInterface;
17
18
/**
19
 * @author Łukasz Chruściel <[email protected]>
20
 */
21
final class OrderContext implements Context
22
{
23
    /**
24
     * @var OrderRepositoryInterface
25
     */
26
    private $orderRepository;
27
28
    /**
29
     * @param OrderRepositoryInterface $orderRepository
30
     */
31
    public function __construct(OrderRepositoryInterface $orderRepository)
32
    {
33
        $this->orderRepository = $orderRepository;
34
    }
35
36
    /**
37
     * @When I delete the order :orderNumber
38
     */
39
    public function iDeleteTheOrder($orderNumber)
40
    {
41
        /** @var OrderInterface $order */
42
        $order = $this->orderRepository->findOneBy(['number' => $orderNumber]);
43
        if (null === $order) {
44
            throw new \InvalidArgumentException(sprintf('Order with %s number was not found in an order repository', $orderNumber));
45
        }
46
47
        $this->orderRepository->remove($order);
48
    }
49
50
    /**
51
     * @Then /^([^"]+) should not exist in the registry$/
52
     */
53
    public function orderShouldNotExistInTheRegistry(OrderInterface $order)
54
    {
55
        /** @var OrderInterface $order */
56
        $order = $this->orderRepository->find($order->getId());
57
58
        expect($order)->toBe(null);
59
    }
60
}
61