mirror of
https://github.com/firefly-iii/firefly-iii.git
synced 2025-01-05 21:53:08 -06:00
Tested part of the journal repository.
This commit is contained in:
parent
84e8e007a5
commit
10e54b2263
@ -137,7 +137,7 @@ class JournalRepository implements JournalRepositoryInterface
|
|||||||
*/
|
*/
|
||||||
public function getWithDate($id, Carbon $date)
|
public function getWithDate($id, Carbon $date)
|
||||||
{
|
{
|
||||||
return Auth::user()->transactionjournals()->where('id', $id)->where('date', $date->format('Y-m-d'))->first();
|
return Auth::user()->transactionjournals()->where('id', $id)->where('date', $date->format('Y-m-d 00:00:00'))->first();
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -1,5 +1,10 @@
|
|||||||
<?php
|
<?php
|
||||||
|
use FireflyIII\Models\Reminder;
|
||||||
|
use FireflyIII\Models\Transaction;
|
||||||
|
use FireflyIII\Models\TransactionJournal;
|
||||||
use FireflyIII\Repositories\Journal\JournalRepository;
|
use FireflyIII\Repositories\Journal\JournalRepository;
|
||||||
|
use Illuminate\Pagination\LengthAwarePaginator;
|
||||||
|
use League\FactoryMuffin\Facade as FactoryMuffin;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Generated by PHPUnit_SkeletonGenerator on 2015-05-05 at 19:19:32.
|
* Generated by PHPUnit_SkeletonGenerator on 2015-05-05 at 19:19:32.
|
||||||
@ -32,122 +37,162 @@ class JournalRepositoryTest extends TestCase
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* @covers FireflyIII\Repositories\Journal\JournalRepository::deactivateReminder
|
* @covers FireflyIII\Repositories\Journal\JournalRepository::deactivateReminder
|
||||||
* @todo Implement testDeactivateReminder().
|
|
||||||
*/
|
*/
|
||||||
public function testDeactivateReminder()
|
public function testDeactivateReminder()
|
||||||
{
|
{
|
||||||
// Remove the following lines when you implement this test.
|
$reminder = FactoryMuffin::create('FireflyIII\Models\Reminder');
|
||||||
$this->markTestIncomplete(
|
$reminder->active = 1;
|
||||||
'This test has not been implemented yet.'
|
$reminder->save();
|
||||||
);
|
$this->be($reminder->user);
|
||||||
|
|
||||||
|
$this->object->deactivateReminder($reminder->id);
|
||||||
|
|
||||||
|
$this->assertEquals(1, Reminder::where('id', $reminder->id)->where('active', 0)->count());
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @covers FireflyIII\Repositories\Journal\JournalRepository::delete
|
* @covers FireflyIII\Repositories\Journal\JournalRepository::delete
|
||||||
* @todo Implement testDelete().
|
|
||||||
*/
|
*/
|
||||||
public function testDelete()
|
public function testDelete()
|
||||||
{
|
{
|
||||||
// Remove the following lines when you implement this test.
|
$journal = FactoryMuffin::create('FireflyIII\Models\TransactionJournal');
|
||||||
$this->markTestIncomplete(
|
$account = FactoryMuffin::create('FireflyIII\Models\Account');
|
||||||
'This test has not been implemented yet.'
|
$transaction = Transaction::create(
|
||||||
|
[
|
||||||
|
'account_id' => $account->id,
|
||||||
|
'transaction_journal_id' => $journal->id,
|
||||||
|
'amount' => 100,
|
||||||
|
]
|
||||||
);
|
);
|
||||||
|
|
||||||
|
$this->object->delete($journal);
|
||||||
|
|
||||||
|
$this->assertEquals(0, TransactionJournal::where('id', $journal->id)->whereNull('deleted_at')->count());
|
||||||
|
$this->assertEquals(0, Transaction::where('id', $transaction->id)->whereNull('deleted_at')->count());
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @covers FireflyIII\Repositories\Journal\JournalRepository::first
|
* @covers FireflyIII\Repositories\Journal\JournalRepository::first
|
||||||
* @todo Implement testFirst().
|
|
||||||
*/
|
*/
|
||||||
public function testFirst()
|
public function testFirst()
|
||||||
{
|
{
|
||||||
// Remove the following lines when you implement this test.
|
$journal = FactoryMuffin::create('FireflyIII\Models\TransactionJournal');
|
||||||
$this->markTestIncomplete(
|
$this->be($journal->user);
|
||||||
'This test has not been implemented yet.'
|
|
||||||
);
|
$first = $this->object->first();
|
||||||
|
|
||||||
|
$this->assertEquals($journal->id, $first->id);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @covers FireflyIII\Repositories\Journal\JournalRepository::getAmountBefore
|
* @covers FireflyIII\Repositories\Journal\JournalRepository::getAmountBefore
|
||||||
* @todo Implement testGetAmountBefore().
|
|
||||||
*/
|
*/
|
||||||
public function testGetAmountBefore()
|
public function testGetAmountBefore()
|
||||||
{
|
{
|
||||||
// Remove the following lines when you implement this test.
|
$transaction = FactoryMuffin::create('FireflyIII\Models\Transaction');
|
||||||
$this->markTestIncomplete(
|
$before = $this->object->getAmountBefore($transaction->transactionjournal, $transaction);
|
||||||
'This test has not been implemented yet.'
|
|
||||||
);
|
$this->assertEquals(0, $before);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @covers FireflyIII\Repositories\Journal\JournalRepository::getJournalsOfType
|
* @covers FireflyIII\Repositories\Journal\JournalRepository::getJournalsOfType
|
||||||
* @todo Implement testGetJournalsOfType().
|
|
||||||
*/
|
*/
|
||||||
public function testGetJournalsOfType()
|
public function testGetJournalsOfType()
|
||||||
{
|
{
|
||||||
// Remove the following lines when you implement this test.
|
$user = FactoryMuffin::create('FireflyIII\User');
|
||||||
$this->markTestIncomplete(
|
$type = FactoryMuffin::create('FireflyIII\Models\TransactionType');
|
||||||
'This test has not been implemented yet.'
|
$this->be($user);
|
||||||
);
|
$result = $this->object->getJournalsOfType($type);
|
||||||
|
$this->assertCount(0, $result);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @covers FireflyIII\Repositories\Journal\JournalRepository::getJournalsOfTypes
|
* @covers FireflyIII\Repositories\Journal\JournalRepository::getJournalsOfTypes
|
||||||
* @todo Implement testGetJournalsOfTypes().
|
|
||||||
*/
|
*/
|
||||||
public function testGetJournalsOfTypes()
|
public function testGetJournalsOfTypes()
|
||||||
{
|
{
|
||||||
// Remove the following lines when you implement this test.
|
FactoryMuffin::create('FireflyIII\Models\TransactionType');
|
||||||
$this->markTestIncomplete(
|
FactoryMuffin::create('FireflyIII\Models\TransactionType');
|
||||||
'This test has not been implemented yet.'
|
FactoryMuffin::create('FireflyIII\Models\TransactionType');
|
||||||
);
|
$user = FactoryMuffin::create('FireflyIII\User');
|
||||||
|
$this->be($user);
|
||||||
|
$types = ['Withdrawal', 'Expense'];
|
||||||
|
$set = $this->object->getJournalsOfTypes($types, 0, 1);
|
||||||
|
|
||||||
|
$this->assertTrue($set instanceof LengthAwarePaginator);
|
||||||
|
$this->assertEquals(1, $set->currentPage());
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @covers FireflyIII\Repositories\Journal\JournalRepository::getTransactionType
|
* @covers FireflyIII\Repositories\Journal\JournalRepository::getTransactionType
|
||||||
* @todo Implement testGetTransactionType().
|
|
||||||
*/
|
*/
|
||||||
public function testGetTransactionType()
|
public function testGetTransactionType()
|
||||||
{
|
{
|
||||||
// Remove the following lines when you implement this test.
|
$type = FactoryMuffin::create('FireflyIII\Models\TransactionType');
|
||||||
$this->markTestIncomplete(
|
$otherType = $this->object->getTransactionType($type->type);
|
||||||
'This test has not been implemented yet.'
|
$this->assertEquals($type->id, $otherType->id);
|
||||||
);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @covers FireflyIII\Repositories\Journal\JournalRepository::getWithDate
|
* @covers FireflyIII\Repositories\Journal\JournalRepository::getWithDate
|
||||||
* @todo Implement testGetWithDate().
|
|
||||||
*/
|
*/
|
||||||
public function testGetWithDate()
|
public function testGetWithDate()
|
||||||
{
|
{
|
||||||
// Remove the following lines when you implement this test.
|
$journal = FactoryMuffin::create('FireflyIII\Models\TransactionJournal');
|
||||||
$this->markTestIncomplete(
|
$this->be($journal->user);
|
||||||
'This test has not been implemented yet.'
|
|
||||||
);
|
$found = $this->object->getWithDate($journal->id, $journal->date);
|
||||||
|
|
||||||
|
$this->assertEquals($journal->id, $found->id);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @covers FireflyIII\Repositories\Journal\JournalRepository::saveTags
|
* @covers FireflyIII\Repositories\Journal\JournalRepository::saveTags
|
||||||
* @todo Implement testSaveTags().
|
|
||||||
*/
|
*/
|
||||||
public function testSaveTags()
|
public function testSaveTags()
|
||||||
{
|
{
|
||||||
// Remove the following lines when you implement this test.
|
$journal = FactoryMuffin::create('FireflyIII\Models\TransactionJournal');
|
||||||
$this->markTestIncomplete(
|
$tags = ['one', 'two', 'three'];
|
||||||
'This test has not been implemented yet.'
|
$this->be($journal->user);
|
||||||
);
|
|
||||||
|
$this->object->saveTags($journal, $tags);
|
||||||
|
|
||||||
|
$this->assertCount(3, $journal->tags()->get());
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @covers FireflyIII\Repositories\Journal\JournalRepository::store
|
* @covers FireflyIII\Repositories\Journal\JournalRepository::store
|
||||||
* @todo Implement testStore().
|
* @covers FireflyIII\Repositories\Journal\JournalRepository::storeAccounts
|
||||||
*/
|
*/
|
||||||
public function testStore()
|
public function testStore()
|
||||||
{
|
{
|
||||||
// Remove the following lines when you implement this test.
|
FactoryMuffin::create('FireflyIII\Models\TransactionType');
|
||||||
$this->markTestIncomplete(
|
$currency = FactoryMuffin::create('FireflyIII\Models\TransactionCurrency');
|
||||||
'This test has not been implemented yet.'
|
$budget = FactoryMuffin::create('FireflyIII\Models\Budget');
|
||||||
);
|
$account1 = FactoryMuffin::create('FireflyIII\Models\Account');
|
||||||
|
$user = FactoryMuffin::create('FireflyIII\User');
|
||||||
|
$data = [
|
||||||
|
'description' => 'Some journal ' . rand(1, 100),
|
||||||
|
'user' => $user->id,
|
||||||
|
'what' => 'withdrawal',
|
||||||
|
'amount_currency_id' => $currency->id,
|
||||||
|
'account_id' => $account1->id,
|
||||||
|
'expense_account' => 'Some expense account',
|
||||||
|
'date' => '2014-01-01',
|
||||||
|
'category' => 'Some category',
|
||||||
|
'budget_id' => $budget->id,
|
||||||
|
'amount' => 100,
|
||||||
|
'tags' => ['one', 'two', 'three']
|
||||||
|
|
||||||
|
|
||||||
|
];
|
||||||
|
|
||||||
|
$journal = $this->object->store($data);
|
||||||
|
|
||||||
|
$this->assertEquals($data['description'], $journal->description);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
Loading…
Reference in New Issue
Block a user