Skip to content

Commit

Permalink
fix: #6 support Autowiring
Browse files Browse the repository at this point in the history
  • Loading branch information
shaunthegeek committed Oct 24, 2021
1 parent 984523c commit f5ffbab
Show file tree
Hide file tree
Showing 4 changed files with 15 additions and 3 deletions.
5 changes: 5 additions & 0 deletions src/Core.php
Original file line number Diff line number Diff line change
Expand Up @@ -34,4 +34,9 @@ public function request(string $action, $data)
}
return $result['Response'];
}

public function setToken(string $token)
{
$this->token = $token;
}
}
7 changes: 6 additions & 1 deletion src/Iteration.php
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ class Iteration
{
private Core $core;

public function __construct(string $token, Core $core = null)
public function __construct(string $token = '', Core $core = null)
{
$this->core = $core ?? new Core($token);
}
Expand All @@ -31,4 +31,9 @@ public function create(array $data)
$response = $this->core->request('CreateIteration', $data);
return $response['Iteration'];
}

public function setToken(string $token)
{
$this->core->setToken($token);
}
}
3 changes: 2 additions & 1 deletion tests/CoreTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,8 @@ public function testRequestFailed()
]
)
->willReturn(new Response(200, [], $responseBody));
$core = new Core($this->token, $this->clientMock);
$core = new Core('', $this->clientMock);
$core->setToken($this->token);
$this->expectException(ApiError::class);
$this->expectExceptionMessage(json_decode($responseBody, true)['Response']['Error']['Message']);
$core->request($action, $data);
Expand Down
3 changes: 2 additions & 1 deletion tests/IterationTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,8 @@ public function testCreateSuccessWithAllParams()
$data
])->andReturn($response);

$iteration = new Iteration($this->token, $coreMock);
$iteration = new Iteration('', $coreMock);
$iteration->setToken($this->token);
$result = $iteration->create($data);
$this->assertEquals($response['Iteration'], $result);
}
Expand Down

0 comments on commit f5ffbab

Please sign in to comment.