Remove dead code.

This commit is contained in:
James Cole
2019-06-21 19:05:28 +02:00
parent 72c0d7a874
commit e80cde86d6
19 changed files with 67 additions and 1038 deletions

View File

@@ -1,81 +0,0 @@
<?php
/**
* StoredJournalEventHandlerTest.php
* Copyright (c) 2018 thegrumpydictator@gmail.com
*
* This file is part of Firefly III.
*
* Firefly III is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* Firefly III is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with Firefly III. If not, see <http://www.gnu.org/licenses/>.
*/
declare(strict_types=1);
namespace Tests\Unit\Handlers\Events;
use FireflyIII\Events\StoredTransactionJournal;
use FireflyIII\Exceptions\FireflyException;
use FireflyIII\Handlers\Events\StoredJournalEventHandler;
use FireflyIII\Repositories\RuleGroup\RuleGroupRepositoryInterface;
use FireflyIII\TransactionRules\Processor;
use Log;
use Tests\TestCase;
/**
*
* Class StoredJournalEventHandlerTest
*/
class StoredJournalEventHandlerTest extends TestCase
{
/**
*
*/
public function setUp(): void
{
parent::setUp();
Log::info(sprintf('Now in %s.', get_class($this)));
}
/**
*/
public function testProcessRules(): void
{
$this->markTestIncomplete('Needs to be rewritten for v4.8.0');
return;
$ruleGroupRepos = $this->mock(RuleGroupRepositoryInterface::class);
$processor = $this->mock(Processor::class);
$journal = $this->user()->transactionJournals()->inRandomOrder()->first();
$piggy = $this->user()->piggyBanks()->inRandomOrder()->first();
$event = new StoredTransactionJournal($journal, $piggy->id);
$ruleGroups = $this->user()->ruleGroups()->take(1)->get();
$rules = $this->user()->rules()->take(1)->get();
// mock calls:
$ruleGroupRepos->shouldReceive('setUser')->once();
$ruleGroupRepos->shouldReceive('getActiveGroups')->andReturn($ruleGroups)->once();
$ruleGroupRepos->shouldReceive('getActiveStoreRules')->andReturn($rules)->once();
$processor->shouldReceive('make')->once();
$processor->shouldReceive('handleTransactionJournal')->once();
$handler = new StoredJournalEventHandler;
try {
$handler->processRules($event);
} catch (FireflyException $e) {
$this->assertTrue(false, $e->getMessage());
}
}
}

View File

@@ -0,0 +1,67 @@
<?php
/**
* UpdatedJournalEventHandlerTest.php
* Copyright (c) 2018 thegrumpydictator@gmail.com
*
* This file is part of Firefly III.
*
* Firefly III is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* Firefly III is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with Firefly III. If not, see <http://www.gnu.org/licenses/>.
*/
declare(strict_types=1);
namespace Tests\Unit\Handlers\Events;
use FireflyIII\Events\StoredTransactionGroup;
use FireflyIII\Events\UpdatedTransactionGroup;
use FireflyIII\Handlers\Events\StoredGroupEventHandler;
use FireflyIII\Handlers\Events\UpdatedGroupEventHandler;
use FireflyIII\TransactionRules\Engine\RuleEngine;
use Log;
use Tests\TestCase;
/**
* Class UpdatedJournalEventHandlerTest
*/
class UpdatedJournalEventHandlerTest extends TestCase
{
/**
*
*/
public function setUp(): void
{
parent::setUp();
Log::info(sprintf('Now in %s.', get_class($this)));
}
/**
* @covers \FireflyIII\Handlers\Events\UpdatedGroupEventHandler
*/
public function testProcessRules(): void
{
$group = $this->getRandomWithdrawalGroup();
$ruleEngine = $this->mock(RuleEngine::class);
$ruleEngine->shouldReceive('setUser')->atLeast()->once();
$ruleEngine->shouldReceive('setAllRules')->atLeast()->once()->withArgs([true]);
$ruleEngine->shouldReceive('setTriggerMode')->atLeast()->once()->withArgs([RuleEngine::TRIGGER_STORE]);
$ruleEngine->shouldReceive('processTransactionJournal')->atLeast()->once();
$event = new UpdatedTransactionGroup($group);
$handler = new UpdatedGroupEventHandler;
$handler->processRules($event);
}
}

