Organize test suites into unit and integration

This is the goals of project organization composing different
combinations to run any number of tests together.
This commit is contained in:
Antonio Spinelli
2023-07-03 11:08:24 -03:00
parent 6ac3cc384b
commit 7f0db0de04
19 changed files with 102 additions and 37 deletions

View File

@@ -168,6 +168,12 @@
"post-install-cmd": [ "post-install-cmd": [
"@php artisan firefly:instructions install", "@php artisan firefly:instructions install",
"@php artisan firefly-iii:verify-security-alerts" "@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": { "config": {

View File

@@ -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"> <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/> <coverage/>
<testsuites> <testsuites>
<testsuite name="Api"> <testsuite name="unit">
<directory suffix="Test.php">./tests</directory> <directory suffix="Test.php">./tests/unit</directory>
</testsuite>
<testsuite name="integration">
<directory suffix="Test.php">./tests/integration</directory>
</testsuite> </testsuite>
</testsuites> </testsuites>
<php> <php>

View File

@@ -21,11 +21,11 @@
declare(strict_types=1); declare(strict_types=1);
namespace Tests\Api\Autocomplete; namespace Tests\integration\Api\Autocomplete;
use Laravel\Passport\Passport; use Laravel\Passport\Passport;
use Log; use Log;
use Tests\TestCase; use Tests\integration\TestCase;
/** /**
* Class AccountControllerTest * Class AccountControllerTest

View File

@@ -20,7 +20,7 @@
*/ */
declare(strict_types=1); declare(strict_types=1);
namespace Tests; namespace Tests\integration;
use Illuminate\Contracts\Console\Kernel; use Illuminate\Contracts\Console\Kernel;
use Illuminate\Foundation\Application; use Illuminate\Foundation\Application;

View File

@@ -21,10 +21,10 @@
*/ */
declare(strict_types=1); declare(strict_types=1);
namespace Tests; namespace Tests\integration;
use Illuminate\Foundation\Testing\TestCase as BaseTestCase; use Illuminate\Foundation\Testing\TestCase as BaseTestCase;
use Tests\Traits\CollectsValues; use Tests\integration\Traits\CollectsValues;
/** /**
* Class TestCase * Class TestCase

View File

@@ -21,7 +21,7 @@
declare(strict_types=1); declare(strict_types=1);
namespace Tests\Traits; namespace Tests\integration\Traits;
use FireflyIII\User; use FireflyIII\User;

View File

@@ -19,11 +19,11 @@
* along with this program. If not, see <https://www.gnu.org/licenses/>. * 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 Carbon\Carbon;
use FireflyIII\Support\Calendar\Periodicity; use FireflyIII\Support\Calendar\Periodicity;
use Tests\Support\Calendar\Periodicity\IntervalProvider; use Tests\unit\Support\Calendar\Periodicity\IntervalProvider;
readonly class CalculatorProvider readonly class CalculatorProvider
{ {

View File

@@ -19,25 +19,28 @@
* along with this program. If not, see <https://www.gnu.org/licenses/>. * 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\Calculator;
use FireflyIII\Support\Calendar\Exceptions\IntervalException; use FireflyIII\Support\Calendar\Exceptions\IntervalException;
use FireflyIII\Support\Calendar\Periodicity; use FireflyIII\Support\Calendar\Periodicity;
use FireflyIII\Support\Navigation; use PHPUnit\Framework\TestCase;
use Tests\Support\Calendar\Periodicity\BimonthlyTest; use Tests\unit\Support\Calendar\Periodicity\BimonthlyTest;
use Tests\Support\Calendar\Periodicity\DailyTest; use Tests\unit\Support\Calendar\Periodicity\DailyTest;
use Tests\Support\Calendar\Periodicity\FortnightlyTest; use Tests\unit\Support\Calendar\Periodicity\FortnightlyTest;
use Tests\Support\Calendar\Periodicity\HalfYearlyTest; use Tests\unit\Support\Calendar\Periodicity\HalfYearlyTest;
use Tests\Support\Calendar\Periodicity\IntervalProvider; use Tests\unit\Support\Calendar\Periodicity\IntervalProvider;
use Tests\Support\Calendar\Periodicity\MonthlyTest; use Tests\unit\Support\Calendar\Periodicity\MonthlyTest;
use Tests\Support\Calendar\Periodicity\QuarterlyTest; use Tests\unit\Support\Calendar\Periodicity\QuarterlyTest;
use Tests\Support\Calendar\Periodicity\WeeklyTest; use Tests\unit\Support\Calendar\Periodicity\WeeklyTest;
use Tests\Support\Calendar\Periodicity\YearlyTest; use Tests\unit\Support\Calendar\Periodicity\YearlyTest;
use Tests\TestCase;
/**
* @group unit-test
* @group support
* @group calendar
* @group calculator
*/
class CalculatorTest extends TestCase class CalculatorTest extends TestCase
{ {
private static function convert(Periodicity $periodicity, array $intervals): array private static function convert(Periodicity $periodicity, array $intervals): array

View File

@@ -19,12 +19,18 @@
* along with this program. If not, see <https://www.gnu.org/licenses/>. * 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 Carbon\Carbon;
use FireflyIII\Support\Calendar\Periodicity; use FireflyIII\Support\Calendar\Periodicity;
use FireflyIII\Support\Calendar\Periodicity\Interval; use FireflyIII\Support\Calendar\Periodicity\Interval;
/**
* @group unit-test
* @group support
* @group calendar
* @group periodicity
*/
class BimonthlyTest extends IntervalTestCase class BimonthlyTest extends IntervalTestCase
{ {
public static function factory(): Interval public static function factory(): Interval

View File

@@ -19,12 +19,18 @@
* along with this program. If not, see <https://www.gnu.org/licenses/>. * 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 Carbon\Carbon;
use FireflyIII\Support\Calendar\Periodicity; use FireflyIII\Support\Calendar\Periodicity;
use FireflyIII\Support\Calendar\Periodicity\Interval; use FireflyIII\Support\Calendar\Periodicity\Interval;
/**
* @group unit-test
* @group support
* @group calendar
* @group periodicity
*/
class DailyTest extends IntervalTestCase class DailyTest extends IntervalTestCase
{ {
public static function factory(): Interval public static function factory(): Interval

View File

@@ -19,12 +19,18 @@
* along with this program. If not, see <https://www.gnu.org/licenses/>. * 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 Carbon\Carbon;
use FireflyIII\Support\Calendar\Periodicity; use FireflyIII\Support\Calendar\Periodicity;
use FireflyIII\Support\Calendar\Periodicity\Interval; use FireflyIII\Support\Calendar\Periodicity\Interval;
/**
* @group unit-test
* @group support
* @group calendar
* @group periodicity
*/
class FortnightlyTest extends IntervalTestCase class FortnightlyTest extends IntervalTestCase
{ {
public static function factory(): Interval public static function factory(): Interval

View File

@@ -19,12 +19,18 @@
* along with this program. If not, see <https://www.gnu.org/licenses/>. * 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 Carbon\Carbon;
use FireflyIII\Support\Calendar\Periodicity; use FireflyIII\Support\Calendar\Periodicity;
use FireflyIII\Support\Calendar\Periodicity\Interval; use FireflyIII\Support\Calendar\Periodicity\Interval;
/**
* @group unit-test
* @group support
* @group calendar
* @group periodicity
*/
class HalfYearlyTest extends IntervalTestCase class HalfYearlyTest extends IntervalTestCase
{ {
public static function factory(): Interval public static function factory(): Interval

View File

@@ -19,7 +19,7 @@
* along with this program. If not, see <https://www.gnu.org/licenses/>. * 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 Carbon\Carbon;

View File

@@ -19,10 +19,10 @@
* along with this program. If not, see <https://www.gnu.org/licenses/>. * 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 FireflyIII\Support\Calendar\Periodicity\Interval;
use Tests\TestCase; use PHPUnit\Framework\TestCase;
abstract class IntervalTestCase extends TestCase abstract class IntervalTestCase extends TestCase
{ {

View File

@@ -19,12 +19,18 @@
* along with this program. If not, see <https://www.gnu.org/licenses/>. * 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 Carbon\Carbon;
use FireflyIII\Support\Calendar\Periodicity; use FireflyIII\Support\Calendar\Periodicity;
use FireflyIII\Support\Calendar\Periodicity\Interval; use FireflyIII\Support\Calendar\Periodicity\Interval;
/**
* @group unit-test
* @group support
* @group calendar
* @group periodicity
*/
class MonthlyTest extends IntervalTestCase class MonthlyTest extends IntervalTestCase
{ {
public static function factory(): Interval public static function factory(): Interval

View File

@@ -19,12 +19,18 @@
* along with this program. If not, see <https://www.gnu.org/licenses/>. * 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 Carbon\Carbon;
use FireflyIII\Support\Calendar\Periodicity; use FireflyIII\Support\Calendar\Periodicity;
use FireflyIII\Support\Calendar\Periodicity\Interval; use FireflyIII\Support\Calendar\Periodicity\Interval;
/**
* @group unit-test
* @group support
* @group calendar
* @group periodicity
*/
class QuarterlyTest extends IntervalTestCase class QuarterlyTest extends IntervalTestCase
{ {
public static function factory(): Interval public static function factory(): Interval

View File

@@ -19,12 +19,18 @@
* along with this program. If not, see <https://www.gnu.org/licenses/>. * 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 Carbon\Carbon;
use FireflyIII\Support\Calendar\Periodicity; use FireflyIII\Support\Calendar\Periodicity;
use FireflyIII\Support\Calendar\Periodicity\Interval; use FireflyIII\Support\Calendar\Periodicity\Interval;
/**
* @group unit-test
* @group support
* @group calendar
* @group periodicity
*/
class WeeklyTest extends IntervalTestCase class WeeklyTest extends IntervalTestCase
{ {
public static function factory(): Interval public static function factory(): Interval

View File

@@ -19,12 +19,18 @@
* along with this program. If not, see <https://www.gnu.org/licenses/>. * 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 Carbon\Carbon;
use FireflyIII\Support\Calendar\Periodicity; use FireflyIII\Support\Calendar\Periodicity;
use FireflyIII\Support\Calendar\Periodicity\Interval; use FireflyIII\Support\Calendar\Periodicity\Interval;
/**
* @group unit-test
* @group support
* @group calendar
* @group periodicity
*/
class YearlyTest extends IntervalTestCase class YearlyTest extends IntervalTestCase
{ {
public static function factory(): Interval public static function factory(): Interval

View File

@@ -1,12 +1,17 @@
<?php <?php
namespace Tests\Support; namespace Tests\unit\Support;
use Carbon\Carbon; use Carbon\Carbon;
use FireflyIII\Support\Calendar\Periodicity; use FireflyIII\Support\Calendar\Periodicity;
use FireflyIII\Support\Navigation; use FireflyIII\Support\Navigation;
use Tests\TestCase; use PHPUnit\Framework\TestCase;
/**
* @group unit-test
* @group support
* @group navigation
*/
class NavigationTest extends TestCase class NavigationTest extends TestCase
{ {
private Navigation $navigation; private Navigation $navigation;