Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit 49fce56

Browse files
feat: #4 create iteration
1 parent 2de53a4 commit 49fce56

File tree

4 files changed

+52
-1
lines changed

4 files changed

+52
-1
lines changed

‎composer.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@
99
},
1010
"require-dev": {
1111
"fakerphp/faker": "^1.16",
12+
"mockery/mockery": "^1.4",
1213
"phpmd/phpmd": "^2.10",
1314
"phpunit/phpunit": "^9.5",
1415
"squizlabs/php_codesniffer": "^3.6"

‎src/Core.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ class Core
99
protected string $token;
1010
protected Client $client;
1111

12-
public function __construct(string $token, Client $client = null)
12+
public function __construct(string $token = '', Client $client = null)
1313
{
1414
$this->token = $token;
1515
$this->client = $client ?? new Client();

‎src/Iteration.php

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
<?php
2+
3+
namespace Coding;
4+
5+
class Iteration
6+
{
7+
private Core $core;
8+
9+
public function __construct(string $token, Core $core = null)
10+
{
11+
$this->core = $core ?? new Core($token);
12+
}
13+
14+
public function create(array $data)
15+
{
16+
$response = $this->core->request('CreateIteration', $data);
17+
return $response['Iteration'];
18+
}
19+
}

‎tests/IterationTest.php

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
<?php
2+
3+
namespace Coding\Tests;
4+
5+
use Coding\Core;
6+
use Coding\Iteration;
7+
8+
class IterationTest extends TestCase
9+
{
10+
public function testCreateSuccess()
11+
{
12+
$coreMock = \Mockery::mock(Core::class, [])->makePartial();
13+
14+
$response = json_decode(
15+
file_get_contents($this->dataPath('CreateIterationResponse.json')),
16+
true
17+
)['Response'];
18+
$data = [
19+
'ProjectName' => $this->projectName,
20+
'Name' => $this->faker->title,
21+
];
22+
$coreMock->shouldReceive('request')->times(1)->withArgs([
23+
'CreateIteration',
24+
$data
25+
])->andReturn($response);
26+
27+
$iteration = new Iteration($this->token, $coreMock);
28+
$result = $iteration->create($data);
29+
$this->assertEquals($response['Iteration'], $result);
30+
}
31+
}

0 commit comments

Comments
(0)

AltStyle によって変換されたページ (->オリジナル) /