mirror of
https://github.com/firefly-iii/firefly-iii.git
synced 2025-02-25 18:45:27 -06:00
Fix tests.
This commit is contained in:
parent
af8df75e49
commit
378b4abaf1
@ -53,6 +53,7 @@ class BudgetControllerTest extends TestCase
|
||||
$journalRepos = $this->mock(JournalRepositoryInterface::class);
|
||||
$journalRepos->shouldReceive('first')->once()->andReturn(new TransactionJournal);
|
||||
$repository->shouldReceive('updateLimitAmount')->andReturn(new BudgetLimit);
|
||||
$repository->shouldReceive('spentInPeriod')->andReturn('0');
|
||||
|
||||
$data = ['amount' => 200, 'start' => '2017-01-01', 'end' => '2017-01-31'];
|
||||
$this->be($this->user());
|
||||
@ -70,6 +71,7 @@ class BudgetControllerTest extends TestCase
|
||||
$journalRepos = $this->mock(JournalRepositoryInterface::class);
|
||||
$journalRepos->shouldReceive('first')->once()->andReturn(new TransactionJournal);
|
||||
$repository->shouldReceive('updateLimitAmount')->andReturn(new BudgetLimit);
|
||||
$repository->shouldReceive('spentInPeriod')->andReturn('0');
|
||||
|
||||
$data = ['amount' => 0, 'start' => '2017-01-01', 'end' => '2017-01-31'];
|
||||
$this->be($this->user());
|
||||
|
@ -26,7 +26,7 @@ use FireflyIII\Models\RuleAction;
|
||||
use FireflyIII\Models\TransactionJournal;
|
||||
use FireflyIII\TransactionRules\Actions\RemoveAllTags;
|
||||
use Tests\TestCase;
|
||||
|
||||
use DB;
|
||||
/**
|
||||
* Class RemoveAllTagsTest
|
||||
*/
|
||||
@ -38,14 +38,11 @@ class RemoveAllTagsTest extends TestCase
|
||||
*/
|
||||
public function testAct()
|
||||
{
|
||||
// get journal, link al tags:
|
||||
$journal = TransactionJournal::find(9);
|
||||
$tags = $journal->user->tags()->get();
|
||||
foreach ($tags as $tag) {
|
||||
$journal->tags()->save($tag);
|
||||
$journal->save();
|
||||
}
|
||||
$this->assertGreaterThan(0, $journal->tags()->count());
|
||||
// find journal with at least one tag
|
||||
$journalIds = DB::table('tag_transaction_journal')->get(['transaction_journal_id'])->pluck('transaction_journal_id')->toArray();
|
||||
$journalId = intval($journalIds[0]);
|
||||
/** @var TransactionJournal $journal */
|
||||
$journal = TransactionJournal::find($journalId);
|
||||
|
||||
// fire the action:
|
||||
$ruleAction = new RuleAction;
|
||||
|
@ -22,6 +22,7 @@ declare(strict_types=1);
|
||||
|
||||
namespace Tests\Unit\TransactionRules\Actions;
|
||||
|
||||
use DB;
|
||||
use FireflyIII\Models\RuleAction;
|
||||
use FireflyIII\Models\TransactionJournal;
|
||||
use FireflyIII\TransactionRules\Actions\RemoveTag;
|
||||
@ -38,16 +39,14 @@ class RemoveTagTest extends TestCase
|
||||
*/
|
||||
public function testAct()
|
||||
{
|
||||
// get journal, link al tags:
|
||||
$journal = TransactionJournal::find(10);
|
||||
$tags = $journal->user->tags()->get();
|
||||
foreach ($tags as $tag) {
|
||||
$journal->tags()->save($tag);
|
||||
$journal->save();
|
||||
}
|
||||
$firstTag = $tags->first();
|
||||
$oldCount = $journal->tags()->count();
|
||||
$this->assertGreaterThan(0, $journal->tags()->count());
|
||||
|
||||
// find journal with at least one tag
|
||||
$journalIds = DB::table('tag_transaction_journal')->get(['transaction_journal_id'])->pluck('transaction_journal_id')->toArray();
|
||||
$journalId = intval($journalIds[0]);
|
||||
/** @var TransactionJournal $journal */
|
||||
$journal = TransactionJournal::find($journalId);
|
||||
$originalCount = $journal->tags()->count();
|
||||
$firstTag = $journal->tags()->first();
|
||||
|
||||
// fire the action:
|
||||
$ruleAction = new RuleAction;
|
||||
@ -58,7 +57,7 @@ class RemoveTagTest extends TestCase
|
||||
foreach ($journal->tags()->get() as $tag) {
|
||||
$this->assertNotEquals($firstTag->id, $tag->id);
|
||||
}
|
||||
$this->assertEquals(($oldCount - 1), $journal->tags()->count());
|
||||
$this->assertEquals(($originalCount - 1), $journal->tags()->count());
|
||||
}
|
||||
|
||||
/**
|
||||
|
Loading…
Reference in New Issue
Block a user