fbett /
le-acme2-php
| 1 | <?php |
||
| 2 | namespace LE_ACME2Tests; |
||
| 3 | |||
| 4 | /** |
||
| 5 | * @covers \LE_ACME2\Order |
||
| 6 | */ |
||
| 7 | class OrderTest extends AbstractLeAcme2TestCase { |
||
| 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->assertFalse(\LE_ACME2\Order::exists($account, $this->_orderSubjects)); |
||
| 18 | $this->assertFalse(\LE_ACME2\Order::existsCertificateBundle($account, $this->_orderSubjects)); |
||
| 19 | |||
| 20 | $this->catchExpectedException( |
||
| 21 | \RuntimeException::class, |
||
| 22 | function() use($account) { |
||
| 23 | \LE_ACME2\Order::get($account, $this->_orderSubjects); |
||
| 24 | } |
||
| 25 | ); |
||
| 26 | } |
||
| 27 | |||
| 28 | public function testCreate() { |
||
| 29 | |||
| 30 | $account = \LE_ACME2\Account::get($this->_accountEmail); |
||
| 31 | |||
| 32 | if(\LE_ACME2\Order::exists($account, $this->_orderSubjects)) { |
||
| 33 | // Skipping order modification tests, when the order already exists |
||
| 34 | // to reduce the LE api usage while developing |
||
| 35 | TestHelper::getInstance()->setSkipOrderModificationTests(true); |
||
|
0 ignored issues
–
show
Bug
introduced
by
Loading history...
|
|||
| 36 | $this->markTestSkipped('Order modifications skipped: Order does already exist'); |
||
| 37 | } |
||
| 38 | |||
| 39 | $this->assertTrue(!\LE_ACME2\Order::exists($account, $this->_orderSubjects)); |
||
| 40 | |||
| 41 | $order = \LE_ACME2\Order::create($account, $this->_orderSubjects); |
||
| 42 | $this->assertTrue(is_object($order)); |
||
| 43 | $this->assertTrue(count(array_diff($order->getSubjects(), $this->_orderSubjects)) == 0); |
||
| 44 | |||
| 45 | $order = \LE_ACME2\Order::get($account, $this->_orderSubjects); |
||
| 46 | $this->assertTrue(is_object($order)); |
||
| 47 | |||
| 48 | // TODO: Order replacement? |
||
| 49 | //$result = $order->get(); |
||
| 50 | //$this->assertTrue($result->getStatus() === \LE_ACME2\Response\Account\AbstractAccount::STATUS_VALID); |
||
| 51 | } |
||
| 52 | |||
| 53 | public function testUmlautsCreate() { |
||
| 54 | |||
| 55 | $account = \LE_ACME2\Account::get($this->_accountEmail); |
||
| 56 | |||
| 57 | if(\LE_ACME2\Order::exists($account, $this->_umlautsOrderSubjects)) { |
||
| 58 | // Skipping order modification tests, when the order already exists |
||
| 59 | // to reduce the LE api usage while developing |
||
| 60 | TestHelper::getInstance()->setSkipOrderModificationTests(true); |
||
| 61 | $this->markTestSkipped('Order modifications skipped: Order does already exist'); |
||
| 62 | } |
||
| 63 | |||
| 64 | $this->assertTrue(!\LE_ACME2\Order::exists($account, $this->_umlautsOrderSubjects)); |
||
| 65 | |||
| 66 | $order = \LE_ACME2\Order::create($account, $this->_umlautsOrderSubjects); |
||
| 67 | $this->assertTrue(is_object($order)); |
||
| 68 | $this->assertTrue(count(array_diff($order->getSubjects(), $this->_umlautsOrderSubjects)) == 0); |
||
| 69 | |||
| 70 | $order = \LE_ACME2\Order::get($account, $this->_umlautsOrderSubjects); |
||
| 71 | $this->assertTrue(is_object($order)); |
||
| 72 | |||
| 73 | // TODO: Order replacement? |
||
| 74 | //$result = $order->get(); |
||
| 75 | //$this->assertTrue($result->getStatus() === \LE_ACME2\Response\Account\AbstractAccount::STATUS_VALID); |
||
| 76 | } |
||
| 77 | } |