Skip to content

Firefly III: a personal finances manager

Organize test suites into unit and integration

Antonio Spinelli7f0db0de0436
diff --git a/composer.json b/composer.json
index b05a6a12c4..0b8810c515 100644
--- a/composer.json
+++ b/composer.json
@@ -168,6 +168,12 @@
"post-install-cmd": [
"@php artisan firefly:instructions install",
"@php artisan firefly-iii:verify-security-alerts"
+ ],
+ "unit-test": [
+ "@php vendor/bin/phpunit -c phpunit.xml --testsuite unit"
+ ],
+ "integration-test": [
+ "@php vendor/bin/phpunit -c phpunit.xml --testsuite integration"
]
},
"config": {
diff --git a/phpunit.xml b/phpunit.xml
index bdcc61af15..575dac224f 100644
--- a/phpunit.xml
+++ b/phpunit.xml
@@ -21,8 +21,11 @@
<phpunit xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" backupGlobals="false" bootstrap="vendor/autoload.php" colors="true" stopOnFailure="true" processIsolation="false" xsi:noNamespaceSchemaLocation="https://schema.phpunit.de/10.1/phpunit.xsd" cacheDirectory=".phpunit.cache" backupStaticProperties="false">
<coverage/>
<testsuites>
- <testsuite name="Api">
- <directory suffix="Test.php">./tests</directory>
+ <testsuite name="unit">
+ <directory suffix="Test.php">./tests/unit</directory>
+ </testsuite>
+ <testsuite name="integration">
+ <directory suffix="Test.php">./tests/integration</directory>
</testsuite>
</testsuites>
<php>
diff --git a/tests/Api/Autocomplete/AccountControllerTest.php b/tests/integration/Api/Autocomplete/AccountControllerTest.php
similarity index 95%
rename from tests/Api/Autocomplete/AccountControllerTest.php
rename to tests/integration/Api/Autocomplete/AccountControllerTest.php
index 7ff8e51672..5eb0ec0ca7 100644
--- a/tests/Api/Autocomplete/AccountControllerTest.php
+++ b/tests/integration/Api/Autocomplete/AccountControllerTest.php
@@ -21,11 +21,11 @@
declare(strict_types=1);
-namespace Tests\Api\Autocomplete;
+namespace Tests\integration\Api\Autocomplete;
use Laravel\Passport\Passport;
use Log;
-use Tests\TestCase;
+use Tests\integration\TestCase;
/**
* Class AccountControllerTest
diff --git a/tests/CreatesApplication.php b/tests/integration/CreatesApplication.php
similarity index 97%
rename from tests/CreatesApplication.php
rename to tests/integration/CreatesApplication.php
index 22211a5905..1900ee8eb1 100644
--- a/tests/CreatesApplication.php
+++ b/tests/integration/CreatesApplication.php
@@ -20,7 +20,7 @@
*/
declare(strict_types=1);
-namespace Tests;
+namespace Tests\integration;
use Illuminate\Contracts\Console\Kernel;
use Illuminate\Foundation\Application;
diff --git a/tests/TestCase.php b/tests/integration/TestCase.php
similarity index 95%
rename from tests/TestCase.php
rename to tests/integration/TestCase.php
index 4e53124582..e0990a65b6 100644
--- a/tests/TestCase.php
+++ b/tests/integration/TestCase.php
@@ -21,10 +21,10 @@
*/
declare(strict_types=1);
-namespace Tests;
+namespace Tests\integration;
use Illuminate\Foundation\Testing\TestCase as BaseTestCase;
-use Tests\Traits\CollectsValues;
+use Tests\integration\Traits\CollectsValues;
/**
* Class TestCase
diff --git a/tests/Traits/CollectsValues.php b/tests/integration/Traits/CollectsValues.php
similarity index 96%
rename from tests/Traits/CollectsValues.php
rename to tests/integration/Traits/CollectsValues.php
index 33c6bfe647..cae0305ff3 100644
--- a/tests/Traits/CollectsValues.php
+++ b/tests/integration/Traits/CollectsValues.php
@@ -21,7 +21,7 @@
declare(strict_types=1);
-namespace Tests\Traits;
+namespace Tests\integration\Traits;
use FireflyIII\User;
diff --git a/tests/Support/Calendar/CalculatorProvider.php b/tests/unit/Support/Calendar/CalculatorProvider.php
similarity index 99%
rename from tests/Support/Calendar/CalculatorProvider.php
rename to tests/unit/Support/Calendar/CalculatorProvider.php
index 20e6172e1e..12f23d7363 100644
--- a/tests/Support/Calendar/CalculatorProvider.php
+++ b/tests/unit/Support/Calendar/CalculatorProvider.php
@@ -19,11 +19,11 @@
* along with this program. If not, see <https://www.gnu.org/licenses/>.
*/
-namespace Tests\Support\Calendar;
+namespace Tests\unit\Support\Calendar;
use Carbon\Carbon;
use FireflyIII\Support\Calendar\Periodicity;
-use Tests\Support\Calendar\Periodicity\IntervalProvider;
+use Tests\unit\Support\Calendar\Periodicity\IntervalProvider;
readonly class CalculatorProvider
{
diff --git a/tests/Support/Calendar/CalculatorTest.php b/tests/unit/Support/Calendar/CalculatorTest.php
similarity index 84%
rename from tests/Support/Calendar/CalculatorTest.php
rename to tests/unit/Support/Calendar/CalculatorTest.php
index d3a05fe0cf..a5c8162a01 100644
--- a/tests/Support/Calendar/CalculatorTest.php
+++ b/tests/unit/Support/Calendar/CalculatorTest.php
@@ -19,25 +19,28 @@
* along with this program. If not, see <https://www.gnu.org/licenses/>.
*/
-namespace Tests\Support\Calendar;
+namespace Tests\unit\Support\Calendar;
-use Carbon\Carbon;
-use FireflyIII\Api\V1\Controllers\Insight\Income\PeriodController;
use FireflyIII\Support\Calendar\Calculator;
use FireflyIII\Support\Calendar\Exceptions\IntervalException;
use FireflyIII\Support\Calendar\Periodicity;
-use FireflyIII\Support\Navigation;
-use Tests\Support\Calendar\Periodicity\BimonthlyTest;
-use Tests\Support\Calendar\Periodicity\DailyTest;
-use Tests\Support\Calendar\Periodicity\FortnightlyTest;
-use Tests\Support\Calendar\Periodicity\HalfYearlyTest;
-use Tests\Support\Calendar\Periodicity\IntervalProvider;
-use Tests\Support\Calendar\Periodicity\MonthlyTest;
-use Tests\Support\Calendar\Periodicity\QuarterlyTest;
-use Tests\Support\Calendar\Periodicity\WeeklyTest;
-use Tests\Support\Calendar\Periodicity\YearlyTest;
-use Tests\TestCase;
+use PHPUnit\Framework\TestCase;
+use Tests\unit\Support\Calendar\Periodicity\BimonthlyTest;
+use Tests\unit\Support\Calendar\Periodicity\DailyTest;
+use Tests\unit\Support\Calendar\Periodicity\FortnightlyTest;
+use Tests\unit\Support\Calendar\Periodicity\HalfYearlyTest;
+use Tests\unit\Support\Calendar\Periodicity\IntervalProvider;
+use Tests\unit\Support\Calendar\Periodicity\MonthlyTest;
+use Tests\unit\Support\Calendar\Periodicity\QuarterlyTest;
+use Tests\unit\Support\Calendar\Periodicity\WeeklyTest;
+use Tests\unit\Support\Calendar\Periodicity\YearlyTest;
+/**
+ * @group unit-test
+ * @group support
+ * @group calendar
+ * @group calculator
+ */
class CalculatorTest extends TestCase
{
private static function convert(Periodicity $periodicity, array $intervals): array
diff --git a/tests/Support/Calendar/Periodicity/BimonthlyTest.php b/tests/unit/Support/Calendar/Periodicity/BimonthlyTest.php
similarity index 93%
rename from tests/Support/Calendar/Periodicity/BimonthlyTest.php
rename to tests/unit/Support/Calendar/Periodicity/BimonthlyTest.php
index 90c46c59b5..e44b188e33 100644
--- a/tests/Support/Calendar/Periodicity/BimonthlyTest.php
+++ b/tests/unit/Support/Calendar/Periodicity/BimonthlyTest.php
@@ -19,12 +19,18 @@
* along with this program. If not, see <https://www.gnu.org/licenses/>.
*/
-namespace Tests\Support\Calendar\Periodicity;
+namespace Tests\unit\Support\Calendar\Periodicity;
use Carbon\Carbon;
use FireflyIII\Support\Calendar\Periodicity;
use FireflyIII\Support\Calendar\Periodicity\Interval;
+/**
+ * @group unit-test
+ * @group support
+ * @group calendar
+ * @group periodicity
+ */
class BimonthlyTest extends IntervalTestCase
{
public static function factory(): Interval
diff --git a/tests/Support/Calendar/Periodicity/DailyTest.php b/tests/unit/Support/Calendar/Periodicity/DailyTest.php
similarity index 90%
rename from tests/Support/Calendar/Periodicity/DailyTest.php
rename to tests/unit/Support/Calendar/Periodicity/DailyTest.php
index b4f25f2e5e..56169a646b 100644
--- a/tests/Support/Calendar/Periodicity/DailyTest.php
+++ b/tests/unit/Support/Calendar/Periodicity/DailyTest.php
@@ -19,12 +19,18 @@
* along with this program. If not, see <https://www.gnu.org/licenses/>.
*/
-namespace Tests\Support\Calendar\Periodicity;
+namespace Tests\unit\Support\Calendar\Periodicity;
use Carbon\Carbon;
use FireflyIII\Support\Calendar\Periodicity;
use FireflyIII\Support\Calendar\Periodicity\Interval;
+/**
+ * @group unit-test
+ * @group support
+ * @group calendar
+ * @group periodicity
+ */
class DailyTest extends IntervalTestCase
{
public static function factory(): Interval
diff --git a/tests/Support/Calendar/Periodicity/FortnightlyTest.php b/tests/unit/Support/Calendar/Periodicity/FortnightlyTest.php
similarity index 90%
rename from tests/Support/Calendar/Periodicity/FortnightlyTest.php
rename to tests/unit/Support/Calendar/Periodicity/FortnightlyTest.php
index e28b818e92..abc63993ec 100644
--- a/tests/Support/Calendar/Periodicity/FortnightlyTest.php
+++ b/tests/unit/Support/Calendar/Periodicity/FortnightlyTest.php
@@ -19,12 +19,18 @@
* along with this program. If not, see <https://www.gnu.org/licenses/>.
*/
-namespace Tests\Support\Calendar\Periodicity;
+namespace Tests\unit\Support\Calendar\Periodicity;
use Carbon\Carbon;
use FireflyIII\Support\Calendar\Periodicity;
use FireflyIII\Support\Calendar\Periodicity\Interval;
+/**
+ * @group unit-test
+ * @group support
+ * @group calendar
+ * @group periodicity
+ */
class FortnightlyTest extends IntervalTestCase
{
public static function factory(): Interval
diff --git a/tests/Support/Calendar/Periodicity/HalfYearlyTest.php b/tests/unit/Support/Calendar/Periodicity/HalfYearlyTest.php
similarity index 93%
rename from tests/Support/Calendar/Periodicity/HalfYearlyTest.php
rename to tests/unit/Support/Calendar/Periodicity/HalfYearlyTest.php
index 08da7027c7..fa15fbfc35 100644
--- a/tests/Support/Calendar/Periodicity/HalfYearlyTest.php
+++ b/tests/unit/Support/Calendar/Periodicity/HalfYearlyTest.php
@@ -19,12 +19,18 @@
* along with this program. If not, see <https://www.gnu.org/licenses/>.
*/
-namespace Tests\Support\Calendar\Periodicity;
+namespace Tests\unit\Support\Calendar\Periodicity;
use Carbon\Carbon;
use FireflyIII\Support\Calendar\Periodicity;
use FireflyIII\Support\Calendar\Periodicity\Interval;
+/**
+ * @group unit-test
+ * @group support
+ * @group calendar
+ * @group periodicity
+ */
class HalfYearlyTest extends IntervalTestCase
{
public static function factory(): Interval
diff --git a/tests/Support/Calendar/Periodicity/IntervalProvider.php b/tests/unit/Support/Calendar/Periodicity/IntervalProvider.php
similarity index 95%
rename from tests/Support/Calendar/Periodicity/IntervalProvider.php
rename to tests/unit/Support/Calendar/Periodicity/IntervalProvider.php
index 4725885d26..2c62f5802f 100644
--- a/tests/Support/Calendar/Periodicity/IntervalProvider.php
+++ b/tests/unit/Support/Calendar/Periodicity/IntervalProvider.php
@@ -19,7 +19,7 @@
* along with this program. If not, see <https://www.gnu.org/licenses/>.
*/
-namespace Tests\Support\Calendar\Periodicity;
+namespace Tests\unit\Support\Calendar\Periodicity;
use Carbon\Carbon;
diff --git a/tests/Support/Calendar/Periodicity/IntervalTestCase.php b/tests/unit/Support/Calendar/Periodicity/IntervalTestCase.php
similarity index 95%
rename from tests/Support/Calendar/Periodicity/IntervalTestCase.php
rename to tests/unit/Support/Calendar/Periodicity/IntervalTestCase.php
index d5db1d901e..a0cf5bb124 100644
--- a/tests/Support/Calendar/Periodicity/IntervalTestCase.php
+++ b/tests/unit/Support/Calendar/Periodicity/IntervalTestCase.php
@@ -19,10 +19,10 @@
* along with this program. If not, see <https://www.gnu.org/licenses/>.
*/
-namespace Tests\Support\Calendar\Periodicity;
+namespace Tests\unit\Support\Calendar\Periodicity;
use FireflyIII\Support\Calendar\Periodicity\Interval;
-use Tests\TestCase;
+use PHPUnit\Framework\TestCase;
abstract class IntervalTestCase extends TestCase
{
diff --git a/tests/Support/Calendar/Periodicity/MonthlyTest.php b/tests/unit/Support/Calendar/Periodicity/MonthlyTest.php
similarity index 94%
rename from tests/Support/Calendar/Periodicity/MonthlyTest.php
rename to tests/unit/Support/Calendar/Periodicity/MonthlyTest.php
index fab8785a4a..a9fe75d15d 100644
--- a/tests/Support/Calendar/Periodicity/MonthlyTest.php
+++ b/tests/unit/Support/Calendar/Periodicity/MonthlyTest.php
@@ -19,12 +19,18 @@
* along with this program. If not, see <https://www.gnu.org/licenses/>.
*/
-namespace Tests\Support\Calendar\Periodicity;
+namespace Tests\unit\Support\Calendar\Periodicity;
use Carbon\Carbon;
use FireflyIII\Support\Calendar\Periodicity;
use FireflyIII\Support\Calendar\Periodicity\Interval;
+/**
+ * @group unit-test
+ * @group support
+ * @group calendar
+ * @group periodicity
+ */
class MonthlyTest extends IntervalTestCase
{
public static function factory(): Interval
diff --git a/tests/Support/Calendar/Periodicity/QuarterlyTest.php b/tests/unit/Support/Calendar/Periodicity/QuarterlyTest.php
similarity index 93%
rename from tests/Support/Calendar/Periodicity/QuarterlyTest.php
rename to tests/unit/Support/Calendar/Periodicity/QuarterlyTest.php
index 22a527e109..093276bcb1 100644
--- a/tests/Support/Calendar/Periodicity/QuarterlyTest.php
+++ b/tests/unit/Support/Calendar/Periodicity/QuarterlyTest.php
@@ -19,12 +19,18 @@
* along with this program. If not, see <https://www.gnu.org/licenses/>.
*/
-namespace Tests\Support\Calendar\Periodicity;
+namespace Tests\unit\Support\Calendar\Periodicity;
use Carbon\Carbon;
use FireflyIII\Support\Calendar\Periodicity;
use FireflyIII\Support\Calendar\Periodicity\Interval;
+/**
+ * @group unit-test
+ * @group support
+ * @group calendar
+ * @group periodicity
+ */
class QuarterlyTest extends IntervalTestCase
{
public static function factory(): Interval
diff --git a/tests/Support/Calendar/Periodicity/WeeklyTest.php b/tests/unit/Support/Calendar/Periodicity/WeeklyTest.php
similarity index 90%
rename from tests/Support/Calendar/Periodicity/WeeklyTest.php
rename to tests/unit/Support/Calendar/Periodicity/WeeklyTest.php
index b889e977cd..b2fa868518 100644
--- a/tests/Support/Calendar/Periodicity/WeeklyTest.php
+++ b/tests/unit/Support/Calendar/Periodicity/WeeklyTest.php
@@ -19,12 +19,18 @@
* along with this program. If not, see <https://www.gnu.org/licenses/>.
*/
-namespace Tests\Support\Calendar\Periodicity;
+namespace Tests\unit\Support\Calendar\Periodicity;
use Carbon\Carbon;
use FireflyIII\Support\Calendar\Periodicity;
use FireflyIII\Support\Calendar\Periodicity\Interval;
+/**
+ * @group unit-test
+ * @group support
+ * @group calendar
+ * @group periodicity
+ */
class WeeklyTest extends IntervalTestCase
{
public static function factory(): Interval
diff --git a/tests/Support/Calendar/Periodicity/YearlyTest.php b/tests/unit/Support/Calendar/Periodicity/YearlyTest.php
similarity index 91%
rename from tests/Support/Calendar/Periodicity/YearlyTest.php
rename to tests/unit/Support/Calendar/Periodicity/YearlyTest.php
index b7f143fd62..fb8e70d9d1 100644
--- a/tests/Support/Calendar/Periodicity/YearlyTest.php
+++ b/tests/unit/Support/Calendar/Periodicity/YearlyTest.php
@@ -19,12 +19,18 @@
* along with this program. If not, see <https://www.gnu.org/licenses/>.
*/
-namespace Tests\Support\Calendar\Periodicity;
+namespace Tests\unit\Support\Calendar\Periodicity;
use Carbon\Carbon;
use FireflyIII\Support\Calendar\Periodicity;
use FireflyIII\Support\Calendar\Periodicity\Interval;
+/**
+ * @group unit-test
+ * @group support
+ * @group calendar
+ * @group periodicity
+ */
class YearlyTest extends IntervalTestCase
{
public static function factory(): Interval
diff --git a/tests/Support/NavigationTest.php b/tests/unit/Support/NavigationTest.php
similarity index 99%
rename from tests/Support/NavigationTest.php
rename to tests/unit/Support/NavigationTest.php
index 5ffdd0dd10..6ad2a395dd 100644
--- a/tests/Support/NavigationTest.php
+++ b/tests/unit/Support/NavigationTest.php
@@ -1,12 +1,17 @@
<?php
-namespace Tests\Support;
+namespace Tests\unit\Support;
use Carbon\Carbon;
use FireflyIII\Support\Calendar\Periodicity;
use FireflyIII\Support\Navigation;
-use Tests\TestCase;
+use PHPUnit\Framework\TestCase;
+/**
+ * @group unit-test
+ * @group support
+ * @group navigation
+ */
class NavigationTest extends TestCase
{
private Navigation $navigation;