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