-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
4 changed files
with
52 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
<?php | ||
|
||
namespace Coding; | ||
|
||
class Iteration | ||
{ | ||
private Core $core; | ||
|
||
public function __construct(string $token, Core $core = null) | ||
{ | ||
$this->core = $core ?? new Core($token); | ||
} | ||
|
||
public function create(array $data) | ||
{ | ||
$response = $this->core->request('CreateIteration', $data); | ||
return $response['Iteration']; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
<?php | ||
|
||
namespace Coding\Tests; | ||
|
||
use Coding\Core; | ||
use Coding\Iteration; | ||
|
||
class IterationTest extends TestCase | ||
{ | ||
public function testCreateSuccess() | ||
{ | ||
$coreMock = \Mockery::mock(Core::class, [])->makePartial(); | ||
|
||
$response = json_decode( | ||
file_get_contents($this->dataPath('CreateIterationResponse.json')), | ||
true | ||
)['Response']; | ||
$data = [ | ||
'ProjectName' => $this->projectName, | ||
'Name' => $this->faker->title, | ||
]; | ||
$coreMock->shouldReceive('request')->times(1)->withArgs([ | ||
'CreateIteration', | ||
$data | ||
])->andReturn($response); | ||
|
||
$iteration = new Iteration($this->token, $coreMock); | ||
$result = $iteration->create($data); | ||
$this->assertEquals($response['Iteration'], $result); | ||
} | ||
} |