mirror of
https://github.com/jbcr/Sylius.git
synced 2026-03-24 08:52:11 +01:00
58 lines
1.4 KiB
PHP
58 lines
1.4 KiB
PHP
<?php
|
|
|
|
/*
|
|
* This file is part of the Sylius package.
|
|
*
|
|
* (c) Sylius Sp. z o.o.
|
|
*
|
|
* For the full copyright and license information, please view the LICENSE
|
|
* file that was distributed with this source code.
|
|
*/
|
|
|
|
declare(strict_types=1);
|
|
|
|
namespace Sylius\Tests\Functional;
|
|
|
|
use Symfony\Bundle\FrameworkBundle\Test\WebTestCase as BaseWebTestCase;
|
|
use Symfony\Component\Filesystem\Filesystem;
|
|
use Symfony\Component\HttpKernel\KernelInterface;
|
|
|
|
abstract class AbstractWebTestCase extends BaseWebTestCase
|
|
{
|
|
public static function setUpBeforeClass(): void
|
|
{
|
|
static::deleteTmpDir();
|
|
}
|
|
|
|
public static function tearDownAfterClass(): void
|
|
{
|
|
static::deleteTmpDir();
|
|
}
|
|
|
|
protected static function deleteTmpDir()
|
|
{
|
|
if (!file_exists($dir = sys_get_temp_dir() . '/sylius_functional_tests')) {
|
|
return;
|
|
}
|
|
|
|
$fs = new Filesystem();
|
|
$fs->remove($dir);
|
|
}
|
|
|
|
protected static function createKernel(array $options = []): KernelInterface
|
|
{
|
|
$class = self::getKernelClass();
|
|
|
|
return new $class(
|
|
$options['environment'] ?? $_ENV['APP_ENV'] ?? $_SERVER['APP_ENV'] ?? 'test',
|
|
(bool) ($options['debug'] ?? $_ENV['APP_DEBUG'] ?? $_SERVER['APP_DEBUG'] ?? false),
|
|
$options['test_case'] ?? null,
|
|
);
|
|
}
|
|
|
|
protected static function getKernelClass(): string
|
|
{
|
|
return 'Sylius\Tests\Functional\app\AppKernel';
|
|
}
|
|
}
|