2011-12-15 09:58:06 +00:00
|
|
|
<?php
|
|
|
|
|
|
|
|
/*
|
2012-03-31 22:00:32 +01:00
|
|
|
* This file is part of the Symfony package.
|
2011-12-15 09:58:06 +00:00
|
|
|
*
|
|
|
|
* (c) Fabien Potencier <fabien@symfony.com>
|
|
|
|
*
|
2012-03-31 22:00:32 +01:00
|
|
|
* For the full copyright and license information, please view the LICENSE
|
|
|
|
* file that was distributed with this source code.
|
2011-12-15 09:58:06 +00:00
|
|
|
*/
|
|
|
|
|
|
|
|
namespace Symfony\Bundle\FrameworkBundle\Tests\Functional;
|
|
|
|
|
|
|
|
use Symfony\Bundle\FrameworkBundle\Test\WebTestCase as BaseWebTestCase;
|
2011-12-22 18:36:46 +00:00
|
|
|
use Symfony\Component\Filesystem\Filesystem;
|
2011-12-17 10:02:17 +00:00
|
|
|
use Symfony\Component\HttpKernel\Kernel;
|
2011-12-15 09:58:06 +00:00
|
|
|
|
|
|
|
class WebTestCase extends BaseWebTestCase
|
|
|
|
{
|
2012-07-09 13:50:58 +01:00
|
|
|
public static function assertRedirect($response, $location)
|
2011-12-15 09:58:06 +00:00
|
|
|
{
|
2011-12-16 15:00:29 +00:00
|
|
|
self::assertTrue($response->isRedirect(), 'Response is not a redirect, got status code: '.$response->getStatusCode());
|
2011-12-15 09:58:06 +00:00
|
|
|
self::assertEquals('http://localhost'.$location, $response->headers->get('Location'));
|
|
|
|
}
|
|
|
|
|
|
|
|
protected function deleteTmpDir($testCase)
|
|
|
|
{
|
2011-12-17 10:02:17 +00:00
|
|
|
if (!file_exists($dir = sys_get_temp_dir().'/'.Kernel::VERSION.'/'.$testCase)) {
|
2011-12-15 09:58:06 +00:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
$fs = new Filesystem();
|
|
|
|
$fs->remove($dir);
|
|
|
|
}
|
|
|
|
|
2012-07-09 13:50:58 +01:00
|
|
|
protected static function getKernelClass()
|
2011-12-15 09:58:06 +00:00
|
|
|
{
|
|
|
|
require_once __DIR__.'/app/AppKernel.php';
|
|
|
|
|
2014-02-11 07:51:18 +00:00
|
|
|
return 'Symfony\Bundle\FrameworkBundle\Tests\Functional\app\AppKernel';
|
2011-12-15 09:58:06 +00:00
|
|
|
}
|
|
|
|
|
2012-07-09 13:50:58 +01:00
|
|
|
protected static function createKernel(array $options = array())
|
2011-12-15 09:58:06 +00:00
|
|
|
{
|
|
|
|
$class = self::getKernelClass();
|
|
|
|
|
|
|
|
if (!isset($options['test_case'])) {
|
|
|
|
throw new \InvalidArgumentException('The option "test_case" must be set.');
|
|
|
|
}
|
|
|
|
|
|
|
|
return new $class(
|
|
|
|
$options['test_case'],
|
|
|
|
isset($options['root_config']) ? $options['root_config'] : 'config.yml',
|
2012-09-19 05:19:30 +01:00
|
|
|
isset($options['environment']) ? $options['environment'] : 'frameworkbundletest'.strtolower($options['test_case']),
|
2011-12-15 09:58:06 +00:00
|
|
|
isset($options['debug']) ? $options['debug'] : true
|
|
|
|
);
|
|
|
|
}
|
|
|
|
}
|