ValidateBasketTest::__construct()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 13
Code Lines 10

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
cc 1
eloc 10
nc 1
nop 3
dl 0
loc 13
rs 9.4285
c 0
b 0
f 0
1
<?php
2
/**
3
 * Created by PhpStorm.
4
 * User: imhotek
5
 * Date: 10/12/17
6
 * Time: 13:50
7
 */
8
9
namespace OpenTickets\Tickets\Domain\Service\Basket;
10
11
use ConferenceTools\Tickets\Domain\Service\Basket\ValidateBasket;
12
use ConferenceTools\Tickets\Domain\Service\Configuration;
13
use ConferenceTools\Tickets\Domain\ValueObject\Basket;
14
use ConferenceTools\Tickets\Domain\ValueObject\TicketReservation;
15
use PHPUnit\Framework\TestCase;
16
17
class ValidateBasketTest extends TestCase
18
{
19
    /**
20
     * @var Configuration
21
     */
22
    private $config;
23
24
    public function __construct($name = null, array $data = array(), $dataName = '')
25
    {
26
        parent::__construct($name, $data, $dataName);
27
        $this->config = Configuration::fromArray([
28
            'tickets' => [
29
                'early' => ['name' => 'Early Bird', 'cost' => 5000, 'available' => 75],
30
                'std' => ['name' => 'Standard', 'cost' => 10000, 'available' => 150],
31
                'free' => ['name' => 'Free', 'cost' => 0, 'available' => 100, 'metadata' => ['private' => true]]
32
            ],
33
            'financial' => [
34
                'taxRate' => 10,
35
                'currency' => 'GBP',
36
                'displayTax' => true
37
            ]
38
        ]);
39
    }
40
41
    public function testValidateThrowsOnEmptyBasket()
42
    {
43
        $sut = new ValidateBasket();
44
45
        $this->expectException(\DomainException::class);
46
        $this->expectExceptionMessage('You must choose at least 1 ticket to purchase');
47
48
        Basket::fromReservations(
49
            $this->config,
50
            $sut
51
        );
52
    }
53
54
    public function testValidate()
55
    {
56
        $sut = new ValidateBasket();
57
58
        Basket::fromReservations(
59
            $this->config,
60
            $sut,
61
            new TicketReservation(
62
                $this->config->getTicketType('std'),
63
                'id1'
64
            )
65
        );
66
    }
67
}
68