Passed
Push — master ( 45ebeb...19a947 )
by Fabian
02:58
created

RateLimitReachedTest::testRetryAfterHeader()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 16
Code Lines 10

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
eloc 10
c 1
b 0
f 0
dl 0
loc 16
rs 9.9332
cc 1
nc 1
nop 0
1
<?php
2
namespace LE_ACME2Tests\Exception;
3
4
use LE_ACME2;
5
use LE_ACME2Tests\Connector\RawResponse;
6
use LE_ACME2Tests\EnhancedTestCase;
7
8
class RateLimitReachedTest extends EnhancedTestCase {
9
10
    /**
11
     * @covers LE_ACME2\Exception\RateLimitReached
12
     * @covers LE_ACME2\Response\AbstractResponse::_isRateLimitReached
13
     * @covers LE_ACME2\Response\AbstractResponse::__construct
14
     *
15
     * @return void
16
     */
17
    public function test() {
18
19
        $raw = RawResponse::createDummyFrom(
20
            'HTTP/2 429 Too many requests' . "\r\n",
21
            '{
22
    "type": "urn:ietf:params:acme:error:rateLimited",
23
    "detail": "Service busy; retry later."
24
}',
25
        );
26
27
        /** @var LE_ACME2\Exception\RateLimitReached $exception */
28
        $exception = $this->catchExpectedException(LE_ACME2\Exception\RateLimitReached::class, function() use($raw) {
29
            new LE_ACME2\Response\GetDirectory($raw);
30
        });
31
        $this->assertIsObject($exception);
32
        $this->assertTrue(get_class($exception) == LE_ACME2\Exception\RateLimitReached::class);
33
    }
34
}