Code cleanup

This commit is contained in:
James Cole 2015-05-17 11:28:58 +02:00
parent 6280448dfb
commit 033f5b67db
18 changed files with 96 additions and 51 deletions

View File

@ -5,6 +5,7 @@ use Illuminate\Support\Collection;
use League\FactoryMuffin\Facade as FactoryMuffin;
/**
* @SuppressWarnings(PHPMD.TooManyMethods)
* Class BudgetControllerTest
*/
class BudgetControllerTest extends TestCase

View File

@ -6,6 +6,7 @@ use League\FactoryMuffin\Facade as FactoryMuffin;
/**
* @SuppressWarnings(PHPMD.TooManyMethods)
* Class CategoryControllerTest
*/
class CategoryControllerTest extends TestCase

View File

@ -3,6 +3,7 @@ use Illuminate\Support\Collection;
use League\FactoryMuffin\Facade as FactoryMuffin;
/**
* @SuppressWarnings(PHPMD.TooManyMethods)
* Class CurrencyControllerTest
*/
class CurrencyControllerTest extends TestCase

View File

@ -40,8 +40,8 @@ class JsonControllerTest extends TestCase
public function testBoxBillsPaid()
{
$bill = FactoryMuffin::create('FireflyIII\Models\Bill');
$cc = FactoryMuffin::create('FireflyIII\Models\Account');
$ccs = new Collection([$cc]);
$creditCard = FactoryMuffin::create('FireflyIII\Models\Account');
$ccs = new Collection([$creditCard]);
$collection = new Collection([$bill]);
$ranges = [['start' => new Carbon, 'end' => new Carbon]];
$this->be($bill->user);
@ -69,8 +69,8 @@ class JsonControllerTest extends TestCase
public function testBoxBillsUnpaid()
{
$bill = FactoryMuffin::create('FireflyIII\Models\Bill');
$cc = FactoryMuffin::create('FireflyIII\Models\Account');
$ccs = new Collection([$cc]);
$creditCard = FactoryMuffin::create('FireflyIII\Models\Account');
$ccs = new Collection([$creditCard]);
$collection = new Collection([$bill]);
$ranges = [['start' => new Carbon, 'end' => new Carbon]];
$this->be($bill->user);
@ -133,24 +133,6 @@ class JsonControllerTest extends TestCase
$this->assertResponseOk();
}
public function testTags()
{
$user = FactoryMuffin::create('FireflyIII\User');
$this->be($user);
$tag = FactoryMuffin::create('FireflyIII\Models\Tag');
$tag->user()->associate($user);
$tag->save();
$this->be($tag->user);
$tags = new Collection([$tag]);
$repository = $this->mock('FireflyIII\Repositories\Tag\TagRepositoryInterface');
$repository->shouldReceive('get')->andReturn($tags);
$this->call('GET', '/json/tags');
$this->assertResponseOk();
}
public function testExpenseAccounts()
{
$account = FactoryMuffin::create('FireflyIII\Models\Account');
@ -177,6 +159,24 @@ class JsonControllerTest extends TestCase
$this->assertResponseOk();
}
public function testTags()
{
$user = FactoryMuffin::create('FireflyIII\User');
$this->be($user);
$tag = FactoryMuffin::create('FireflyIII\Models\Tag');
$tag->user()->associate($user);
$tag->save();
$this->be($tag->user);
$tags = new Collection([$tag]);
$repository = $this->mock('FireflyIII\Repositories\Tag\TagRepositoryInterface');
$repository->shouldReceive('get')->andReturn($tags);
$this->call('GET', '/json/tags');
$this->assertResponseOk();
}
public function testTransactionJournals()
{
$journal = FactoryMuffin::create('FireflyIII\Models\TransactionJournal');

View File

@ -8,6 +8,7 @@ use Illuminate\Support\Collection;
use League\FactoryMuffin\Facade as FactoryMuffin;
/**
* @SuppressWarnings(PHPMD.TooManyMethods)
* Class PiggyBankControllerTest
*/
class PiggyBankControllerTest extends TestCase

View File

@ -69,7 +69,7 @@ class ReportControllerTest extends TestCase
public function testMonth()
{
$user = FactoryMuffin::create('FireflyIII\User');
$account = FactoryMuffin::create('FireflyIII\Models\Account');
FactoryMuffin::create('FireflyIII\Models\Account');
$budget1 = FactoryMuffin::create('FireflyIII\Models\Budget');
$budget1->queryAmount = 12;
$budget2 = FactoryMuffin::create('FireflyIII\Models\Budget');
@ -95,7 +95,7 @@ class ReportControllerTest extends TestCase
public function testMonthShared()
{
$user = FactoryMuffin::create('FireflyIII\User');
$account = FactoryMuffin::create('FireflyIII\Models\Account');
FactoryMuffin::create('FireflyIII\Models\Account');
$budget1 = FactoryMuffin::create('FireflyIII\Models\Budget');
$budget1->queryAmount = 12;
$budget2 = FactoryMuffin::create('FireflyIII\Models\Budget');
@ -132,7 +132,7 @@ class ReportControllerTest extends TestCase
'data' => 'sharedAsset'
]
);
$journals = new Collection([$journal]);
new Collection([$journal]);
$this->be($user);

View File

@ -2,6 +2,7 @@
use League\FactoryMuffin\Facade as FactoryMuffin;
/**
* @SuppressWarnings(PHPMD.TooManyMethods)
* Class TagControllerTest
*/
class TagControllerTest extends TestCase

View File

@ -4,6 +4,7 @@ use Illuminate\Support\Collection;
use League\FactoryMuffin\Facade as FactoryMuffin;
/**
* @SuppressWarnings(PHPMD.TooManyMethods)
* Class TransactionControllerTest
*/
class TransactionControllerTest extends TestCase
@ -82,6 +83,9 @@ class TransactionControllerTest extends TestCase
}
/**
* @SuppressWarnings(PHPMD.ExcessiveMethodLength)
*/
public function testEdit()
{
// make complete journal:
@ -225,6 +229,9 @@ class TransactionControllerTest extends TestCase
$this->assertResponseOk();
}
/**
* @SuppressWarnings(PHPMD.ExcessiveMethodLength)
*/
public function testStore()
{
$account = FactoryMuffin::create('FireflyIII\Models\Account');
@ -269,6 +276,9 @@ class TransactionControllerTest extends TestCase
}
/**
* @SuppressWarnings(PHPMD.ExcessiveMethodLength)
*/
public function testUpdate()
{
$account = FactoryMuffin::create('FireflyIII\Models\Account');
@ -314,6 +324,9 @@ class TransactionControllerTest extends TestCase
}
/**
* @SuppressWarnings(PHPMD.ExcessiveMethodLength)
*/
public function testUpdateWithRedirect()
{
$account = FactoryMuffin::create('FireflyIII\Models\Account');

View File

@ -30,6 +30,9 @@ class ConnectJournalToPiggyBankTest extends TestCase
parent::tearDown();
}
/**
* @SuppressWarnings(PHPMD.ExcessiveMethodLength)
*/
public function testNoRepetition()
{
FactoryMuffin::create('FireflyIII\Models\TransactionType');
@ -97,6 +100,9 @@ class ConnectJournalToPiggyBankTest extends TestCase
$this->assertFalse($result);
}
/**
* @SuppressWarnings(PHPMD.ExcessiveMethodLength)
*/
public function testWithRepetition()
{
FactoryMuffin::create('FireflyIII\Models\TransactionType');
@ -154,6 +160,9 @@ class ConnectJournalToPiggyBankTest extends TestCase
$this->assertCount(1, $piggyBank->piggyBankEvents()->get());
}
/**
* @SuppressWarnings(PHPMD.ExcessiveMethodLength)
*/
public function testWithRepetitionReversed()
{
FactoryMuffin::create('FireflyIII\Models\TransactionType');

View File

@ -7,6 +7,7 @@ use FireflyIII\Models\Transaction;
use League\FactoryMuffin\Facade as FactoryMuffin;
/**
* @SuppressWarnings(PHPMD.TooManyMethods)
* Class ReportQueryTest
*/
class ReportQueryTest extends TestCase

View File

@ -11,6 +11,7 @@ use Illuminate\Pagination\LengthAwarePaginator;
use League\FactoryMuffin\Facade as FactoryMuffin;
/**
* @SuppressWarnings(PHPMD.TooManyMethods)
* Generated by PHPUnit_SkeletonGenerator on 2015-05-05 at 16:33:55.
*/
class AccountRepositoryTest extends TestCase
@ -58,14 +59,14 @@ class AccountRepositoryTest extends TestCase
{
// create account:
$account = FactoryMuffin::create('FireflyIII\Models\Account');
$id = $account->id;
$accountId = $account->id;
$this->be($account->user);
$this->object->destroy($account);
// cannot find account:
$this->assertCount(0, Account::whereId($id)->whereNotNull('deleted_at')->get());
$this->assertCount(0, Account::whereId($accountId)->whereNotNull('deleted_at')->get());
}
/**
@ -190,6 +191,7 @@ class AccountRepositoryTest extends TestCase
/**
* @covers FireflyIII\Repositories\Account\AccountRepository::getFrontpageTransactions
* @SuppressWarnings(PHPMD.ExcessiveMethodLength)
*/
public function testGetFrontpageTransactions()
{
@ -250,6 +252,7 @@ class AccountRepositoryTest extends TestCase
/**
* @covers FireflyIII\Repositories\Account\AccountRepository::getJournals
* @SuppressWarnings(PHPMD.ExcessiveMethodLength)
*/
public function testGetJournals()
{
@ -399,6 +402,7 @@ class AccountRepositoryTest extends TestCase
/**
* @covers FireflyIII\Repositories\Account\AccountRepository::getSavingsAccounts
* @SuppressWarnings(PHPMD.ExcessiveMethodLength)
*/
public function testGetSavingsAccounts()
{
@ -457,12 +461,12 @@ class AccountRepositoryTest extends TestCase
/**
* @covers FireflyIII\Repositories\Account\AccountRepository::getTransfersInRange
* @SuppressWarnings(PHPMD.ExcessiveMethodLength)
*/
public function testGetTransfersInRange()
{
$account = FactoryMuffin::create('FireflyIII\Models\Account');
FactoryMuffin::create('FireflyIII\Models\Account');
$date = new Carbon;
// three transfers, two out of range:
FactoryMuffin::create('FireflyIII\Models\TransactionType');
@ -546,6 +550,7 @@ class AccountRepositoryTest extends TestCase
/**
* @covers FireflyIII\Repositories\Account\AccountRepository::openingBalanceTransaction
* @SuppressWarnings(PHPMD.ExcessiveMethodLength)
*/
public function testOpeningBalanceTransaction()
{
@ -764,6 +769,7 @@ class AccountRepositoryTest extends TestCase
* @covers FireflyIII\Repositories\Account\AccountRepository::update
* @covers FireflyIII\Repositories\Account\AccountRepository::updateMetadata
* @covers FireflyIII\Repositories\Account\AccountRepository::updateInitialBalance
* @SuppressWarnings(PHPMD.ExcessiveMethodLength)
*/
public function testUpdate()
{
@ -814,6 +820,7 @@ class AccountRepositoryTest extends TestCase
* @covers FireflyIII\Repositories\Account\AccountRepository::update
* @covers FireflyIII\Repositories\Account\AccountRepository::updateMetadata
* @covers FireflyIII\Repositories\Account\AccountRepository::updateInitialBalance
* @SuppressWarnings(PHPMD.ExcessiveMethodLength)
*/
public function testUpdateDeleteOpeningBalance()
{
@ -864,6 +871,7 @@ class AccountRepositoryTest extends TestCase
* @covers FireflyIII\Repositories\Account\AccountRepository::update
* @covers FireflyIII\Repositories\Account\AccountRepository::updateMetadata
* @covers FireflyIII\Repositories\Account\AccountRepository::updateInitialBalance
* @SuppressWarnings(PHPMD.ExcessiveMethodLength)
*/
public function testUpdateNewOpeningBalance()
{

View File

@ -7,6 +7,7 @@ use FireflyIII\Repositories\Bill\BillRepository;
use League\FactoryMuffin\Facade as FactoryMuffin;
/**
* @SuppressWarnings(PHPMD.TooManyMethods)
* Generated by PHPUnit_SkeletonGenerator on 2015-05-08 at 10:43:42.
*/
class BillRepositoryTest extends TestCase
@ -58,11 +59,11 @@ class BillRepositoryTest extends TestCase
public function testDestroy()
{
$bill = FactoryMuffin::create('FireflyIII\Models\Bill');
$id = $bill->id;
$accountId = $bill->id;
$this->object->destroy($bill);
// cannot find bill:
$this->assertCount(0, Bill::whereId($id)->whereNotNull('deleted_at')->get());
$this->assertCount(0, Bill::whereId($accountId)->whereNotNull('deleted_at')->get());
}
/**
@ -282,7 +283,7 @@ class BillRepositoryTest extends TestCase
/**
* One
*
* @SuppressWarnings(PHPMD.ExcessiveMethodLength)
* @covers FireflyIII\Repositories\Bill\BillRepository::scan
*/
public function testScanMatch()

View File

@ -7,6 +7,7 @@ use Illuminate\Pagination\LengthAwarePaginator;
use League\FactoryMuffin\Facade as FactoryMuffin;
/**
* @SuppressWarnings(PHPMD.TooManyMethods)
* Generated by PHPUnit_SkeletonGenerator on 2015-05-05 at 19:16:07.
*/
class BudgetRepositoryTest extends TestCase

View File

@ -5,6 +5,7 @@ use FireflyIII\Repositories\Category\CategoryRepository;
use League\FactoryMuffin\Facade as FactoryMuffin;
/**
* @SuppressWarnings(PHPMD.TooManyMethods)
* Generated by PHPUnit_SkeletonGenerator on 2015-05-05 at 19:19:32.
*/
class CategoryRepositoryTest extends TestCase

View File

@ -71,7 +71,7 @@ class CurrencyRepositoryTest extends TestCase
*/
public function testGetCurrencyByPreferenceNull()
{
$first = FactoryMuffin::create('FireflyIII\Models\TransactionCurrency');
FactoryMuffin::create('FireflyIII\Models\TransactionCurrency');
$preference = FactoryMuffin::create('FireflyIII\Models\Preference');
$preference->data = 'ABC';
$preference->save();

View File

@ -7,6 +7,7 @@ use Illuminate\Pagination\LengthAwarePaginator;
use League\FactoryMuffin\Facade as FactoryMuffin;
/**
* @SuppressWarnings(PHPMD.TooManyMethods)
* Generated by PHPUnit_SkeletonGenerator on 2015-05-05 at 19:19:32.
*/
class JournalRepositoryTest extends TestCase
@ -425,6 +426,7 @@ class JournalRepositoryTest extends TestCase
/**
* @covers FireflyIII\Repositories\Journal\JournalRepository::update
* @covers FireflyIII\Repositories\Journal\JournalRepository::updateTags
* @SuppressWarnings(PHPMD.ExcessiveMethodLength)
*/
public function testUpdate()
{
@ -482,6 +484,7 @@ class JournalRepositoryTest extends TestCase
/**
* @covers FireflyIII\Repositories\Journal\JournalRepository::update
* @covers FireflyIII\Repositories\Journal\JournalRepository::updateTags
* @SuppressWarnings(PHPMD.ExcessiveMethodLength)
*/
public function testUpdateNoTags()
{

View File

@ -6,6 +6,7 @@ use FireflyIII\Repositories\PiggyBank\PiggyBankRepository;
use League\FactoryMuffin\Facade as FactoryMuffin;
/**
* @SuppressWarnings(PHPMD.TooManyMethods)
* Generated by PHPUnit_SkeletonGenerator on 2015-05-05 at 19:19:32.
*/
class PiggyBankRepositoryTest extends TestCase

View File

@ -5,6 +5,7 @@ use FireflyIII\Repositories\Tag\TagRepository;
use League\FactoryMuffin\Facade as FactoryMuffin;
/**
* @SuppressWarnings(PHPMD.TooManyMethods)
* Generated by PHPUnit_SkeletonGenerator on 2015-05-05 at 19:19:32.
*/
class TagRepositoryTest extends TestCase
@ -56,9 +57,9 @@ class TagRepositoryTest extends TestCase
*/
public function testConnectBalancingOneDeposit()
{
$withdrawal = FactoryMuffin::create('FireflyIII\Models\TransactionType');
FactoryMuffin::create('FireflyIII\Models\TransactionType');
$deposit = FactoryMuffin::create('FireflyIII\Models\TransactionType');
$transfer = FactoryMuffin::create('FireflyIII\Models\TransactionType');
FactoryMuffin::create('FireflyIII\Models\TransactionType');
$journal = FactoryMuffin::create('FireflyIII\Models\TransactionJournal');
$tag = FactoryMuffin::create('FireflyIII\Models\Tag');
@ -82,8 +83,8 @@ class TagRepositoryTest extends TestCase
*/
public function testConnectBalancingOneTransfer()
{
$withdrawal = FactoryMuffin::create('FireflyIII\Models\TransactionType');
$deposit = FactoryMuffin::create('FireflyIII\Models\TransactionType');
FactoryMuffin::create('FireflyIII\Models\TransactionType');
FactoryMuffin::create('FireflyIII\Models\TransactionType');
$transfer = FactoryMuffin::create('FireflyIII\Models\TransactionType');
$journal = FactoryMuffin::create('FireflyIII\Models\TransactionJournal');
@ -109,8 +110,8 @@ class TagRepositoryTest extends TestCase
public function testConnectBalancingOneWithdrawal()
{
$withdrawal = FactoryMuffin::create('FireflyIII\Models\TransactionType');
$deposit = FactoryMuffin::create('FireflyIII\Models\TransactionType');
$transfer = FactoryMuffin::create('FireflyIII\Models\TransactionType');
FactoryMuffin::create('FireflyIII\Models\TransactionType');
FactoryMuffin::create('FireflyIII\Models\TransactionType');
$journal = FactoryMuffin::create('FireflyIII\Models\TransactionJournal');
$tag = FactoryMuffin::create('FireflyIII\Models\Tag');
@ -151,10 +152,10 @@ class TagRepositoryTest extends TestCase
{
$withdrawal = FactoryMuffin::create('FireflyIII\Models\TransactionType');
$deposit = FactoryMuffin::create('FireflyIII\Models\TransactionType');
$transfer = FactoryMuffin::create('FireflyIII\Models\TransactionType');
FactoryMuffin::create('FireflyIII\Models\TransactionType');
$expense = FactoryMuffin::create('FireflyIII\Models\AccountType');
$revenue = FactoryMuffin::create('FireflyIII\Models\AccountType');
FactoryMuffin::create('FireflyIII\Models\AccountType');
FactoryMuffin::create('FireflyIII\Models\AccountType');
$asset = FactoryMuffin::create('FireflyIII\Models\AccountType');
$account = FactoryMuffin::create('FireflyIII\Models\Account');
@ -191,16 +192,17 @@ class TagRepositoryTest extends TestCase
* Once one or more journals have been accepted by the tag, others must match the asset account
* id. For this to work, we must also create an asset account, and a transaction.
*
* @SuppressWarnings(PHPMD.ExcessiveMethodLength)
* @covers FireflyIII\Repositories\Tag\TagRepository::connect
*/
public function testConnectPaymentNoMatch()
{
$withdrawal = FactoryMuffin::create('FireflyIII\Models\TransactionType');
$deposit = FactoryMuffin::create('FireflyIII\Models\TransactionType');
$transfer = FactoryMuffin::create('FireflyIII\Models\TransactionType');
FactoryMuffin::create('FireflyIII\Models\TransactionType');
$expense = FactoryMuffin::create('FireflyIII\Models\AccountType');
$revenue = FactoryMuffin::create('FireflyIII\Models\AccountType');
FactoryMuffin::create('FireflyIII\Models\AccountType');
FactoryMuffin::create('FireflyIII\Models\AccountType');
$asset = FactoryMuffin::create('FireflyIII\Models\AccountType');
$account1 = FactoryMuffin::create('FireflyIII\Models\Account');
@ -244,8 +246,8 @@ class TagRepositoryTest extends TestCase
*/
public function testConnectPaymentOneTransfer()
{
$withdrawal = FactoryMuffin::create('FireflyIII\Models\TransactionType');
$deposit = FactoryMuffin::create('FireflyIII\Models\TransactionType');
FactoryMuffin::create('FireflyIII\Models\TransactionType');
FactoryMuffin::create('FireflyIII\Models\TransactionType');
$transfer = FactoryMuffin::create('FireflyIII\Models\TransactionType');
$journal = FactoryMuffin::create('FireflyIII\Models\TransactionJournal');
@ -270,8 +272,8 @@ class TagRepositoryTest extends TestCase
public function testConnectPaymentOneWithdrawal()
{
$withdrawal = FactoryMuffin::create('FireflyIII\Models\TransactionType');
$deposit = FactoryMuffin::create('FireflyIII\Models\TransactionType');
$transfer = FactoryMuffin::create('FireflyIII\Models\TransactionType');
FactoryMuffin::create('FireflyIII\Models\TransactionType');
FactoryMuffin::create('FireflyIII\Models\TransactionType');
$journal = FactoryMuffin::create('FireflyIII\Models\TransactionJournal');
$tag = FactoryMuffin::create('FireflyIII\Models\Tag');
@ -295,8 +297,8 @@ class TagRepositoryTest extends TestCase
public function testConnectPaymentTwoWithdrawals()
{
$withdrawal = FactoryMuffin::create('FireflyIII\Models\TransactionType');
$deposit = FactoryMuffin::create('FireflyIII\Models\TransactionType');
$transfer = FactoryMuffin::create('FireflyIII\Models\TransactionType');
FactoryMuffin::create('FireflyIII\Models\TransactionType');
FactoryMuffin::create('FireflyIII\Models\TransactionType');
$journal = FactoryMuffin::create('FireflyIII\Models\TransactionJournal');
$otherJournal = FactoryMuffin::create('FireflyIII\Models\TransactionJournal');