vendor/symfony/src/Symfony/Bundle/SecurityBundle/Tests/Functional/WebTestCase.php
changeset 0 7f95f8617b0b
equal deleted inserted replaced
-1:000000000000 0:7f95f8617b0b
       
     1 <?php
       
     2 
       
     3 /*
       
     4  * This file is part of the Symfony framework.
       
     5  *
       
     6  * (c) Fabien Potencier <fabien@symfony.com>
       
     7  *
       
     8  * This source file is subject to the MIT license that is bundled
       
     9  * with this source code in the file LICENSE.
       
    10  */
       
    11 
       
    12 namespace Symfony\Bundle\SecurityBundle\Tests\Functional;
       
    13 
       
    14 use Symfony\Component\HttpKernel\Util\Filesystem;
       
    15 use Symfony\Bundle\FrameworkBundle\Test\WebTestCase as BaseWebTestCase;
       
    16 
       
    17 class WebTestCase extends BaseWebTestCase
       
    18 {
       
    19     static public function assertRedirect($response, $location)
       
    20     {
       
    21         self::assertTrue($response->isRedirect(), 'Response is not a redirect, got status code: '.$response->getStatusCode());
       
    22         self::assertEquals('http://localhost'.$location, $response->headers->get('Location'));
       
    23     }
       
    24 
       
    25     protected function setUp()
       
    26     {
       
    27         if (!class_exists('Twig_Environment')) {
       
    28             $this->markTestSkipped('Twig is not available.');
       
    29         }
       
    30 
       
    31         parent::setUp();
       
    32     }
       
    33 
       
    34     protected function deleteTmpDir($testCase)
       
    35     {
       
    36         if (!file_exists($dir = sys_get_temp_dir().'/'.$testCase)) {
       
    37             return;
       
    38         }
       
    39 
       
    40         $fs = new Filesystem();
       
    41         $fs->remove($dir);
       
    42     }
       
    43 
       
    44     static protected function getKernelClass()
       
    45     {
       
    46         require_once __DIR__.'/app/AppKernel.php';
       
    47 
       
    48         return 'Symfony\Bundle\SecurityBundle\Tests\Functional\AppKernel';
       
    49     }
       
    50 
       
    51     static protected function createKernel(array $options = array())
       
    52     {
       
    53         $class = self::getKernelClass();
       
    54 
       
    55         if (!isset($options['test_case'])) {
       
    56             throw new \InvalidArgumentException('The option "test_case" must be set.');
       
    57         }
       
    58 
       
    59         return new $class(
       
    60             $options['test_case'],
       
    61             isset($options['root_config']) ? $options['root_config'] : 'config.yml',
       
    62             isset($options['environment']) ? $options['environment'] : 'test',
       
    63             isset($options['debug']) ? $options['debug'] : true
       
    64         );
       
    65     }
       
    66 }