This commit is contained in:
parent
2273c91f2b
commit
af9354ff22
20 changed files with 1687 additions and 570 deletions
|
@ -4,4 +4,3 @@ APP_SECRET='$ecretf0rt3st'
|
|||
SYMFONY_DEPRECATIONS_HELPER=999999
|
||||
PANTHER_APP_ENV=panther
|
||||
PANTHER_ERROR_SCREENSHOT_DIR=./var/error-screenshots
|
||||
DATABASE_URL="sqlite:///%kernel.project_dir%/var/test-data.db"
|
||||
|
|
19
.gitignore
vendored
19
.gitignore
vendored
|
@ -1,4 +1,3 @@
|
|||
|
||||
###> symfony/framework-bundle ###
|
||||
/.env.local
|
||||
/.env.local.php
|
||||
|
@ -8,17 +7,13 @@
|
|||
/var/
|
||||
/vendor/
|
||||
###< symfony/framework-bundle ###
|
||||
|
||||
###> symfony/phpunit-bridge ###
|
||||
.phpunit.result.cache
|
||||
/phpunit.xml
|
||||
###< symfony/phpunit-bridge ###
|
||||
|
||||
###> phpunit/phpunit ###
|
||||
/phpunit.xml
|
||||
.phpunit.result.cache
|
||||
###< phpunit/phpunit ###
|
||||
|
||||
.idea/
|
||||
/deploy/var/
|
||||
/deploy/app/
|
||||
|
||||
###> phpunit/phpunit ###
|
||||
.phpunit.result.cache
|
||||
.phpunit.cache
|
||||
###< phpunit/phpunit ###
|
||||
|
||||
.DS_Store
|
||||
|
|
23
bin/phpunit
23
bin/phpunit
|
@ -1,23 +0,0 @@
|
|||
#!/usr/bin/env php
|
||||
<?php
|
||||
|
||||
if (!ini_get('date.timezone')) {
|
||||
ini_set('date.timezone', 'UTC');
|
||||
}
|
||||
|
||||
if (is_file(dirname(__DIR__).'/vendor/phpunit/phpunit/phpunit')) {
|
||||
if (PHP_VERSION_ID >= 80000) {
|
||||
require dirname(__DIR__).'/vendor/phpunit/phpunit/phpunit';
|
||||
} else {
|
||||
define('PHPUNIT_COMPOSER_INSTALL', dirname(__DIR__).'/vendor/autoload.php');
|
||||
require PHPUNIT_COMPOSER_INSTALL;
|
||||
PHPUnit\TextUI\Command::main();
|
||||
}
|
||||
} else {
|
||||
if (!is_file(dirname(__DIR__).'/vendor/symfony/phpunit-bridge/bin/simple-phpunit.php')) {
|
||||
echo "Unable to find the `simple-phpunit.php` script in `vendor/symfony/phpunit-bridge/bin/`.\n";
|
||||
exit(1);
|
||||
}
|
||||
|
||||
require dirname(__DIR__).'/vendor/symfony/phpunit-bridge/bin/simple-phpunit.php';
|
||||
}
|
|
@ -27,21 +27,21 @@
|
|||
"require-dev": {
|
||||
"doctrine/doctrine-fixtures-bundle": "^4.0",
|
||||
"lubiana/code-quality": "^1.7.2",
|
||||
"phpunit/phpunit": "^9.6.20",
|
||||
"pestphp/pest": "^3.6",
|
||||
"symfony/browser-kit": "7.2.*",
|
||||
"symfony/css-selector": "7.2.*",
|
||||
"symfony/maker-bundle": "^1.60",
|
||||
"symfony/phpunit-bridge": "7.2.*",
|
||||
"symfony/stopwatch": "7.2.*",
|
||||
"symfony/web-profiler-bundle": "7.2.*",
|
||||
"symplify/config-transformer": "^12.3.4"
|
||||
},
|
||||
"config": {
|
||||
"allow-plugins": {
|
||||
"dealerdirect/phpcodesniffer-composer-installer": true,
|
||||
"pestphp/pest-plugin": true,
|
||||
"php-http/discovery": true,
|
||||
"symfony/flex": true,
|
||||
"symfony/runtime": true,
|
||||
"dealerdirect/phpcodesniffer-composer-installer": true
|
||||
"symfony/runtime": true
|
||||
},
|
||||
"sort-packages": true,
|
||||
"platform": {
|
||||
|
@ -85,7 +85,7 @@
|
|||
"rector",
|
||||
"ecs --fix || ecs --fix"
|
||||
],
|
||||
"test": "bin/phpunit"
|
||||
"test": "pest"
|
||||
},
|
||||
"conflict": {
|
||||
"symfony/symfony": "*"
|
||||
|
|
1995
composer.lock
generated
1995
composer.lock
generated
File diff suppressed because it is too large
Load diff
|
@ -1,20 +0,0 @@
|
|||
{
|
||||
"$schema": "vendor/infection/infection/resources/schema.json",
|
||||
"source": {
|
||||
"directories": [
|
||||
"src"
|
||||
]
|
||||
},
|
||||
"timeout": 30,
|
||||
"logs": {
|
||||
"text": "var/log/infection.txt",
|
||||
"summary": "var/log/summary.log",
|
||||
},
|
||||
"mutators": {
|
||||
"@default": true,
|
||||
"global-ignore": [
|
||||
"App\\Service\\Favicon::__toString",
|
||||
"ORM\\Column.*"
|
||||
]
|
||||
}
|
||||
}
|
35
phpunit.xml
Normal file
35
phpunit.xml
Normal file
|
@ -0,0 +1,35 @@
|
|||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<phpunit xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
||||
xsi:noNamespaceSchemaLocation="vendor/phpunit/phpunit/phpunit.xsd"
|
||||
bootstrap="tests/bootstrap.php"
|
||||
cacheDirectory=".phpunit.cache"
|
||||
executionOrder="depends,defects"
|
||||
shortenArraysForExportThreshold="10"
|
||||
requireCoverageMetadata="false"
|
||||
beStrictAboutCoverageMetadata="true"
|
||||
beStrictAboutOutputDuringTests="true"
|
||||
displayDetailsOnPhpunitDeprecations="true"
|
||||
failOnPhpunitDeprecation="true"
|
||||
failOnRisky="true"
|
||||
failOnWarning="true">
|
||||
<testsuites>
|
||||
<testsuite name="default">
|
||||
<directory>tests/Controller</directory>
|
||||
<directory>tests/Entity</directory>
|
||||
</testsuite>
|
||||
</testsuites>
|
||||
|
||||
<source ignoreIndirectDeprecations="true" restrictNotices="true" restrictWarnings="true">
|
||||
<include>
|
||||
<directory>src</directory>
|
||||
</include>
|
||||
<exclude>
|
||||
<file>src/Kernel.php</file>
|
||||
<file>src/Service/Favicon.php</file>
|
||||
</exclude>
|
||||
</source>
|
||||
<php>
|
||||
<env name="APP_ENV" value="test" />
|
||||
<env name="KERNEL_CLASS" value="App\Kernel" />
|
||||
</php>
|
||||
</phpunit>
|
|
@ -6,9 +6,7 @@
|
|||
backupGlobals="false"
|
||||
colors="true"
|
||||
bootstrap="tests/bootstrap.php"
|
||||
convertDeprecationsToExceptions="true"
|
||||
executionOrder="random"
|
||||
resolveDependencies="true"
|
||||
convertDeprecationsToExceptions="false"
|
||||
>
|
||||
<php>
|
||||
<ini name="display_errors" value="1" />
|
||||
|
@ -16,8 +14,7 @@
|
|||
<server name="APP_ENV" value="test" force="true" />
|
||||
<server name="SHELL_VERBOSITY" value="-1" />
|
||||
<server name="SYMFONY_PHPUNIT_REMOVE" value="" />
|
||||
<server name="SYMFONY_PHPUNIT_VERSION" value="9.6" />
|
||||
<server name="KERNEL_CLASS" value="App\Kernel" />
|
||||
<server name="SYMFONY_PHPUNIT_VERSION" value="9.5" />
|
||||
</php>
|
||||
|
||||
<testsuites>
|
||||
|
|
|
@ -8,4 +8,15 @@ use Symfony\Component\HttpKernel\Kernel as BaseKernel;
|
|||
final class Kernel extends BaseKernel
|
||||
{
|
||||
use MicroKernelTrait;
|
||||
|
||||
public function __construct(
|
||||
protected string $environment,
|
||||
protected bool $debug,
|
||||
) {
|
||||
parent::__construct($environment, $debug);
|
||||
if ($environment === 'test') {
|
||||
$this->debug = false;
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
|
17
symfony.lock
17
symfony.lock
|
@ -48,7 +48,7 @@
|
|||
}
|
||||
},
|
||||
"phpunit/phpunit": {
|
||||
"version": "9.6",
|
||||
"version": "11.4",
|
||||
"recipe": {
|
||||
"repo": "github.com/symfony/recipes",
|
||||
"branch": "main",
|
||||
|
@ -122,21 +122,6 @@
|
|||
"ref": "fadbfe33303a76e25cb63401050439aa9b1a9c7f"
|
||||
}
|
||||
},
|
||||
"symfony/phpunit-bridge": {
|
||||
"version": "7.1",
|
||||
"recipe": {
|
||||
"repo": "github.com/symfony/recipes",
|
||||
"branch": "main",
|
||||
"version": "6.3",
|
||||
"ref": "a411a0480041243d97382cac7984f7dce7813c08"
|
||||
},
|
||||
"files": [
|
||||
".env.test",
|
||||
"bin/phpunit",
|
||||
"phpunit.xml.dist",
|
||||
"tests/bootstrap.php"
|
||||
]
|
||||
},
|
||||
"symfony/routing": {
|
||||
"version": "7.1",
|
||||
"recipe": {
|
||||
|
|
|
@ -2,12 +2,18 @@
|
|||
|
||||
namespace App\Tests\Controller;
|
||||
|
||||
use App\Controller\FoodOrderController;
|
||||
use App\Entity\FoodOrder;
|
||||
use App\Entity\FoodVendor;
|
||||
use App\Entity\MenuItem;
|
||||
use App\Entity\OrderItem;
|
||||
use App\Form\FoodOrderType;
|
||||
use App\Repository\FoodOrderRepository;
|
||||
use App\Repository\FoodVendorRepository;
|
||||
use App\Tests\DbWebTest;
|
||||
use App\Tests\Entity\FoodOrderTest;
|
||||
use Override;
|
||||
use PHPUnit\Framework\Attributes\CoversClass;
|
||||
use Symfony\Component\BrowserKit\Cookie;
|
||||
use Symfony\Component\DomCrawler\Crawler;
|
||||
|
||||
|
@ -16,6 +22,15 @@ use function range;
|
|||
use function sprintf;
|
||||
use function str_ends_with;
|
||||
|
||||
#[CoversClass(FoodOrderController::class)]
|
||||
#[CoversClass(FoodOrder::class)]
|
||||
#[CoversClass(FoodOrderTest::class)]
|
||||
#[CoversClass(FoodVendor::class)]
|
||||
#[CoversClass(FoodOrderRepository::class)]
|
||||
#[CoversCLass(MenuItem::class)]
|
||||
#[CoversClass(OrderItem::class)]
|
||||
#[CoversClass(FoodOrderType::class)]
|
||||
#[CoversClass(FoodVendorRepository::class)]
|
||||
final class FoodOrderControllerTest extends DbWebTest
|
||||
{
|
||||
private string $path = '/food/order/';
|
||||
|
|
|
@ -2,13 +2,32 @@
|
|||
|
||||
namespace App\Tests\Controller;
|
||||
|
||||
use App\Controller\FoodVendorController;
|
||||
use App\Entity\FoodOrder;
|
||||
use App\Entity\FoodVendor;
|
||||
use App\Entity\MenuItem;
|
||||
use App\Entity\OrderItem;
|
||||
use App\Form\FoodOrderType;
|
||||
use App\Form\FoodVendorType;
|
||||
use App\Repository\FoodOrderRepository;
|
||||
use App\Repository\FoodVendorRepository;
|
||||
use App\Tests\DbWebTest;
|
||||
use App\Tests\Entity\FoodOrderTest;
|
||||
use Override;
|
||||
use PHPUnit\Framework\Attributes\CoversClass;
|
||||
|
||||
use function sprintf;
|
||||
|
||||
#[CoversClass(FoodOrder::class)]
|
||||
#[CoversClass(FoodOrderTest::class)]
|
||||
#[CoversClass(FoodVendor::class)]
|
||||
#[CoversClass(FoodOrderRepository::class)]
|
||||
#[CoversCLass(MenuItem::class)]
|
||||
#[CoversClass(OrderItem::class)]
|
||||
#[CoversClass(FoodOrderType::class)]
|
||||
#[CoversClass(FoodVendorRepository::class)]
|
||||
#[CoversClass(FoodVendorController::class)]
|
||||
#[CoversClass(FoodVendorType::class)]
|
||||
final class FoodVendorControllerTest extends DbWebTest
|
||||
{
|
||||
private string $path = '/food/vendor/';
|
||||
|
|
|
@ -2,9 +2,14 @@
|
|||
|
||||
namespace App\Tests\Controller;
|
||||
|
||||
use App\Controller\HomeController;
|
||||
use App\Form\UserNameFormType;
|
||||
use App\Tests\DbWebTest;
|
||||
use Override;
|
||||
use PHPUnit\Framework\Attributes\CoversClass;
|
||||
|
||||
#[CoversClass(HomeController::class)]
|
||||
#[CoversClass(UserNameFormType::class)]
|
||||
final class HomeControllerTest extends DbWebTest
|
||||
{
|
||||
public function testIndex(): void
|
||||
|
|
|
@ -2,14 +2,32 @@
|
|||
|
||||
namespace App\Tests\Controller;
|
||||
|
||||
use App\Controller\MenuItemController;
|
||||
use App\Controller\OrderItemController;
|
||||
use App\Entity\FoodOrder;
|
||||
use App\Entity\FoodVendor;
|
||||
use App\Entity\MenuItem;
|
||||
use App\Entity\OrderItem;
|
||||
use App\Form\MenuItemType;
|
||||
use App\Form\OrderItemType;
|
||||
use App\Repository\FoodOrderRepository;
|
||||
use App\Repository\MenuItemRepository;
|
||||
use App\Tests\DbWebTest;
|
||||
use Override;
|
||||
use PHPUnit\Framework\Attributes\CoversClass;
|
||||
|
||||
use function sprintf;
|
||||
|
||||
#[CoversClass(MenuItemController::class)]
|
||||
#[CoversClass(OrderItemController::class)]
|
||||
#[CoversClass(OrderItemType::class)]
|
||||
#[CoversClass(MenuItemRepository::class)]
|
||||
#[CoversClass(FoodOrder::class)]
|
||||
#[CoversClass(FoodVendor::class)]
|
||||
#[CoversClass(MenuItem::class)]
|
||||
#[CoversClass(OrderItem::class)]
|
||||
#[CoversClass(FoodOrderRepository::class)]
|
||||
#[CoversClass(MenuItemType::class)]
|
||||
final class MenuItemControllerTest extends DbWebTest
|
||||
{
|
||||
private string $path = '/menu/item/';
|
||||
|
|
|
@ -2,17 +2,31 @@
|
|||
|
||||
namespace App\Tests\Controller;
|
||||
|
||||
use App\Controller\OrderItemController;
|
||||
use App\Entity\FoodOrder;
|
||||
use App\Entity\FoodVendor;
|
||||
use App\Entity\MenuItem;
|
||||
use App\Entity\OrderItem;
|
||||
use App\Form\OrderItemType;
|
||||
use App\Repository\FoodOrderRepository;
|
||||
use App\Repository\MenuItemRepository;
|
||||
use App\Repository\OrderItemRepository;
|
||||
use App\Tests\DbWebTest;
|
||||
use DateTimeImmutable;
|
||||
use Override;
|
||||
use PHPUnit\Framework\Attributes\CoversClass;
|
||||
|
||||
use function sprintf;
|
||||
|
||||
#[CoversClass(OrderItemController::class)]
|
||||
#[CoversClass(MenuItemRepository::class)]
|
||||
#[CoversClass(OrderItemRepository::class)]
|
||||
#[CoversClass(OrderItemType::class)]
|
||||
#[CoversClass(FoodOrder::class)]
|
||||
#[CoversClass(FoodVendor::class)]
|
||||
#[CoversClass(MenuItem::class)]
|
||||
#[CoversClass(OrderItem::class)]
|
||||
#[CoversClass(FoodOrderRepository::class)]
|
||||
final class OrderItemControllerTest extends DbWebTest
|
||||
{
|
||||
public FoodVendor $vendor;
|
||||
|
|
|
@ -4,8 +4,11 @@ namespace App\Tests\Entity;
|
|||
|
||||
use App\Entity\FoodOrder;
|
||||
use App\Entity\OrderItem;
|
||||
use PHPUnit\Framework\Attributes\CoversClass;
|
||||
use PHPUnit\Framework\TestCase;
|
||||
|
||||
#[CoversClass(FoodOrder::class)]
|
||||
#[CoversClass(OrderItem::class)]
|
||||
final class FoodOrderTest extends TestCase
|
||||
{
|
||||
public function testFoodOrder(): void
|
||||
|
|
|
@ -5,9 +5,13 @@ namespace App\Tests\Entity;
|
|||
use App\Entity\FoodOrder;
|
||||
use App\Entity\FoodVendor;
|
||||
use App\Entity\MenuItem;
|
||||
use PHPUnit\Framework\Attributes\CoversClass;
|
||||
use PHPUnit\Framework\TestCase;
|
||||
use Symfony\Component\Uid\Ulid;
|
||||
|
||||
#[CoversClass(FoodVendor::class)]
|
||||
#[CoversClass(FoodOrder::class)]
|
||||
#[CoversClass(MenuItem::class)]
|
||||
final class FoodVendorTest extends TestCase
|
||||
{
|
||||
public function testFoodVendor(): void
|
||||
|
|
|
@ -5,8 +5,11 @@ namespace App\Tests\Entity;
|
|||
use App\Entity\FoodVendor;
|
||||
use App\Entity\MenuItem;
|
||||
use DateTimeImmutable;
|
||||
use PHPUnit\Framework\Attributes\CoversClass;
|
||||
use PHPUnit\Framework\TestCase;
|
||||
|
||||
#[CoversClass(MenuItem::class)]
|
||||
#[CoversClass(FoodVendor::class)]
|
||||
final class MenuItemTest extends TestCase
|
||||
{
|
||||
public function testMenuItem(): void
|
||||
|
|
28
tests/Pest.php
Normal file
28
tests/Pest.php
Normal file
|
@ -0,0 +1,28 @@
|
|||
<?php declare(strict_types=1);
|
||||
|
||||
/*
|
||||
|--------------------------------------------------------------------------
|
||||
| Test Case
|
||||
|--------------------------------------------------------------------------
|
||||
|
|
||||
| The closure you provide to your test functions is always bound to a specific PHPUnit test
|
||||
| case class. By default, that class is "PHPUnit\Framework\TestCase". Of course, you may
|
||||
| need to change it using the "pest()" function to bind a different classes or traits.
|
||||
|
|
||||
*/
|
||||
|
||||
/*
|
||||
|--------------------------------------------------------------------------
|
||||
| Functions
|
||||
|--------------------------------------------------------------------------
|
||||
|
|
||||
| While Pest is very powerful out-of-the-box, you may have some testing code specific to your
|
||||
| project that you don't want to repeat in every file. Here you can also expose helpers as
|
||||
| global functions to help you to reduce the number of lines of code in your test files.
|
||||
|
|
||||
*/
|
||||
|
||||
function something(): void
|
||||
{
|
||||
// ..
|
||||
}
|
10
tests/TestCase.php
Normal file
10
tests/TestCase.php
Normal file
|
@ -0,0 +1,10 @@
|
|||
<?php declare(strict_types=1);
|
||||
|
||||
namespace Tests;
|
||||
|
||||
use PHPUnit\Framework\TestCase as BaseTestCase;
|
||||
|
||||
abstract class TestCase extends BaseTestCase
|
||||
{
|
||||
//
|
||||
}
|
Loading…
Add table
Reference in a new issue