Fix tests.

This commit is contained in:
James Cole
2018-04-14 21:21:20 +02:00
parent 15a22f0bfc
commit 62b68c6a21
6 changed files with 74 additions and 105 deletions

View File

@@ -140,6 +140,7 @@ class BillControllerTest extends TestCase
$repository->shouldReceive('getPaginator')->andReturn(new LengthAwarePaginator($collection, 1, 50))->once();
$repository->shouldReceive('setUser');
$repository->shouldReceive('getPaidDatesInRange')->twice()->andReturn(new Collection([new Carbon, new Carbon, new Carbon]));
$repository->shouldReceive('getRulesForBills')->andReturn([]);
$this->be($this->user());
@@ -159,10 +160,8 @@ class BillControllerTest extends TestCase
$journal = factory(TransactionJournal::class)->make();
$journalRepos = $this->mock(JournalRepositoryInterface::class);
$repository = $this->mock(BillRepositoryInterface::class);
$repository->shouldReceive('getPossiblyRelatedJournals')->once()->andReturn(new Collection([$journal]));
$repository->shouldReceive('scan')->once();
$journalRepos->shouldReceive('first')->once()->andReturn(new TransactionJournal);
$repository->shouldReceive('getRulesForBill')->andReturn(new Collection);
$this->be($this->user());
$response = $this->get(route('bills.rescan', [1]));
$response->assertStatus(302);
@@ -199,6 +198,7 @@ class BillControllerTest extends TestCase
$repository->shouldReceive('getYearAverage')->andReturn('0');
$repository->shouldReceive('getOverallAverage')->andReturn('0');
$repository->shouldReceive('nextExpectedMatch')->andReturn(new Carbon);
$repository->shouldReceive('getRulesForBill')->andReturn(new Collection);
$journalRepos->shouldReceive('first')->once()->andReturn(new TransactionJournal);
$collector->shouldReceive('setAllAssetAccounts')->andReturnSelf();
@@ -235,15 +235,14 @@ class BillControllerTest extends TestCase
$attachHelper->shouldReceive('getMessages')->andReturn(new MessageBag);
$data = [
'name' => 'New Bill ' . random_int(1000, 9999),
'match' => 'some words',
'amount_min' => '100',
'amount_currency_id_amount_min' => 1,
'amount_currency_id_amount_max' => 1,
'skip' => 0,
'amount_max' => '100',
'date' => '2016-01-01',
'repeat_freq' => 'monthly',
'name' => 'New Bill ' . random_int(1000, 9999),
'amount_min' => '100',
'transaction_currency_id' => 1,
'skip' => 0,
'strict' => 1,
'amount_max' => '100',
'date' => '2016-01-01',
'repeat_freq' => 'monthly',
];
$this->session(['bills.create.uri' => 'http://localhost']);
$this->be($this->user());
@@ -271,10 +270,8 @@ class BillControllerTest extends TestCase
$data = [
'id' => 1,
'name' => 'Updated Bill ' . random_int(1000, 9999),
'match' => 'some more words',
'amount_min' => '100',
'amount_currency_id_amount_min' => 1,
'amount_currency_id_amount_max' => 1,
'transaction_currency_id' => 1,
'skip' => 0,
'amount_max' => '100',
'date' => '2016-01-01',

View File

@@ -42,16 +42,16 @@ class BillFactoryTest extends TestCase
public function testCreateBasic()
{
$data = [
'name' => 'Some new bill #' . random_int(1, 1000),
'match' => 'i,am,word' . random_int(1, 1000),
'amount_min' => '5',
'amount_max' => '10',
'date' => '2018-01-01',
'repeat_freq' => 'monthly',
'skip' => 0,
'automatch' => true,
'active' => true,
'notes' => 'Hello!',
'name' => 'Some new bill #' . random_int(1, 1000),
'amount_min' => '5',
'transaction_currency_id' => 1,
'amount_max' => '10',
'date' => '2018-01-01',
'repeat_freq' => 'monthly',
'skip' => 0,
'automatch' => true,
'active' => true,
'notes' => 'Hello!',
];
/** @var BillFactory $factory */
@@ -60,7 +60,6 @@ class BillFactoryTest extends TestCase
$bill = $factory->create($data);
$this->assertEquals($data['name'], $bill->name);
$this->assertEquals($data['match'], $bill->match);
$this->assertEquals($data['amount_min'], $bill->amount_min);
$this->assertEquals($data['repeat_freq'], $bill->repeat_freq);
$note = $bill->notes()->first();
@@ -77,16 +76,16 @@ class BillFactoryTest extends TestCase
public function testCreateEmptyNotes()
{
$data = [
'name' => 'Some new bill #' . random_int(1, 1000),
'match' => 'i,am,word' . random_int(1, 1000),
'amount_min' => '5',
'amount_max' => '10',
'date' => '2018-01-01',
'repeat_freq' => 'monthly',
'skip' => 0,
'automatch' => true,
'active' => true,
'notes' => '',
'name' => 'Some new bill #' . random_int(1, 1000),
'amount_min' => '5',
'amount_max' => '10',
'date' => '2018-01-01',
'repeat_freq' => 'monthly',
'transaction_currency_id' => 1,
'skip' => 0,
'automatch' => true,
'active' => true,
'notes' => '',
];
/** @var BillFactory $factory */
@@ -95,7 +94,6 @@ class BillFactoryTest extends TestCase
$bill = $factory->create($data);
$this->assertEquals($data['name'], $bill->name);
$this->assertEquals($data['match'], $bill->match);
$this->assertEquals($data['amount_min'], $bill->amount_min);
$this->assertEquals($data['repeat_freq'], $bill->repeat_freq);
$this->assertEquals(0, $bill->notes()->count());

View File

@@ -49,15 +49,16 @@ class BillTransformerTest extends TestCase
$bill = Bill::create(
[
'user_id' => $this->user()->id,
'name' => 'Some bill ' . random_int(1, 10000),
'match' => 'word,' . random_int(1, 10000),
'amount_min' => 12.34,
'amount_max' => 45.67,
'date' => '2018-01-02',
'repeat_freq' => 'weekly',
'skip' => 0,
'active' => 1,
'user_id' => $this->user()->id,
'name' => 'Some bill ' . random_int(1, 10000),
'match' => 'word,' . random_int(1, 10000),
'amount_min' => 12.34,
'amount_max' => 45.67,
'transaction_currency_id' => 1,
'date' => '2018-01-02',
'repeat_freq' => 'weekly',
'skip' => 0,
'active' => 1,
]
);
$transformer = new BillTransformer(new ParameterBag);
@@ -77,15 +78,16 @@ class BillTransformerTest extends TestCase
$bill = Bill::create(
[
'user_id' => $this->user()->id,
'name' => 'Some bill ' . random_int(1, 10000),
'match' => 'word,' . random_int(1, 10000),
'amount_min' => 12.34,
'amount_max' => 45.67,
'date' => '2018-01-02',
'repeat_freq' => 'weekly',
'skip' => 0,
'active' => 1,
'user_id' => $this->user()->id,
'name' => 'Some bill ' . random_int(1, 10000),
'match' => 'word,' . random_int(1, 10000),
'amount_min' => 12.34,
'amount_max' => 45.67,
'date' => '2018-01-02',
'transaction_currency_id' => 1,
'repeat_freq' => 'weekly',
'skip' => 0,
'active' => 1,
]
);
$noteText = 'I are a note ' . random_int(1, 10000);
@@ -121,15 +123,16 @@ class BillTransformerTest extends TestCase
$repository->shouldReceive('getPaidDatesInRange')->andReturn(new Collection([new Carbon('2018-01-02')]));
$bill = Bill::create(
[
'user_id' => $this->user()->id,
'name' => 'Some bill ' . random_int(1, 10000),
'match' => 'word,' . random_int(1, 10000),
'amount_min' => 12.34,
'amount_max' => 45.67,
'date' => '2018-01-02',
'repeat_freq' => 'monthly',
'skip' => 0,
'active' => 1,
'user_id' => $this->user()->id,
'name' => 'Some bill ' . random_int(1, 10000),
'match' => 'word,' . random_int(1, 10000),
'amount_min' => 12.34,
'amount_max' => 45.67,
'date' => '2018-01-02',
'transaction_currency_id' => 1,
'repeat_freq' => 'monthly',
'skip' => 0,
'active' => 1,
]
);
$parameters = new ParameterBag();