29 - Add PHPUnit
This commit is contained in:
parent
4e9f4ad449
commit
b230aa3fd2
11 changed files with 2264 additions and 3 deletions
7
.env.test
Normal file
7
.env.test
Normal file
|
|
@ -0,0 +1,7 @@
|
|||
# define your env variables for the test env here
|
||||
KERNEL_CLASS='App\Kernel'
|
||||
APP_SECRET='$ecretf0rt3st'
|
||||
|
||||
# Test database: real Postgres (same engine as prod). Doctrine's when@test config
|
||||
# appends "_test" to the dbname, so this resolves to "buckets_test".
|
||||
DATABASE_URL="postgresql://buckets:buckets@database:5432/buckets?serverVersion=16&charset=utf8"
|
||||
5
.gitignore
vendored
5
.gitignore
vendored
|
|
@ -8,3 +8,8 @@
|
|||
/var/
|
||||
/vendor/
|
||||
###< symfony/framework-bundle ###
|
||||
|
||||
###> phpunit/phpunit ###
|
||||
/phpunit.xml
|
||||
/.phpunit.cache/
|
||||
###< phpunit/phpunit ###
|
||||
|
|
|
|||
4
bin/phpunit
Executable file
4
bin/phpunit
Executable file
|
|
@ -0,0 +1,4 @@
|
|||
#!/usr/bin/env php
|
||||
<?php
|
||||
|
||||
require dirname(__DIR__).'/vendor/phpunit/phpunit/phpunit';
|
||||
|
|
@ -82,5 +82,10 @@
|
|||
"require": "8.1.*",
|
||||
"docker": true
|
||||
}
|
||||
},
|
||||
"require-dev": {
|
||||
"phpunit/phpunit": "^13.2",
|
||||
"symfony/browser-kit": "8.1.*",
|
||||
"symfony/css-selector": "8.1.*"
|
||||
}
|
||||
}
|
||||
|
|
|
|||
2138
composer.lock
generated
2138
composer.lock
generated
File diff suppressed because it is too large
Load diff
44
phpunit.dist.xml
Normal file
44
phpunit.dist.xml
Normal file
|
|
@ -0,0 +1,44 @@
|
|||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
|
||||
<!-- https://phpunit.readthedocs.io/en/latest/configuration.html -->
|
||||
<phpunit xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
||||
xsi:noNamespaceSchemaLocation="vendor/phpunit/phpunit/phpunit.xsd"
|
||||
colors="true"
|
||||
failOnDeprecation="true"
|
||||
failOnNotice="true"
|
||||
failOnWarning="true"
|
||||
bootstrap="tests/bootstrap.php"
|
||||
cacheDirectory=".phpunit.cache"
|
||||
>
|
||||
<php>
|
||||
<ini name="display_errors" value="1" />
|
||||
<ini name="error_reporting" value="-1" />
|
||||
<server name="APP_ENV" value="test" force="true" />
|
||||
<server name="SHELL_VERBOSITY" value="-1" />
|
||||
</php>
|
||||
|
||||
<testsuites>
|
||||
<testsuite name="Project Test Suite">
|
||||
<directory>tests</directory>
|
||||
</testsuite>
|
||||
</testsuites>
|
||||
|
||||
<source ignoreSuppressionOfDeprecations="true"
|
||||
ignoreIndirectDeprecations="true"
|
||||
restrictNotices="true"
|
||||
restrictWarnings="true"
|
||||
>
|
||||
<include>
|
||||
<directory>src</directory>
|
||||
</include>
|
||||
|
||||
<deprecationTrigger>
|
||||
<method>Doctrine\Deprecations\Deprecation::trigger</method>
|
||||
<method>Doctrine\Deprecations\Deprecation::delegateTriggerToBackend</method>
|
||||
<function>trigger_deprecation</function>
|
||||
</deprecationTrigger>
|
||||
</source>
|
||||
|
||||
<extensions>
|
||||
</extensions>
|
||||
</phpunit>
|
||||
|
|
@ -96,6 +96,13 @@ pkgs.mkShell {
|
|||
$COMPOSE exec php composer "$@"
|
||||
}
|
||||
|
||||
# ===================
|
||||
# QA COMMANDS (run in the php container)
|
||||
# ===================
|
||||
dev-test() {
|
||||
$COMPOSE exec php php bin/phpunit "$@"
|
||||
}
|
||||
|
||||
# ===================
|
||||
# BUILD COMMANDS
|
||||
# ===================
|
||||
|
|
@ -147,6 +154,7 @@ pkgs.mkShell {
|
|||
echo " dev-shell Shell into app container"
|
||||
echo " dev-console <cmd> Run Symfony console command"
|
||||
echo " dev-composer <cmd> Run composer in the container"
|
||||
echo " dev-test [args] Run PHPUnit (bin/phpunit)"
|
||||
echo " base-build Build and push image"
|
||||
echo ""
|
||||
echo "Services:"
|
||||
|
|
|
|||
15
symfony.lock
15
symfony.lock
|
|
@ -61,6 +61,21 @@
|
|||
"config/packages/nelmio_cors.yaml"
|
||||
]
|
||||
},
|
||||
"phpunit/phpunit": {
|
||||
"version": "13.2",
|
||||
"recipe": {
|
||||
"repo": "github.com/symfony/recipes",
|
||||
"branch": "main",
|
||||
"version": "11.1",
|
||||
"ref": "ca0bc067abfb40a8de1b2561b96cbfc2b833c314"
|
||||
},
|
||||
"files": [
|
||||
".env.test",
|
||||
"phpunit.dist.xml",
|
||||
"tests/bootstrap.php",
|
||||
"bin/phpunit"
|
||||
]
|
||||
},
|
||||
"symfony/console": {
|
||||
"version": "8.1",
|
||||
"recipe": {
|
||||
|
|
|
|||
15
tests/KernelBootTest.php
Normal file
15
tests/KernelBootTest.php
Normal file
|
|
@ -0,0 +1,15 @@
|
|||
<?php
|
||||
|
||||
namespace App\Tests;
|
||||
|
||||
use Symfony\Bundle\FrameworkBundle\Test\KernelTestCase;
|
||||
|
||||
final class KernelBootTest extends KernelTestCase
|
||||
{
|
||||
public function testKernelBootsInTestEnv(): void
|
||||
{
|
||||
self::bootKernel();
|
||||
|
||||
self::assertSame('test', self::$kernel->getEnvironment());
|
||||
}
|
||||
}
|
||||
13
tests/SmokeTest.php
Normal file
13
tests/SmokeTest.php
Normal file
|
|
@ -0,0 +1,13 @@
|
|||
<?php
|
||||
|
||||
namespace App\Tests;
|
||||
|
||||
use PHPUnit\Framework\TestCase;
|
||||
|
||||
final class SmokeTest extends TestCase
|
||||
{
|
||||
public function testPhpunitRuns(): void
|
||||
{
|
||||
self::assertTrue(true);
|
||||
}
|
||||
}
|
||||
13
tests/bootstrap.php
Normal file
13
tests/bootstrap.php
Normal file
|
|
@ -0,0 +1,13 @@
|
|||
<?php
|
||||
|
||||
use Symfony\Component\Dotenv\Dotenv;
|
||||
|
||||
require dirname(__DIR__).'/vendor/autoload.php';
|
||||
|
||||
if (method_exists(Dotenv::class, 'bootEnv')) {
|
||||
(new Dotenv())->bootEnv(dirname(__DIR__).'/.env');
|
||||
}
|
||||
|
||||
if ($_SERVER['APP_DEBUG']) {
|
||||
umask(0000);
|
||||
}
|
||||
Loading…
Reference in a new issue