From 6d1bfd3956c80bd1f6301bf6742d7048ae67a91c Mon Sep 17 00:00:00 2001 From: James Cole Date: Sat, 17 Aug 2019 10:54:16 +0200 Subject: [PATCH] Code cleanup --- .../Controllers/RecurrenceControllerTest.php | 1 + .../Chart/CategoryControllerTest.php | 1 + .../Controllers/ReportControllerTest.php | 1 + tests/TestCase.php | 1 + .../Import/Storage/ImportArrayStorageTest.php | 2 ++ tests/Unit/Middleware/BinderTest.php | 3 +++ .../Destroy/AccountDestroyServiceTest.php | 8 ++++---- .../Spectre/ChooseLoginHandlerTest.php | 8 ++++---- .../Placeholder/ImportTransactionTest.php | 2 ++ .../Routine/Bunq/StageNewHandlerTest.php | 18 +++++++++--------- .../Routine/File/MappedValuesValidatorTest.php | 6 +++--- 11 files changed, 31 insertions(+), 20 deletions(-) diff --git a/tests/Api/V1/Controllers/RecurrenceControllerTest.php b/tests/Api/V1/Controllers/RecurrenceControllerTest.php index 064b7b5850..8ad80b3fa2 100644 --- a/tests/Api/V1/Controllers/RecurrenceControllerTest.php +++ b/tests/Api/V1/Controllers/RecurrenceControllerTest.php @@ -38,6 +38,7 @@ use Tests\TestCase; * @SuppressWarnings(PHPMD.CouplingBetweenObjects) * @SuppressWarnings(PHPMD.ExcessiveMethodLength) * @SuppressWarnings(PHPMD.TooManyPublicMethods) + * @SuppressWarnings(PHPMD.ExcessiveClassLength) */ class RecurrenceControllerTest extends TestCase { diff --git a/tests/Feature/Controllers/Chart/CategoryControllerTest.php b/tests/Feature/Controllers/Chart/CategoryControllerTest.php index cdca2234ac..89197731b8 100644 --- a/tests/Feature/Controllers/Chart/CategoryControllerTest.php +++ b/tests/Feature/Controllers/Chart/CategoryControllerTest.php @@ -60,6 +60,7 @@ class CategoryControllerTest extends TestCase * * @param string $range * @throws FireflyException + * @SuppressWarnings(PHPMD.CyclomaticComplexity) */ public function testAll(string $range): void { diff --git a/tests/Feature/Controllers/ReportControllerTest.php b/tests/Feature/Controllers/ReportControllerTest.php index 6776d7d829..f49f4f9e2e 100644 --- a/tests/Feature/Controllers/ReportControllerTest.php +++ b/tests/Feature/Controllers/ReportControllerTest.php @@ -52,6 +52,7 @@ use Tests\TestCase; * @SuppressWarnings(PHPMD.TooManyPublicMethods) * @SuppressWarnings(PHPMD.ExcessiveMethodLength) * @SuppressWarnings(PHPMD.CouplingBetweenObjects) + * @SuppressWarnings(PHPMD.TooManyMethods) */ class ReportControllerTest extends TestCase { diff --git a/tests/TestCase.php b/tests/TestCase.php index 416ba86f1a..600d3a7791 100644 --- a/tests/TestCase.php +++ b/tests/TestCase.php @@ -67,6 +67,7 @@ use RuntimeException; * @SuppressWarnings(PHPMD.CouplingBetweenObjects) * @SuppressWarnings(PHPMD.ExcessiveMethodLength) * @SuppressWarnings(PHPMD.TooManyPublicMethods) + * @SuppressWarnings(PHPMD.ExcessiveClassComplexity) */ abstract class TestCase extends BaseTestCase { diff --git a/tests/Unit/Import/Storage/ImportArrayStorageTest.php b/tests/Unit/Import/Storage/ImportArrayStorageTest.php index 7ca7841e48..b1633818db 100644 --- a/tests/Unit/Import/Storage/ImportArrayStorageTest.php +++ b/tests/Unit/Import/Storage/ImportArrayStorageTest.php @@ -50,6 +50,8 @@ use Tests\TestCase; * @SuppressWarnings(PHPMD.CouplingBetweenObjects) * @SuppressWarnings(PHPMD.ExcessiveMethodLength) * @SuppressWarnings(PHPMD.TooManyPublicMethods) + * @SuppressWarnings(PHPMD.ExcessiveClassLength) + * */ class ImportArrayStorageTest extends TestCase { diff --git a/tests/Unit/Middleware/BinderTest.php b/tests/Unit/Middleware/BinderTest.php index bf9da21780..c6faa59688 100644 --- a/tests/Unit/Middleware/BinderTest.php +++ b/tests/Unit/Middleware/BinderTest.php @@ -51,6 +51,9 @@ use Tests\TestCase; * @SuppressWarnings(PHPMD.CouplingBetweenObjects) * @SuppressWarnings(PHPMD.ExcessiveMethodLength) * @SuppressWarnings(PHPMD.TooManyPublicMethods) + * @SuppressWarnings(PHPMD.TooManyMethods) + * @SuppressWarnings(PHPMD.ExcessiveClassLength) + * @SuppressWarnings(PHPMD.ExcessiveClassComplexity) */ class BinderTest extends TestCase { diff --git a/tests/Unit/Services/Internal/Destroy/AccountDestroyServiceTest.php b/tests/Unit/Services/Internal/Destroy/AccountDestroyServiceTest.php index f3c9f7add6..b8c9a7ab8c 100644 --- a/tests/Unit/Services/Internal/Destroy/AccountDestroyServiceTest.php +++ b/tests/Unit/Services/Internal/Destroy/AccountDestroyServiceTest.php @@ -78,8 +78,8 @@ class AccountDestroyServiceTest extends TestCase 'virtual_balance' => '0', 'iban' => null, 'active' => true] ); - $recurrence = $this->getRandomRecurrence(); - $recurrenceTransaction = RecurrenceTransaction::create( + $recurrence = $this->getRandomRecurrence(); + $transaction = RecurrenceTransaction::create( [ 'recurrence_id' => $recurrence->id, 'transaction_currency_id' => $this->getEuro()->id, @@ -91,7 +91,7 @@ class AccountDestroyServiceTest extends TestCase ); $recService->shouldReceive('destroyById')->once() - ->withAnyArgs([$recurrenceTransaction->id]); + ->withAnyArgs([$transaction->id]); /** @var AccountDestroyService $service */ $service = app(AccountDestroyService::class); @@ -99,7 +99,7 @@ class AccountDestroyServiceTest extends TestCase $this->assertDatabaseMissing('accounts', ['id' => $account->id, 'deleted_at' => null]); - $recurrenceTransaction->forceDelete(); + $transaction->forceDelete(); } /** diff --git a/tests/Unit/Support/Import/JobConfiguration/Spectre/ChooseLoginHandlerTest.php b/tests/Unit/Support/Import/JobConfiguration/Spectre/ChooseLoginHandlerTest.php index 646ba05578..2f16902cfd 100644 --- a/tests/Unit/Support/Import/JobConfiguration/Spectre/ChooseLoginHandlerTest.php +++ b/tests/Unit/Support/Import/JobConfiguration/Spectre/ChooseLoginHandlerTest.php @@ -142,9 +142,9 @@ class ChooseLoginHandlerTest extends TestCase public function testConfigureJobCustomer(): void { // fake Spectre customer: - $fakeCustomerPreference = new Preference; - $fakeCustomerPreference->name = 'spectre_customer'; - $fakeCustomerPreference->data = [ + $fakePref = new Preference; + $fakePref->name = 'spectre_customer'; + $fakePref->data = [ 'id' => 1, 'identifier' => 'fake', 'secret' => 'Dumbledore dies', @@ -167,7 +167,7 @@ class ChooseLoginHandlerTest extends TestCase // should try to grab customer from preferences: Preferences::shouldReceive('getForUser')->withArgs([Mockery::any(), 'spectre_customer', null]) - ->andReturn($fakeCustomerPreference)->once(); + ->andReturn($fakePref)->once(); // mock stuff $ctRequest = $this->mock(CreateTokenRequest::class); diff --git a/tests/Unit/Support/Import/Placeholder/ImportTransactionTest.php b/tests/Unit/Support/Import/Placeholder/ImportTransactionTest.php index 272612ecf0..308fbd735c 100644 --- a/tests/Unit/Support/Import/Placeholder/ImportTransactionTest.php +++ b/tests/Unit/Support/Import/Placeholder/ImportTransactionTest.php @@ -35,6 +35,8 @@ use Tests\TestCase; * @SuppressWarnings(PHPMD.CouplingBetweenObjects) * @SuppressWarnings(PHPMD.ExcessiveMethodLength) * @SuppressWarnings(PHPMD.TooManyPublicMethods) + * @SuppressWarnings(PHPMD.TooManyMethods) + * @SuppressWarnings(PHPMD.ExcessiveClassComplexity) */ class ImportTransactionTest extends TestCase { diff --git a/tests/Unit/Support/Import/Routine/Bunq/StageNewHandlerTest.php b/tests/Unit/Support/Import/Routine/Bunq/StageNewHandlerTest.php index 098b89f4a2..c59dd08afe 100644 --- a/tests/Unit/Support/Import/Routine/Bunq/StageNewHandlerTest.php +++ b/tests/Unit/Support/Import/Routine/Bunq/StageNewHandlerTest.php @@ -85,7 +85,7 @@ class StageNewHandlerTest extends TestCase // create fake bunq object: $setting = new MonetaryAccountSetting(null, null, null); $mab = new BunqMonetaryAccountBank('EUR', 'Some descr', null, null, null, null, null, null, null, null); - $ma = new BunqMonetaryAccount; + $monAcc = new BunqMonetaryAccount; $alias = new Pointer('a', 'b', null); @@ -96,10 +96,10 @@ class StageNewHandlerTest extends TestCase $setting->setColor('FFFFFF'); $mab->setSetting($setting); $mab->setAlias([$alias]); - $ma->setMonetaryAccountBank($mab); + $monAcc->setMonetaryAccountBank($mab); // response list. - $list = new BunqResponseMonetaryAccountList([$ma], []); + $list = new BunqResponseMonetaryAccountList([$monAcc], []); $expectedConfig = [ 'accounts' => [ @@ -172,7 +172,7 @@ class StageNewHandlerTest extends TestCase // create fake bunq object: $setting = new MonetaryAccountSetting(null, null, null); $maj = new MonetaryAccountJoint('EUR', [], 'Some descr', null, null, null, null, null, null, null, null); - $ma = new BunqMonetaryAccount; + $monAcc = new BunqMonetaryAccount; $alias = new Pointer('a', 'b', null); $labelUser = new LabelUser('x', 'James', 'NL'); $coOwner = new CoOwner($alias); @@ -186,11 +186,11 @@ class StageNewHandlerTest extends TestCase $maj->setSetting($setting); $maj->setAlias([$alias]); $maj->setAllCoOwner([$coOwner]); - $ma->setMonetaryAccountJoint($maj); + $monAcc->setMonetaryAccountJoint($maj); $coOwner->setAlias($labelUser); // response list. - $list = new BunqResponseMonetaryAccountList([$ma], []); + $list = new BunqResponseMonetaryAccountList([$monAcc], []); $expectedConfig = [ 'accounts' => [ @@ -264,7 +264,7 @@ class StageNewHandlerTest extends TestCase // create fake bunq object: $setting = new MonetaryAccountSetting(null, null, null); $mal = new MonetaryAccountLight('EUR', 'Some descr', null, null, null, null, null, null, null, null); - $ma = new BunqMonetaryAccount; + $monAcc = new BunqMonetaryAccount; $alias = new Pointer('a', 'b', null); @@ -275,10 +275,10 @@ class StageNewHandlerTest extends TestCase $setting->setColor('FFFFFF'); $mal->setSetting($setting); $mal->setAlias([$alias]); - $ma->setMonetaryAccountLight($mal); + $monAcc->setMonetaryAccountLight($mal); // response list. - $list = new BunqResponseMonetaryAccountList([$ma], []); + $list = new BunqResponseMonetaryAccountList([$monAcc], []); $expectedConfig = [ 'accounts' => [ diff --git a/tests/Unit/Support/Import/Routine/File/MappedValuesValidatorTest.php b/tests/Unit/Support/Import/Routine/File/MappedValuesValidatorTest.php index cc7d813022..9704f09553 100644 --- a/tests/Unit/Support/Import/Routine/File/MappedValuesValidatorTest.php +++ b/tests/Unit/Support/Import/Routine/File/MappedValuesValidatorTest.php @@ -125,14 +125,14 @@ class MappedValuesValidatorTest extends TestCase } /** - * @param int $id + * @param int $objectId * * @return stdClass */ - private function objectWithId(int $id): stdClass + private function objectWithId(int $objectId): stdClass { $obj = new stdClass(); - $obj->id = $id; + $obj->id = $objectId; return $obj; }