Skip to content

Commit

Permalink
Approve second code review PR #6
Browse files Browse the repository at this point in the history
  • Loading branch information
peter279k committed Jun 1, 2018
1 parent fc13c82 commit 2cc0eff
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 17 deletions.
2 changes: 1 addition & 1 deletion src/Resource/GetAllRate.php
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,6 @@ public function fetch(ImportConnector $connector): \Iterator

$rates = new \ArrayIterator($response['rates']);

return new AllRatesRecord($rates, $this->base, count($response), $this);
return new AllRatesRecord($rates, $this->base, count($rates), $this);
}
}
2 changes: 1 addition & 1 deletion src/Resource/GetSpecificRate.php
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,6 @@ public function fetch(ImportConnector $connector): \Iterator
true
);

return new \ArrayIterator($response);
return yield $response;
}
}
25 changes: 10 additions & 15 deletions tests/Functional/GetRateTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -17,35 +17,30 @@ final class GetRateTest extends TestCase

public function testGetSpecificRateRecords()
{
/** @var \ArrayIterator $rates */
$rate = FixtureFactory::createPorter()->import(new ImportSpecification(new GetSpecificRate($this->apiKey)));
$rate = FixtureFactory::createPorter()->importOne(new ImportSpecification(new GetSpecificRate($this->apiKey)));

$this->assertCount(1, $rate);

$rateRecords = iterator_to_array($rate);

foreach($rateRecords as $rateRecord) {
$this->assertArrayHasKey('asset_id_base', $rateRecord);
$this->assertArrayHasKey('asset_id_quote', $rateRecord);
$this->assertArrayHasKey('rate', $rateRecord);
$this->assertArrayHasKey('time', $rateRecord);
}
$this->assertArrayHasKey('asset_id_base', $rate[0]);
$this->assertArrayHasKey('asset_id_quote', $rate[0]);
$this->assertArrayHasKey('rate', $rate[0]);
$this->assertArrayHasKey('time', $rate[0]);
}

public function testGetAllRateRecords()
{
/** @var AllRatesRecord $rates */
$rates = FixtureFactory::createPorter()->import(new ImportSpecification(new GetAllRate($this->apiKey)));

$rates = $rates->findFirstCollection();
$rateRecords = iterator_to_array($rates);
$this->assertCount(1267, $rates);

$this->assertSame('BTC', $rates->getBase());

foreach ($rateRecords as $rateRecord) {
foreach ($rates as $rateRecord) {
$this->assertArrayHasKey('asset_id_quote', $rateRecord);
$this->assertArrayHasKey('rate', $rateRecord);
$this->assertArrayHasKey('time', $rateRecord);
}

$rates = $rates->findFirstCollection();
$this->assertSame('BTC', $rates->getBase());
}
}

0 comments on commit 2cc0eff

Please sign in to comment.