PluginProbe ʕ •ᴥ•ʔ
Booking for Appointments and Events Calendar – Amelia / 2.4.4
Booking for Appointments and Events Calendar – Amelia v2.4.4
2.4.4 2.4.3 2.4.2 2.4.1 2.4 trunk 1.2.1 1.2.10 1.2.11 1.2.12 1.2.13 1.2.14 1.2.15 1.2.16 1.2.17 1.2.18 1.2.19 1.2.2 1.2.20 1.2.21 1.2.22 1.2.23 1.2.24 1.2.25 1.2.26 1.2.27 1.2.28 1.2.29 1.2.3 1.2.30 1.2.31 1.2.32 1.2.33 1.2.34 1.2.35 1.2.36 1.2.37 1.2.38 1.2.4 1.2.5 1.2.6 1.2.7 1.2.8 1.2.9 2.0 2.0.1 2.0.2 2.1 2.1.1 2.1.2 2.1.3 2.2 2.2.1 2.3
ameliabooking / vendor / apimatic / core / src / TestCase / StatusCodeMatcher.php
ameliabooking / vendor / apimatic / core / src / TestCase Last commit date
BodyMatchers 1 year ago CoreTestCase.php 1 year ago HeadersMatcher.php 1 year ago StatusCodeMatcher.php 1 year ago TestParam.php 1 year ago
StatusCodeMatcher.php
71 lines
1 <?php
2
3 declare(strict_types=1);
4
5 namespace Core\TestCase;
6
7 use PHPUnit\Framework\TestCase;
8
9 class StatusCodeMatcher
10 {
11 /**
12 * @var int|null
13 */
14 private $statusCode;
15
16 /**
17 * @var int|null
18 */
19 private $lowerStatusCode;
20
21 /**
22 * @var int|null
23 */
24 private $upperStatusCode;
25 private $assertStatusRange = false;
26 private $testCase;
27
28 /**
29 * Creates a new StatusCodeMatcher object.
30 */
31 public function __construct(TestCase $testCase)
32 {
33 $this->testCase = $testCase;
34 }
35
36 /**
37 * Sets statusCode of the object to the value provided.
38 */
39 public function setStatusCode(int $statusCode): void
40 {
41 $this->statusCode = $statusCode;
42 }
43
44 /**
45 * Sets an expected status code range. Used in case the test case expects a status from a range of status codes.
46 */
47 public function setStatusRange(int $lowerStatusCode, int $upperStatusCode): void
48 {
49 $this->assertStatusRange = true;
50 $this->lowerStatusCode = $lowerStatusCode;
51 $this->upperStatusCode = $upperStatusCode;
52 }
53
54 /**
55 * Assert required assertions according to the properties set within the object.
56 */
57 public function assert(int $statusCode)
58 {
59 if (isset($this->statusCode)) {
60 $this->testCase->assertEquals($this->statusCode, $statusCode, "Status is not $this->statusCode");
61 return;
62 }
63 if (!$this->assertStatusRange) {
64 return;
65 }
66 $message = "Status is not between $this->lowerStatusCode and $this->upperStatusCode";
67 $this->testCase->assertGreaterThanOrEqual($this->lowerStatusCode, $statusCode, $message);
68 $this->testCase->assertLessThanOrEqual($this->upperStatusCode, $statusCode, $message);
69 }
70 }
71