View File

@@ -1,79 +0,0 @@
<?php
/**
* UpdatedJournalEventHandlerTest.php
* Copyright (c) 2018 thegrumpydictator@gmail.com
*
* This file is part of Firefly III.
*
* Firefly III is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* Firefly III is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with Firefly III. If not, see <http://www.gnu.org/licenses/>.
*/
declare(strict_types=1);
namespace Tests\Unit\Handlers\Events;
use FireflyIII\Events\UpdatedTransactionJournal;
use FireflyIII\Handlers\Events\UpdatedJournalEventHandler;
use FireflyIII\Repositories\RuleGroup\RuleGroupRepositoryInterface;
use FireflyIII\TransactionRules\Processor;
use Log;
use Tests\TestCase;
/**
* Class UpdatedJournalEventHandlerTest
*/
class UpdatedJournalEventHandlerTest extends TestCase
{
/**
*
*/
public function setUp(): void
{
parent::setUp();
Log::info(sprintf('Now in %s.', get_class($this)));
}
/**
*/
public function testProcessRules(): void
{
$this->markTestIncomplete('Needs to be rewritten for v4.8.0');
return;
$ruleGroupRepos = $this->mock(RuleGroupRepositoryInterface::class);
$processor = $this->mock(Processor::class);
$journal = $this->user()->transactionJournals()->inRandomOrder()->first();
$event = new UpdatedTransactionJournal($journal);
$ruleGroups = $this->user()->ruleGroups()->take(1)->get();
$rules = $this->user()->rules()->take(1)->get();
// mock calls:
$ruleGroupRepos->shouldReceive('setUser')->once();
$ruleGroupRepos->shouldReceive('getActiveGroups')->andReturn($ruleGroups)->once();
$ruleGroupRepos->shouldReceive('getActiveUpdateRules')->andReturn($rules)->once();
$processor->shouldReceive('make')->once();
$processor->shouldReceive('handleTransactionJournal')->once();
$handler = new UpdatedJournalEventHandler;
try {
$handler->processRules($event);
} catch (FireflyException $e) {
$this->assertTrue(false, $e->getMessage());
}
}
}

View File

@@ -1,69 +0,0 @@
<?php
/**
* AmountFilterTest.php
* Copyright (c) 2018 thegrumpydictator@gmail.com
*
* This file is part of Firefly III.
*
* Firefly III is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* Firefly III is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with Firefly III. If not, see <http://www.gnu.org/licenses/>.
*/
declare(strict_types=1);
namespace Tests\Unit\Helpers\Filter;
use FireflyIII\Helpers\Filter\AmountFilter;
use FireflyIII\Models\Transaction;
use Illuminate\Support\Collection;
use Log;
use Tests\TestCase;
/**
*
* Class AmountFilterTest
*/
class AmountFilterTest extends TestCase
{
/**
*
*/
public function setUp(): void
{
parent::setUp();
Log::info(sprintf('Now in %s.', get_class($this)));
}
/**
* @covers \FireflyIII\Helpers\Filter\AmountFilter
*/
public function testBasicPositive(): void
{
$count = 0;
$collection = new Collection;
for ($i = 0; $i < 10; $i++) {
$amount = random_int(-10, 10);
$transaction = new Transaction;
$transaction->transaction_amount = (string)$amount;
if ($amount <= 0) {
$count++;
}
$collection->push($transaction);
}
$filter = new AmountFilter(1);
$result = $filter->filter($collection);
$this->assertCount($count, $result);
}
}