Passed
Branch master (fc5382)
by Fabian
03:13
created

OrderTest   A

Complexity

Total Complexity 6

Size/Duplication

Total Lines 60
Duplicated Lines 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
wmc 6
eloc 27
dl 0
loc 60
rs 10
c 1
b 0
f 0

3 Methods

Rating   Name   Duplication   Size   Complexity  
A testCreate() 0 19 2
A testUmlautsCreate() 0 19 2
A testNonExisting() 0 12 2
1
<?php
2
namespace LE_ACME2Tests;
3
4
/**
5
 * @covers \LE_ACME2\Order
6
 */
7
class OrderTest extends AbstractTest {
8
9
    public function testNonExisting() {
10
11
        $account = \LE_ACME2\Account::get($this->_accountEmail);
12
13
        if(\LE_ACME2\Order::exists($account, $this->_orderSubjects)) {
14
            $this->markTestSkipped('Skipped: Order does already exist');
15
        }
16
17
        $this->assertTrue(!\LE_ACME2\Order::exists($account, $this->_orderSubjects));
18
19
        $this->expectException(\RuntimeException::class);
20
        \LE_ACME2\Order::get($account, $this->_orderSubjects);
21
    }
22
23
    public function testCreate() {
24
25
        $account = \LE_ACME2\Account::get($this->_accountEmail);
26
27
        if(\LE_ACME2\Order::exists($account, $this->_orderSubjects)) {
28
            // Skipping order modification tests, when the order already exists
29
            // to reduce the LE api usage while developing
30
            TestHelper::getInstance()->setSkipOrderModificationTests(true);
0 ignored issues
show
Bug introduced by
It seems like setSkipOrderModificationTests() must be provided by classes using this trait. How about adding it as abstract method to this trait? ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-call  annotation

30
            TestHelper::getInstance()->/** @scrutinizer ignore-call */ setSkipOrderModificationTests(true);
Loading history...
31
            $this->markTestSkipped('Order modifications skipped: Order does already exist');
32
        }
33
34
        $this->assertTrue(!\LE_ACME2\Order::exists($account, $this->_orderSubjects));
35
36
        $order = \LE_ACME2\Order::create($account, $this->_orderSubjects);
37
        $this->assertTrue(is_object($order));
38
        $this->assertTrue(count(array_diff($order->getSubjects(), $this->_orderSubjects)) == 0);
39
40
        $order = \LE_ACME2\Order::get($account, $this->_orderSubjects);
41
        $this->assertTrue(is_object($order));
42
43
        // TODO: Order replacement?
44
        //$result = $order->get();
45
        //$this->assertTrue($result->getStatus() === \LE_ACME2\Response\Account\AbstractAccount::STATUS_VALID);
46
    }
47
48
    public function testUmlautsCreate() {
49
50
        $account = \LE_ACME2\Account::get($this->_accountEmail);
51
52
        if(\LE_ACME2\Order::exists($account, $this->_umlautsOrderSubjects)) {
53
            // Skipping order modification tests, when the order already exists
54
            // to reduce the LE api usage while developing
55
            TestHelper::getInstance()->setSkipOrderModificationTests(true);
56
            $this->markTestSkipped('Order modifications skipped: Order does already exist');
57
        }
58
59
        $this->assertTrue(!\LE_ACME2\Order::exists($account, $this->_umlautsOrderSubjects));
60
61
        $order = \LE_ACME2\Order::create($account, $this->_umlautsOrderSubjects);
62
        $this->assertTrue(is_object($order));
63
        $this->assertTrue(count(array_diff($order->getSubjects(), $this->_umlautsOrderSubjects)) == 0);
64
65
        $order = \LE_ACME2\Order::get($account, $this->_umlautsOrderSubjects);
66
        $this->assertTrue(is_object($order));
67
68
        // TODO: Order replacement?
69
        //$result = $order->get();
70
        //$this->assertTrue($result->getStatus() === \LE_ACME2\Response\Account\AbstractAccount::STATUS_VALID);
71
    }
72
}