Improve test coverage.

This commit is contained in:
James Cole
2019-07-31 16:53:09 +02:00
parent 5524941c90
commit 9b574ce7ad
155 changed files with 1890 additions and 2263 deletions

View File

@@ -67,7 +67,7 @@ class StageImportDataHandlerTest extends TestCase
{
$job = new ImportJob;
$job->user_id = $this->user()->id;
$job->key = 'sidh_bbunq_' . random_int(1, 10000);
$job->key = 'sidh_bbunq_' . $this->randomInt();
$job->status = 'new';
$job->stage = 'new';
$job->provider = 'bunq';
@@ -117,7 +117,7 @@ class StageImportDataHandlerTest extends TestCase
$payment = new BunqPayment($amount, $pointer, 'Some descr', null, null);
$payment->setAmount($amount);
$payment->setCounterpartyAlias($labelMonetaryAccount);
$payment->setDescription('Random description #' . random_int(1, 10000));
$payment->setDescription('Random description #' . $this->randomInt());
$value = [$payment];
$list = new BunqResponsePaymentList($value, [], null);
@@ -216,7 +216,7 @@ class StageImportDataHandlerTest extends TestCase
// {
// $job = new ImportJob;
// $job->user_id = $this->user()->id;
// $job->key = 'sidA_bbunq_' . random_int(1, 10000);
// $job->key = 'sidA_bbunq_' . $this->randomInt();
// $job->status = 'new';
// $job->stage = 'new';
// $job->provider = 'bunq';
@@ -290,7 +290,7 @@ class StageImportDataHandlerTest extends TestCase
// {
// $job = new ImportJob;
// $job->user_id = $this->user()->id;
// $job->key = 'sidh_bbunq_' . random_int(1, 10000);
// $job->key = 'sidh_bbunq_' . $this->randomInt();
// $job->status = 'new';
// $job->stage = 'new';
// $job->provider = 'bunq';
@@ -344,7 +344,7 @@ class StageImportDataHandlerTest extends TestCase
//
// $payment = new BunqPayment($amount, $pointer, 'Some descr', null, null);
// $payment->setAmount($amount);
// $payment->setDescription('Some random thing #' . random_int(1, 10000));
// $payment->setDescription('Some random thing #' . $this->randomInt());
// $payment->setCounterpartyAlias($labelMonetaryAccount);
// $value = [$payment];
// $list = new BunqResponsePaymentList($value, [], null);
@@ -427,7 +427,7 @@ class StageImportDataHandlerTest extends TestCase
// {
// $job = new ImportJob;
// $job->user_id = $this->user()->id;
// $job->key = 'sidh_bbunq_' . random_int(1, 10000);
// $job->key = 'sidh_bbunq_' . $this->randomInt();
// $job->status = 'new';
// $job->stage = 'new';
// $job->provider = 'bunq';
@@ -477,7 +477,7 @@ class StageImportDataHandlerTest extends TestCase
// $payment = new BunqPayment($amount, $pointer, 'Some descr', null, null);
// $payment->setAmount($amount);
// $payment->setCounterpartyAlias($labelMonetaryAccount);
// $payment->setDescription('Random transfer #' . random_int(1, 10000));
// $payment->setDescription('Random transfer #' . $this->randomInt());
// $value = [$payment];
// $list = new BunqResponsePaymentList($value, [], null);
//

View File

@@ -67,7 +67,7 @@ class StageNewHandlerTest extends TestCase
{
$job = new ImportJob;
$job->user_id = $this->user()->id;
$job->key = 'snh_bunq_' . random_int(1, 10000);
$job->key = 'snh_bunq_' . $this->randomInt();
$job->status = 'new';
$job->stage = 'new';
$job->provider = 'bunq';
@@ -154,7 +154,7 @@ class StageNewHandlerTest extends TestCase
{
$job = new ImportJob;
$job->user_id = $this->user()->id;
$job->key = 'snha_bunq_' . random_int(1, 10000);
$job->key = 'snha_bunq_' . $this->randomInt();
$job->status = 'new';
$job->stage = 'new';
$job->provider = 'bunq';
@@ -246,7 +246,7 @@ class StageNewHandlerTest extends TestCase
{
$job = new ImportJob;
$job->user_id = $this->user()->id;
$job->key = 'snh_bbunq_' . random_int(1, 10000);
$job->key = 'snh_bbunq_' . $this->randomInt();
$job->status = 'new';
$job->stage = 'new';
$job->provider = 'bunq';

View File

@@ -87,8 +87,8 @@ class ImportableConverterTest extends TestCase
$accountRepos->shouldReceive('setUser')->once();
// get default currency
$euro = TransactionCurrency::whereCode('EUR')->first();
$usd = TransactionCurrency::whereCode('USD')->first();
$euro = $this->getEuro();
$usd = $this->getDollar();
Amount::shouldReceive('getDefaultCurrencyByUser')->andReturn($euro)->once();
// set user and config:
@@ -113,9 +113,9 @@ class ImportableConverterTest extends TestCase
$result = $converter->convert($importables);
// verify content of $result
$this->assertEquals('withdrawal', $result[0]['type']);
$this->assertEquals('2018-09-17 00:00:00', $result[0]['date']);
$this->assertEquals($importable->tags, $result[0]['tags']);
$this->assertEquals('withdrawal', $result[0]['transactions'][0]['type']);
$this->assertEquals('2018-09-17 00:00:00', $result[0]['transactions'][0]['date']);
$this->assertEquals($importable->tags, $result[0]['transactions'][0]['tags']);
$this->assertEquals($usd->id, $result[0]['transactions'][0]['currency_id']);
}
@@ -176,9 +176,9 @@ class ImportableConverterTest extends TestCase
// verify content of $result
$today = new Carbon();
$this->assertEquals('transfer', $result[0]['type']);
$this->assertEquals($today->format('Y-m-d H:i:s'), $result[0]['date']);
$this->assertEquals([], $result[0]['tags']);
$this->assertEquals('transfer', $result[0]['transactions'][0]['type']);
$this->assertEquals($today->format('Y-m-d H:i:s'), $result[0]['transactions'][0]['date']);
$this->assertEquals([], $result[0]['transactions'][0]['tags']);
$this->assertEquals($euro->id, $result[0]['transactions'][0]['currency_id']);
}
@@ -237,13 +237,13 @@ class ImportableConverterTest extends TestCase
$result = $converter->convert($importables);
// verify content of $result
$this->assertEquals('deposit', $result[0]['type']);
$this->assertEquals('2018-09-17 00:00:00', $result[0]['date']);
$this->assertEquals([], $result[0]['tags']);
$this->assertEquals('deposit', $result[0]['transactions'][0]['type']);
$this->assertEquals('2018-09-17 00:00:00', $result[0]['transactions'][0]['date']);
$this->assertEquals([], $result[0]['transactions'][0]['tags']);
$this->assertEquals($usd->id, $result[0]['transactions'][0]['currency_id']);
$this->assertEquals($revenue->id, $result[0]['transactions'][0]['source_id']);
$this->assertEquals($asset->id, $result[0]['transactions'][0]['destination_id']);
$this->assertEquals('2018-01-02 00:00:00', $result[0]['book_date']);
$this->assertEquals('2018-01-02 00:00:00', $result[0]['transactions'][0]['book_date']);
}
@@ -361,11 +361,11 @@ class ImportableConverterTest extends TestCase
$result = $converter->convert($importables);
// verify content of $result
$this->assertEquals('transfer', $result[0]['type']);
$this->assertEquals('2018-09-17 00:00:00', $result[0]['date']);
$this->assertEquals([], $result[0]['tags']);
$this->assertEquals(2, $result[0]['bill_id']); // will NOT be ignored.
$this->assertEquals($importable->billName, $result[0]['bill_name']);
$this->assertEquals('transfer', $result[0]['transactions'][0]['type']);
$this->assertEquals('2018-09-17 00:00:00', $result[0]['transactions'][0]['date']);
$this->assertEquals([], $result[0]['transactions'][0]['tags']);
$this->assertEquals(2, $result[0]['transactions'][0]['bill_id']); // will NOT be ignored.
$this->assertEquals($importable->billName, $result[0]['transactions'][0]['bill_name']);
$this->assertEquals($usd->id, $result[0]['transactions'][0]['currency_id']);
// since amount is positive, $asset recieves the money
@@ -434,11 +434,11 @@ class ImportableConverterTest extends TestCase
$result = $converter->convert($importables);
// verify content of $result
$this->assertEquals('transfer', $result[0]['type']);
$this->assertEquals('2018-09-17 00:00:00', $result[0]['date']);
$this->assertEquals([], $result[0]['tags']);
$this->assertEquals(3, $result[0]['bill_id']);
$this->assertEquals($importable->billName, $result[0]['bill_name']);
$this->assertEquals('transfer', $result[0]['transactions'][0]['type']);
$this->assertEquals('2018-09-17 00:00:00', $result[0]['transactions'][0]['date']);
$this->assertEquals([], $result[0]['transactions'][0]['tags']);
$this->assertEquals(3, $result[0]['transactions'][0]['bill_id']);
$this->assertEquals($importable->billName, $result[0]['transactions'][0]['bill_name']);
$this->assertEquals($usd->id, $result[0]['transactions'][0]['currency_id']);
// since amount is negative, $asset sends the money

View File

@@ -55,7 +55,7 @@ class LineReaderTest extends TestCase
{
$job = new ImportJob;
$job->user_id = $this->user()->id;
$job->key = 'linerA' . random_int(1, 10000);
$job->key = 'linerA' . $this->randomInt();
$job->status = 'new';
$job->stage = 'new';
$job->provider = 'fake';

View File

@@ -132,7 +132,7 @@ class MappingConvergerTest extends TestCase
$job = new ImportJob;
$job->user_id = $this->user()->id;
$job->key = 'linerB' . random_int(1, 10000);
$job->key = 'linerB' . $this->randomInt();
$job->status = 'new';
$job->stage = 'new';
$job->provider = 'fake';

View File

@@ -72,16 +72,16 @@ class OpposingAccountMapperTest extends TestCase
*/
public function testAccountIdBadType(): void
{
$expected = $this->user()->accounts()->where('account_type_id', 5)->inRandomOrder()->first();
$expected = $this->getRandomRevenue();
$expected->iban = null;
$expected->save();
$amount = '-12.34';
$expectedArgs = [
'name' => $expected->name,
'iban' => null,
'accountNumber' => null,
'account_number' => null,
'account_type_id' => null,
'accountType' => AccountType::EXPENSE,
'account_type' => AccountType::EXPENSE,
'active' => true,
'BIC' => null,
];
@@ -116,9 +116,9 @@ class OpposingAccountMapperTest extends TestCase
$expectedArgs = [
'name' => $expected->name,
'iban' => $expected->iban,
'accountNumber' => null,
'account_number' => null,
'account_type_id' => null,
'accountType' => AccountType::EXPENSE,
'account_type' => AccountType::EXPENSE,
'active' => true,
'BIC' => null,
];
@@ -152,9 +152,9 @@ class OpposingAccountMapperTest extends TestCase
$expectedArgs = [
'name' => '(no name)',
'iban' => null,
'accountNumber' => null,
'account_number' => null,
'account_type_id' => null,
'accountType' => AccountType::EXPENSE,
'account_type' => AccountType::EXPENSE,
'active' => true,
'BIC' => null,
];
@@ -184,9 +184,9 @@ class OpposingAccountMapperTest extends TestCase
$expectedArgs = [
'name' => '(no name)',
'iban' => null,
'accountNumber' => null,
'account_number' => null,
'account_type_id' => null,
'accountType' => AccountType::REVENUE,
'account_type' => AccountType::REVENUE,
'active' => true,
'BIC' => null,
];

View File

@@ -122,7 +122,7 @@ class StageAuthenticatedHandlerTest extends TestCase
$job = new ImportJob;
$job->user_id = $this->user()->id;
$job->key = 'sa_a_' . random_int(1, 10000);
$job->key = 'sa_a_' . $this->randomInt();
$job->status = 'new';
$job->stage = 'new';
$job->provider = 'spectre';
@@ -251,7 +251,7 @@ class StageAuthenticatedHandlerTest extends TestCase
$job = new ImportJob;
$job->user_id = $this->user()->id;
$job->key = 'sa_a_' . random_int(1, 10000);
$job->key = 'sa_a_' . $this->randomInt();
$job->status = 'new';
$job->stage = 'new';
$job->provider = 'spectre';
@@ -380,7 +380,7 @@ class StageAuthenticatedHandlerTest extends TestCase
$job = new ImportJob;
$job->user_id = $this->user()->id;
$job->key = 'sa_a_' . random_int(1, 10000);
$job->key = 'sa_a_' . $this->randomInt();
$job->status = 'new';
$job->stage = 'new';
$job->provider = 'spectre';

View File

@@ -325,7 +325,7 @@ class StageImportDataHandlerTest extends TestCase
$revenue = $this->user()->accounts()->where('account_type_id', 5)->first();
$job = new ImportJob;
$job->user_id = $this->user()->id;
$job->key = 'sid_a_' . random_int(1, 10000);
$job->key = 'sid_a_' . $this->randomInt();
$job->status = 'new';
$job->stage = 'new';
$job->provider = 'spectre';
@@ -524,7 +524,7 @@ class StageImportDataHandlerTest extends TestCase
$revenue = $this->user()->accounts()->where('account_type_id', 5)->first();
$job = new ImportJob;
$job->user_id = $this->user()->id;
$job->key = 'sid_a_' . random_int(1, 10000);
$job->key = 'sid_a_' . $this->randomInt();
$job->status = 'new';
$job->stage = 'new';
$job->provider = 'spectre';

View File

@@ -67,7 +67,7 @@ class StageNewHandlerTest extends TestCase
{
$job = new ImportJob;
$job->user_id = $this->user()->id;
$job->key = 'sn_a_' . random_int(1, 10000);
$job->key = 'sn_a_' . $this->randomInt();
$job->status = 'new';
$job->stage = 'new';
$job->provider = 'spectre';
@@ -134,7 +134,7 @@ class StageNewHandlerTest extends TestCase
{
$job = new ImportJob;
$job->user_id = $this->user()->id;
$job->key = 'sn_a_' . random_int(1, 10000);
$job->key = 'sn_a_' . $this->randomInt();
$job->status = 'new';
$job->stage = 'new';
$job->provider = 'spectre';
@@ -187,7 +187,7 @@ class StageNewHandlerTest extends TestCase
{
$job = new ImportJob;
$job->user_id = $this->user()->id;
$job->key = 'sn_a_' . random_int(1, 10000);
$job->key = 'sn_a_' . $this->randomInt();
$job->status = 'new';
$job->stage = 'new';
$job->provider = 'spectre';
@@ -256,7 +256,7 @@ class StageNewHandlerTest extends TestCase
{
$job = new ImportJob;
$job->user_id = $this->user()->id;
$job->key = 'sn_a_' . random_int(1, 10000);
$job->key = 'sn_a_' . $this->randomInt();
$job->status = 'new';
$job->stage = 'new';
$job->provider = 'spectre';