Code cleanup and realign.

This commit is contained in:
James Cole
2018-08-06 19:14:30 +02:00
parent f7eef25fed
commit 5908c0ce8c
188 changed files with 1019 additions and 1031 deletions

View File

@@ -103,40 +103,6 @@ class CurrencyExchangeRateControllerTest extends TestCase
$response->assertHeader('Content-Type', 'application/vnd.api+json');
}
/**
* @covers \FireflyIII\Api\V1\Controllers\CurrencyExchangeRateController
*/
public function testIndexBadSource(): void
{
// mock repository
$repository = $this->mock(CurrencyRepositoryInterface::class);
$service = $this->mock(ExchangeRateInterface::class);
$rate = new CurrencyExchangeRate();
$rate->date = new Carbon();
$rate->updated_at = new Carbon();
$rate->created_at = new Carbon();
$rate->rate = '0.5';
$rate->to_currency_id = 1;
$rate->from_currency_id = 2;
// mock calls:
$repository->shouldReceive('setUser')->once();
$repository->shouldReceive('findByCodeNull')->withArgs(['EUR'])->andReturn(null)->once();
$repository->shouldReceive('findByCodeNull')->withArgs(['USD'])->andReturn(TransactionCurrency::whereCode('USD')->first())->once();
// test API
$params = [
'from' => 'EUR',
'to' => 'USD',
'date' => '2018-01-01',
];
$response = $this->get('/api/v1/cer?' . http_build_query($params), ['Accept' => 'application/json']);
$response->assertStatus(500);
$response->assertSee('Unknown source currency.');
$response->assertHeader('Content-Type', 'application/json');
}
/**
* @covers \FireflyIII\Api\V1\Controllers\CurrencyExchangeRateController
*/
@@ -170,4 +136,38 @@ class CurrencyExchangeRateControllerTest extends TestCase
$response->assertSee('Unknown destination currency.');
$response->assertHeader('Content-Type', 'application/json');
}
/**
* @covers \FireflyIII\Api\V1\Controllers\CurrencyExchangeRateController
*/
public function testIndexBadSource(): void
{
// mock repository
$repository = $this->mock(CurrencyRepositoryInterface::class);
$service = $this->mock(ExchangeRateInterface::class);
$rate = new CurrencyExchangeRate();
$rate->date = new Carbon();
$rate->updated_at = new Carbon();
$rate->created_at = new Carbon();
$rate->rate = '0.5';
$rate->to_currency_id = 1;
$rate->from_currency_id = 2;
// mock calls:
$repository->shouldReceive('setUser')->once();
$repository->shouldReceive('findByCodeNull')->withArgs(['EUR'])->andReturn(null)->once();
$repository->shouldReceive('findByCodeNull')->withArgs(['USD'])->andReturn(TransactionCurrency::whereCode('USD')->first())->once();
// test API
$params = [
'from' => 'EUR',
'to' => 'USD',
'date' => '2018-01-01',
];
$response = $this->get('/api/v1/cer?' . http_build_query($params), ['Accept' => 'application/json']);
$response->assertStatus(500);
$response->assertSee('Unknown source currency.');
$response->assertHeader('Content-Type', 'application/json');
}
}