Skip to content

Commit 77cfd7b

Browse files
-
1 parent 844d7cc commit 77cfd7b

File tree

4 files changed

+79
-31
lines changed

4 files changed

+79
-31
lines changed

src/Model/CallRequestModel.php

Lines changed: 13 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ class CallRequestModel extends AbstractAppModel
1515
public function __construct()
1616
{
1717
$this->method = 'GET';
18-
$this->options = ['query' => [], 'body' => false, 'json' => []];
18+
$this->options = ['query' => [], 'json' => [], 'body' => false];
1919
}
2020

2121
public function getMethod(): ?string
@@ -57,40 +57,38 @@ public function setOptions(?array $options): self
5757
return $this;
5858
}
5959

60-
public function setQuery(?array $query): self
60+
public function getQuery(): ?array
6161
{
62-
$this->options['query'] = $query;
63-
64-
return $this;
62+
return $this->options['query'];
6563
}
6664

67-
public function setHeaders(?array $headers): self
65+
public function setQuery(?array $query): self
6866
{
69-
$this->options['headers'] = $headers;
67+
$this->options['query'] = $query;
7068

7169
return $this;
7270
}
7371

74-
public function getBody(): ?string
72+
public function getJson(): ?array
7573
{
76-
return $this->options['body'];
74+
return $this->options['json'];
7775
}
7876

79-
public function setBody(?string $body): self
77+
public function setJson(?array $json): self
8078
{
81-
$this->options['body'] = $body;
79+
$this->options['json'] = $json;
8280

8381
return $this;
8482
}
8583

86-
public function getJson(): ?array
84+
public function getBody(): ?string
8785
{
88-
return $this->options['json'];
86+
return $this->options['body'];
8987
}
9088

91-
public function setJson(?array $json): self
89+
public function setBody(?string $body): self
9290
{
93-
$this->options['json'] = $json;
91+
$this->options['body'] = $body;
9492

9593
return $this;
9694
}

src/Model/CallResponseModel.php

Lines changed: 2 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -12,14 +12,12 @@ class CallResponseModel extends AbstractAppModel
1212

1313
private $contentRaw;
1414

15-
private $error;
16-
17-
public function getCode(): ?string
15+
public function getCode(): ?int
1816
{
1917
return $this->code;
2018
}
2119

22-
public function setCode(?string $code): self
20+
public function setCode(?int $code): self
2321
{
2422
$this->code = $code;
2523

@@ -49,16 +47,4 @@ public function setContentRaw(?string $contentRaw): self
4947

5048
return $this;
5149
}
52-
53-
public function getError(): ?string
54-
{
55-
return $this->error;
56-
}
57-
58-
public function setError(?string $error): self
59-
{
60-
$this->error;
61-
62-
return $this;
63-
}
6450
}

tests/Model/CallRequestModelTest.php

Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
1+
<?php
2+
3+
namespace App\Tests\Model;
4+
5+
use App\Model\CallRequestModel;
6+
use PHPUnit\Framework\TestCase;
7+
8+
class CallRequestModelTest extends TestCase
9+
{
10+
public function test()
11+
{
12+
$callRequest = new CallRequestModel();
13+
$callRequest->setMethod('method');
14+
$callRequest->setPath('path');
15+
$callRequest->setOptions([]);
16+
$callRequest->setQuery(['query']);
17+
$callRequest->setJson(['json']);
18+
$callRequest->setBody('body');
19+
20+
$this->assertEquals($callRequest->getMethod(), 'method');
21+
$this->assertIsString($callRequest->getMethod());
22+
23+
$this->assertEquals($callRequest->getPath(), '/path');
24+
$this->assertIsString($callRequest->getPath());
25+
26+
$this->assertEquals($callRequest->getOptions(), ['query' => ['query'], 'json' => ['json'], 'body' => 'body']);
27+
$this->assertIsArray($callRequest->getOptions());
28+
29+
$this->assertEquals($callRequest->getQuery(), ['query']);
30+
$this->assertIsArray($callRequest->getQuery());
31+
32+
$this->assertEquals($callRequest->getJson(), ['json']);
33+
$this->assertIsArray($callRequest->getJson());
34+
35+
$this->assertEquals($callRequest->getBody(), 'body');
36+
$this->assertIsString($callRequest->getBody());
37+
}
38+
}

tests/Model/CallResponseModelTest.php

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
<?php
2+
3+
namespace App\Tests\Model;
4+
5+
use App\Model\CallResponseModel;
6+
use PHPUnit\Framework\TestCase;
7+
8+
class CallResponseModelTest extends TestCase
9+
{
10+
public function test()
11+
{
12+
$callResponse = new CallResponseModel();
13+
$callResponse->setCode(200);
14+
$callResponse->setContent(['content']);
15+
$callResponse->setContentRaw('content-raw');
16+
17+
$this->assertEquals($callResponse->getCode(), 200);
18+
$this->assertIsNumeric($callResponse->getCode());
19+
20+
$this->assertEquals($callResponse->getContent(), ['content']);
21+
$this->assertIsArray($callResponse->getContent());
22+
23+
$this->assertEquals($callResponse->getContentRaw(), 'content-raw');
24+
$this->assertIsString($callResponse->getContentRaw());
25+
}
26+
}

0 commit comments

Comments
 (0)