Skip to content

Commit f5ffbab

Browse files
committed
fix: #6 support Autowiring
1 parent 984523c commit f5ffbab

File tree

4 files changed

+15
-3
lines changed

4 files changed

+15
-3
lines changed

src/Core.php

+5
Original file line numberDiff line numberDiff line change
@@ -34,4 +34,9 @@ public function request(string $action, $data)
3434
}
3535
return $result['Response'];
3636
}
37+
38+
public function setToken(string $token)
39+
{
40+
$this->token = $token;
41+
}
3742
}

src/Iteration.php

+6-1
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ class Iteration
99
{
1010
private Core $core;
1111

12-
public function __construct(string $token, Core $core = null)
12+
public function __construct(string $token = '', Core $core = null)
1313
{
1414
$this->core = $core ?? new Core($token);
1515
}
@@ -31,4 +31,9 @@ public function create(array $data)
3131
$response = $this->core->request('CreateIteration', $data);
3232
return $response['Iteration'];
3333
}
34+
35+
public function setToken(string $token)
36+
{
37+
$this->core->setToken($token);
38+
}
3439
}

tests/CoreTest.php

+2-1
Original file line numberDiff line numberDiff line change
@@ -61,7 +61,8 @@ public function testRequestFailed()
6161
]
6262
)
6363
->willReturn(new Response(200, [], $responseBody));
64-
$core = new Core($this->token, $this->clientMock);
64+
$core = new Core('', $this->clientMock);
65+
$core->setToken($this->token);
6566
$this->expectException(ApiError::class);
6667
$this->expectExceptionMessage(json_decode($responseBody, true)['Response']['Error']['Message']);
6768
$core->request($action, $data);

tests/IterationTest.php

+2-1
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,8 @@ public function testCreateSuccessWithAllParams()
5252
$data
5353
])->andReturn($response);
5454

55-
$iteration = new Iteration($this->token, $coreMock);
55+
$iteration = new Iteration('', $coreMock);
56+
$iteration->setToken($this->token);
5657
$result = $iteration->create($data);
5758
$this->assertEquals($response['Iteration'], $result);
5859
}

0 commit comments

Comments
 (0)