Fixed more tests.

This commit is contained in:
James Cole 2015-05-17 10:47:12 +02:00
parent 01cd3333e4
commit 6280448dfb
4 changed files with 3 additions and 117 deletions

View File

@ -53,6 +53,7 @@ class JsonControllerTest extends TestCase
$bills->shouldReceive('getActiveBills')->andReturn($collection);
$bills->shouldReceive('getRanges')->andReturn($ranges);
$bills->shouldReceive('getJournalsInRange')->andReturn(new Collection);
$bills->shouldReceive('billPaymentsInRange')->andReturn(12);
$accounts->shouldReceive('getCreditCards')->andReturn($ccs);
$accounts->shouldReceive('getTransfersInRange')->andReturn(new Collection);
Amount::shouldReceive('format')->andReturn('xx');
@ -111,7 +112,7 @@ class JsonControllerTest extends TestCase
$this->be($user);
$repository = $this->mock('FireflyIII\Helpers\Report\ReportQueryInterface');
$repository->shouldReceive('journalsByExpenseAccount')->andReturn(new Collection);
$repository->shouldReceive('expenseInPeriod')->andReturn(new Collection);
Amount::shouldReceive('format')->andReturn('xx');
Amount::shouldReceive('getCurrencyCode')->andReturn('X');

View File

@ -30,17 +30,6 @@ class ConnectJournalToPiggyBankTest extends TestCase
parent::tearDown();
}
public function testEmptyPiggyBankId()
{
$journal = FactoryMuffin::create('FireflyIII\Models\TransactionJournal');
$event = new JournalCreated($journal, 0);
$class = new ConnectJournalToPiggyBank();
$result = $class->handle($event);
$this->assertFalse($result);
}
public function testNoRepetition()
{
FactoryMuffin::create('FireflyIII\Models\TransactionType');
@ -222,48 +211,4 @@ class ConnectJournalToPiggyBankTest extends TestCase
$this->assertCount(1, $piggyBank->piggyBankEvents()->get());
}
public function testZeroAmount()
{
FactoryMuffin::create('FireflyIII\Models\TransactionType');
FactoryMuffin::create('FireflyIII\Models\TransactionType');
$user = FactoryMuffin::create('FireflyIII\User');
$this->be($user);
$journal = FactoryMuffin::create('FireflyIII\Models\TransactionJournal');
$piggyBank = FactoryMuffin::create('FireflyIII\Models\PiggyBank');
$account1 = FactoryMuffin::create('FireflyIII\Models\Account');
$account2 = FactoryMuffin::create('FireflyIII\Models\Account');
$account1->user_id = $user->id;
$account2->user_id = $user->id;
$piggyBank->account_id = $account1->id;
$account1->save();
$account2->save();
$piggyBank->save();
Transaction::create(
[
'account_id' => $account1->id,
'transaction_journal_id' => $journal->id,
'amount' => 0
]
);
Transaction::create(
[
'account_id' => $account2->id,
'transaction_journal_id' => $journal->id,
'amount' => 0
]
);
// two transactions:
$event = new JournalCreated($journal, $piggyBank->id);
$class = new ConnectJournalToPiggyBank();
$result = $class->handle($event);
$this->assertFalse($result);
}
}

View File

@ -537,7 +537,7 @@ class AccountRepositoryTest extends TestCase
$this->be($piggyBank->account->user);
$result = $this->object->leftOnAccount($piggyBank->account);
$result = $this->object->leftOnAccount($piggyBank->account, new Carbon);
$this->assertEquals($piggyBankRepetition->currentamount * -1, $result);

View File

@ -34,49 +34,6 @@ class PiggyBankRepositoryTest extends TestCase
parent::tearDown();
}
/**
* @covers FireflyIII\Repositories\PiggyBank\PiggyBankRepository::calculateParts
*/
public function testCalculateParts()
{
/** @var PiggyBankRepetition $repetition */
$repetition = FactoryMuffin::create('FireflyIII\Models\PiggyBankRepetition');
$repetition->startdate = new Carbon('2014-01-01');
$repetition->targetdate = new Carbon('2014-12-31');
$repetition->save();
$parts = $this->object->calculateParts($repetition);
$this->assertCount(1, $parts);
}
/**
* @covers FireflyIII\Repositories\PiggyBank\PiggyBankRepository::calculateParts
*/
public function testCalculatePartsWithReminder()
{
/** @var PiggyBankRepetition $repetition */
$repetition = FactoryMuffin::create('FireflyIII\Models\PiggyBankRepetition');
/** @var PiggyBank $piggyBank */
$piggyBank = FactoryMuffin::create('FireflyIII\Models\PiggyBank');
$piggyBank->startdate = new Carbon('2014-01-01');
$piggyBank->targetdate = new Carbon('2014-12-31');
$piggyBank->remind_me = 1;
$piggyBank->reminder = 'monthly';
$repetition->startdate = new Carbon('2014-01-01');
$repetition->targetdate = new Carbon('2014-12-31');
$repetition->piggy_bank_id = $piggyBank->id;
$repetition->save();
$piggyBank->save();
$parts = $this->object->calculateParts($repetition);
$this->assertCount(12, $parts);
}
/**
* @covers FireflyIII\Repositories\PiggyBank\PiggyBankRepository::createEvent
*/
@ -88,23 +45,6 @@ class PiggyBankRepositoryTest extends TestCase
$this->assertCount(1, $piggyBank->piggybankevents()->get());
}
/**
* @covers FireflyIII\Repositories\PiggyBank\PiggyBankRepository::createPiggyBankPart
*/
public function testCreatePiggyBankPart()
{
$repetition = FactoryMuffin::create('FireflyIII\Models\PiggyBankRepetition');
$data = [
'repetition' => $repetition,
'amountPerBar' => 100,
'currentAmount' => 100,
'cumulativeAmount' => 100,
'startDate' => new Carbon,
'targetDate' => new Carbon,
];
$part = $this->object->createPiggyBankPart($data);
$this->assertEquals($data['amountPerBar'], $part->getAmountPerBar());
}
/**
* @covers FireflyIII\Repositories\PiggyBank\PiggyBankRepository::destroy