From 57cb32563929b429ab5602c9021b73350c450b16 Mon Sep 17 00:00:00 2001 From: James Cole Date: Sat, 1 Aug 2020 05:34:32 +0200 Subject: [PATCH] Optimise tests --- composer.lock | 43 +++++++++-------------- phpunit.xml | 8 ++--- tests/Unit/Factory/AccountFactoryTest.php | 16 +-------- 3 files changed, 21 insertions(+), 46 deletions(-) diff --git a/composer.lock b/composer.lock index 0e0ef7de30..b7f84a8ab1 100644 --- a/composer.lock +++ b/composer.lock @@ -7314,16 +7314,16 @@ }, { "name": "ergebnis/phpstan-rules", - "version": "0.15.0", + "version": "0.15.1", "source": { "type": "git", "url": "https://github.com/ergebnis/phpstan-rules.git", - "reference": "f0c49d0efdaebd9e663e9e5637253ebcc41048d7" + "reference": "e6e2bbf0edd7f78b26dfd72daa01d28500ad3e6c" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/ergebnis/phpstan-rules/zipball/f0c49d0efdaebd9e663e9e5637253ebcc41048d7", - "reference": "f0c49d0efdaebd9e663e9e5637253ebcc41048d7", + "url": "https://api.github.com/repos/ergebnis/phpstan-rules/zipball/e6e2bbf0edd7f78b26dfd72daa01d28500ad3e6c", + "reference": "e6e2bbf0edd7f78b26dfd72daa01d28500ad3e6c", "shasum": "" }, "require": { @@ -7333,18 +7333,18 @@ "phpstan/phpstan": "~0.11.15 || ~0.12.0" }, "require-dev": { - "ergebnis/composer-normalize": "^2.5.1", - "ergebnis/license": "~1.0.0", - "ergebnis/php-cs-fixer-config": "^2.1.2", - "ergebnis/test-util": "~1.0.0", + "ergebnis/composer-normalize": "^2.6.1", + "ergebnis/license": "^1.0.0", + "ergebnis/php-cs-fixer-config": "^2.2.1", + "ergebnis/test-util": "^1.0.0", "infection/infection": "~0.13.6", "nette/di": "^3.0.1", "phpstan/phpstan-deprecation-rules": "~0.11.2", "phpstan/phpstan-strict-rules": "~0.11.1", "phpunit/phpunit": "^7.5.20", - "psalm/plugin-phpunit": "~0.10.0", + "psalm/plugin-phpunit": "~0.10.1", "psr/container": "^1.0.0", - "vimeo/psalm": "^3.11.2", + "vimeo/psalm": "^3.13.1", "zendframework/zend-servicemanager": "^2.0.0" }, "type": "phpstan-extension", @@ -7378,24 +7378,12 @@ "phpstan-rules" ], "funding": [ - { - "url": "https://paypal.me/localheinz", - "type": "custom" - }, - { - "url": "https://www.amazon.de/hz/wishlist/ls/2NCHMSJ4BC1OW", - "type": "custom" - }, - { - "url": "https://www.buymeacoffee.com/localheinz", - "type": "custom" - }, { "url": "https://github.com/localheinz", "type": "github" } ], - "time": "2020-05-10T18:39:28+00:00" + "time": "2020-07-31T18:01:05+00:00" }, { "name": "felixfbecker/advanced-json-rpc", @@ -9085,12 +9073,12 @@ "source": { "type": "git", "url": "https://github.com/Roave/SecurityAdvisories.git", - "reference": "f693c37873d31bff5adb1279cb05a2f4ce5efb43" + "reference": "38ea77863c1b13199948363e9cf7f7dd35a06e37" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/Roave/SecurityAdvisories/zipball/f693c37873d31bff5adb1279cb05a2f4ce5efb43", - "reference": "f693c37873d31bff5adb1279cb05a2f4ce5efb43", + "url": "https://api.github.com/repos/Roave/SecurityAdvisories/zipball/38ea77863c1b13199948363e9cf7f7dd35a06e37", + "reference": "38ea77863c1b13199948363e9cf7f7dd35a06e37", "shasum": "" }, "conflict": { @@ -9174,6 +9162,7 @@ "joomla/session": "<1.3.1", "jsmitty12/phpwhois": "<5.1", "kazist/phpwhois": "<=4.2.6", + "kitodo/presentation": "<3.1.2", "kreait/firebase-php": ">=3.2,<3.8.1", "la-haute-societe/tcpdf": "<6.2.22", "laravel/framework": ">=4,<4.0.99|>=4.1,<=4.1.31|>=4.2,<=4.2.22|>=5,<=5.0.35|>=5.1,<=5.1.46|>=5.2,<=5.2.45|>=5.3,<=5.3.31|>=5.4,<=5.4.36|>=5.5,<5.5.42|>=5.6,<5.6.30|>=7,<7.1.2", @@ -9369,7 +9358,7 @@ "type": "tidelift" } ], - "time": "2020-07-29T19:02:51+00:00" + "time": "2020-07-31T18:02:22+00:00" }, { "name": "sebastian/code-unit-reverse-lookup", diff --git a/phpunit.xml b/phpunit.xml index 220c0dd4a1..54e7a7569d 100644 --- a/phpunit.xml +++ b/phpunit.xml @@ -33,17 +33,17 @@ + + + ./tests/Unit + diff --git a/tests/Unit/Factory/AccountFactoryTest.php b/tests/Unit/Factory/AccountFactoryTest.php index d9754fc969..ffb63c4836 100644 --- a/tests/Unit/Factory/AccountFactoryTest.php +++ b/tests/Unit/Factory/AccountFactoryTest.php @@ -62,13 +62,9 @@ class AccountFactoryTest extends TestCase * @covers \FireflyIII\Services\Internal\Support\AccountServiceTrait * @covers \FireflyIII\Services\Internal\Support\LocationServiceTrait */ - public function testCreate(): void + public function testCreateNoMockery(): void { // mock repositories - $accountRepos = $this->mock(AccountRepositoryInterface::class); - $metaFactory = $this->mock(AccountMetaFactory::class); - $currencyFactory = $this->mock(TransactionCurrencyFactory::class); - $euro = $this->getEuro(); $data = [ 'account_type_id' => null, 'account_type' => 'asset', @@ -79,16 +75,6 @@ class AccountFactoryTest extends TestCase 'account_role' => 'defaultAsset', ]; - // no currency submitted means: find the EURO: - Amount::shouldReceive('getDefaultCurrencyByUser')->atLeast()->once()->andReturn($euro); - - $currencyFactory->shouldReceive('find')->withArgs([0, ''])->atLeast()->once()->andReturnNull(); - $metaFactory->shouldReceive('crud')->withArgs([Mockery::any(), 'account_role', 'defaultAsset'])->atLeast()->once()->andReturnNull(); - $metaFactory->shouldReceive('crud')->withArgs([Mockery::any(), 'currency_id', '1'])->atLeast()->once()->andReturnNull(); - - // get opening balance group (null for new accounts) - $accountRepos->shouldReceive('getOpeningBalanceGroup')->atLeast()->once()->andReturn(null); - /** @var AccountFactory $factory */ $factory = app(AccountFactory::class); $factory->setUser($this->user());