Files
iTop/lib/symfony/framework-bundle/Tests/Functional/AbstractWebTestCase.php
Molkobain 5960dc6245 N°2435.1 Portal: Split portal composer.json in 2
- Autoloader for portal files in the itop-portal-base module
- Dependencies moved to root composer.json
- Add autoloader for /core and /application content
2019-08-13 10:34:22 +02:00

74 lines
2.1 KiB
PHP

<?php
/*
* This file is part of the Symfony package.
*
* (c) Fabien Potencier <fabien@symfony.com>
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/
namespace Symfony\Bundle\FrameworkBundle\Tests\Functional;
use Symfony\Bundle\FrameworkBundle\Test\WebTestCase as BaseWebTestCase;
use Symfony\Component\Filesystem\Filesystem;
abstract class AbstractWebTestCase extends BaseWebTestCase
{
public static function assertRedirect($response, $location)
{
self::assertTrue($response->isRedirect(), 'Response is not a redirect, got status code: '.$response->getStatusCode());
self::assertEquals('http://localhost'.$location, $response->headers->get('Location'));
}
public static function setUpBeforeClass()
{
static::deleteTmpDir();
}
public static function tearDownAfterClass()
{
static::deleteTmpDir();
}
protected static function deleteTmpDir()
{
if (!file_exists($dir = sys_get_temp_dir().'/'.static::getVarDir())) {
return;
}
$fs = new Filesystem();
$fs->remove($dir);
}
protected static function getKernelClass()
{
require_once __DIR__.'/app/AppKernel.php';
return 'Symfony\Bundle\FrameworkBundle\Tests\Functional\app\AppKernel';
}
protected static function createKernel(array $options = [])
{
$class = self::getKernelClass();
if (!isset($options['test_case'])) {
throw new \InvalidArgumentException('The option "test_case" must be set.');
}
return new $class(
static::getVarDir(),
$options['test_case'],
isset($options['root_config']) ? $options['root_config'] : 'config.yml',
isset($options['environment']) ? $options['environment'] : strtolower(static::getVarDir().$options['test_case']),
isset($options['debug']) ? $options['debug'] : false
);
}
protected static function getVarDir()
{
return 'FB'.substr(strrchr(\get_called_class(), '\\'), 1);
}
}