Skip to content

Firefly III: a personal finances manager

Clean up test code, prep for merge.

James Colecd19e86141b8
diff --git a/phpunit.coverage.specific.xml b/phpunit.coverage.specific.xml
deleted file mode 100644
index 14ca914b98..0000000000
--- a/phpunit.coverage.specific.xml
+++ /dev/null
@@ -1,63 +0,0 @@
-<?xml version="1.0" encoding="UTF-8"?>
-
-<!--
- ~ phpunit.coverage.specific.xml
- ~ Copyright (c) 2020 [email protected]
- ~
- ~ This file is part of Firefly III (https://github.com/firefly-iii).
- ~
- ~ This program is free software: you can redistribute it and/or modify
- ~ it under the terms of the GNU Affero General Public License as
- ~ published by the Free Software Foundation, either version 3 of the
- ~ License, or (at your option) any later version.
- ~
- ~ This program 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 Affero General Public License for more details.
- ~
- ~ You should have received a copy of the GNU Affero General Public License
- ~ along with this program. If not, see <https://www.gnu.org/licenses/>.
- -->
-
-<phpunit backupGlobals="false"
- backupStaticAttributes="false"
- bootstrap="vendor/autoload.php"
- colors="true"
- convertErrorsToExceptions="true"
- convertNoticesToExceptions="true"
- convertWarningsToExceptions="true"
- processIsolation="false"
- stopOnFailure="true">
- <listeners>
- <listener class="JohnKary\PHPUnit\Listener\SpeedTrapListener" />
- </listeners>
- <testsuites>
- <testsuite name="Api">
- <directory suffix="Test.php">./tests/Api</directory>
- </testsuite>
- <testsuite name="Unit">
- <directory suffix="Test.php">./tests/Unit</directory>
- </testsuite>
- <testsuite name="Feature">
- <directory suffix="Test.php">./tests/Feature</directory>
- </testsuite>
- </testsuites>
- <filter>
- <whitelist processUncoveredFilesFromWhitelist="true">
- <directory suffix=".php">./app</directory>
- <exclude>
- <file>app/Http/breadcrumbs.php</file>
- </exclude>
- </whitelist>
- </filter>
- <logging>
- <log type="coverage-clover" target="./storage/build/clover-specific.xml" />
- </logging>
- <php>
- <env name="APP_ENV" value="testing"/>
- <env name="CACHE_DRIVER" value="array"/>
- <env name="SESSION_DRIVER" value="array"/>
- <env name="QUEUE_DRIVER" value="sync"/>
- </php>
-</phpunit>
diff --git a/phpunit.coverage.xml b/phpunit.coverage.xml
deleted file mode 100644
index 78a52537ac..0000000000
--- a/phpunit.coverage.xml
+++ /dev/null
@@ -1,64 +0,0 @@
-<?xml version="1.0" encoding="UTF-8"?>
-
-
-<!--
- ~ phpunit.coverage.xml
- ~ Copyright (c) 2020 [email protected]
- ~
- ~ This file is part of Firefly III (https://github.com/firefly-iii).
- ~
- ~ This program is free software: you can redistribute it and/or modify
- ~ it under the terms of the GNU Affero General Public License as
- ~ published by the Free Software Foundation, either version 3 of the
- ~ License, or (at your option) any later version.
- ~
- ~ This program 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 Affero General Public License for more details.
- ~
- ~ You should have received a copy of the GNU Affero General Public License
- ~ along with this program. If not, see <https://www.gnu.org/licenses/>.
- -->
-
-<phpunit backupGlobals="false"
- backupStaticAttributes="false"
- bootstrap="vendor/autoload.php"
- colors="true"
- convertErrorsToExceptions="true"
- convertNoticesToExceptions="true"
- convertWarningsToExceptions="true"
- processIsolation="false"
- stopOnFailure="true">
- <listeners>
- <listener class="JohnKary\PHPUnit\Listener\SpeedTrapListener" />
- </listeners>
- <testsuites>
- <testsuite name="Api">
- <directory suffix="Test.php">./tests/Api</directory>
- </testsuite>
- <testsuite name="Unit">
- <directory suffix="Test.php">./tests/Unit</directory>
- </testsuite>
- <testsuite name="Feature">
- <directory suffix="Test.php">./tests/Feature</directory>
- </testsuite>
- </testsuites>
- <filter>
- <whitelist processUncoveredFilesFromWhitelist="true">
- <directory suffix=".php">./app</directory>
- <exclude>
- <file>app/Http/breadcrumbs.php</file>
- </exclude>
- </whitelist>
- </filter>
- <logging>
- <log type="coverage-clover" target="./storage/build/clover-all.xml" />
- </logging>
- <php>
- <env name="APP_ENV" value="testing"/>
- <env name="CACHE_DRIVER" value="array"/>
- <env name="SESSION_DRIVER" value="array"/>
- <env name="QUEUE_DRIVER" value="sync"/>
- </php>
-</phpunit>
diff --git a/phpunit.xml b/phpunit.xml
index a255c39ab5..3ed2160e50 100644
--- a/phpunit.xml
+++ b/phpunit.xml
@@ -37,12 +37,14 @@
<testsuite name="Api">
<directory suffix="Test.php">./tests/Api</directory>
</testsuite>
+ <!--
<testsuite name="Unit">
<directory suffix="Test.php">./tests/Unit</directory>
</testsuite>
<testsuite name="Feature">
<directory suffix="Test.php">./tests/Feature</directory>
</testsuite>
+ -->
</testsuites>
<filter>
<whitelist processUncoveredFilesFromWhitelist="true">
diff --git a/tests/Api/V1/Controllers/Chart/CategoryControllerTest.php b/tests/Api/V1/Controllers/Chart/CategoryControllerTest.php
index 4805200840..10d8571354 100644
--- a/tests/Api/V1/Controllers/Chart/CategoryControllerTest.php
+++ b/tests/Api/V1/Controllers/Chart/CategoryControllerTest.php
@@ -29,7 +29,6 @@ use FireflyIII\Repositories\Category\NoCategoryRepositoryInterface;
use FireflyIII\Repositories\Category\OperationsRepositoryInterface;
use Laravel\Passport\Passport;
use Log;
-use Tests\Support\TestDataTrait;
use Tests\TestCase;
/**
@@ -40,8 +39,6 @@ use Tests\TestCase;
*/
class CategoryControllerTest extends TestCase
{
- use TestDataTrait;
-
/**
*
*/
diff --git a/tests/Api/V1/Controllers/UserControllerTest.php b/tests/Api/V1/Controllers/UserControllerTest.php
index ce2966d070..0c090772eb 100644
--- a/tests/Api/V1/Controllers/UserControllerTest.php
+++ b/tests/Api/V1/Controllers/UserControllerTest.php
@@ -24,9 +24,9 @@ declare(strict_types=1);
namespace Tests\Api\V1\Controllers;
+use Faker\Factory;
use FireflyIII\Repositories\User\UserRepositoryInterface;
use FireflyIII\Transformers\UserTransformer;
-use FireflyIII\User;
use Laravel\Passport\Passport;
use Log;
use Mockery;
@@ -49,7 +49,6 @@ class UserControllerTest extends TestCase
parent::setUp();
Passport::actingAs($this->user());
$this->mockDefaultConfiguration();
- Log::info(sprintf('Now in %s.', get_class($this)));
}
@@ -61,7 +60,13 @@ class UserControllerTest extends TestCase
*/
public function testStoreBasic(): void
{
- $this->assertTrue(true);
- }
+ Log::info(sprintf('Now in test %s.', __METHOD__));
+ // random user
+ $faker = Factory::create();
+ $data = ['email' => $faker->email,];
+ // test API
+ $response = $this->post(route('api.v1.users.store'), $data, ['Content-Type' => 'application/x-www-form-urlencoded', 'Accept' => 'application/json']);
+ $response->assertStatus(200);
+ }
}
diff --git a/tests/TestCase.php b/tests/TestCase.php
index 610ca27616..c07f2814bb 100644
--- a/tests/TestCase.php
+++ b/tests/TestCase.php
@@ -25,6 +25,7 @@ namespace Tests;
use FireflyIII\User;
use Illuminate\Foundation\Testing\TestCase as BaseTestCase;
+use Tests\Traits\CollectsValues;
use Tests\Traits\MocksDefaultValues;
use Tests\Traits\TestHelpers;
@@ -33,7 +34,7 @@ use Tests\Traits\TestHelpers;
*/
abstract class TestCase extends BaseTestCase
{
- use CreatesApplication, MocksDefaultValues, TestHelpers;
+ use CreatesApplication, MocksDefaultValues, TestHelpers, CollectsValues;
/**
* @return array
@@ -50,14 +51,4 @@ abstract class TestCase extends BaseTestCase
'custom range' => ['custom'],
];
}
-
- /**
- * @return User
- */
- public function user(): User
- {
- return User::find(1);
- }
-
-
}