File tree 4 files changed +52
-1
lines changed
4 files changed +52
-1
lines changed Original file line number Diff line number Diff line change 9
9
},
10
10
"require-dev" : {
11
11
"fakerphp/faker" : " ^1.16" ,
12
+ "mockery/mockery" : " ^1.4" ,
12
13
"phpmd/phpmd" : " ^2.10" ,
13
14
"phpunit/phpunit" : " ^9.5" ,
14
15
"squizlabs/php_codesniffer" : " ^3.6"
Original file line number Diff line number Diff line change @@ -9,7 +9,7 @@ class Core
9
9
protected string $ token ;
10
10
protected Client $ client ;
11
11
12
- public function __construct (string $ token , Client $ client = null )
12
+ public function __construct (string $ token = '' , Client $ client = null )
13
13
{
14
14
$ this ->token = $ token ;
15
15
$ this ->client = $ client ?? new Client ();
Original file line number Diff line number Diff line change
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
+ }
Original file line number Diff line number Diff line change
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
+ }
You can’t perform that action at this time.
0 commit comments