forked from noiselabs/SmartyBundle
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
noiselabsGH-95 Rework the SmartyEngine::renderTemplateFunction when c…
…aching is disabled * Rename the Functional test suite to Integration
- Loading branch information
1 parent
dbb1b96
commit 1dfb8ac
Showing
56 changed files
with
793 additions
and
84 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,86 @@ | ||
<?php | ||
/* | ||
* This file is part of the NoiseLabs-SmartyBundle package. | ||
* | ||
* Copyright (c) 2011-2021 Vítor Brandão <[email protected]> | ||
* | ||
* NoiseLabs-SmartyBundle is free software; you can redistribute it | ||
* and/or modify it under the terms of the GNU Lesser General Public | ||
* License as published by the Free Software Foundation; either | ||
* version 3 of the License, or (at your option) any later version. | ||
* | ||
* NoiseLabs-SmartyBundle is distributed in the hope that it will be | ||
* useful, but WITHOUT ANY WARRANTY; without even the implied warranty | ||
* of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU | ||
* Lesser General Public License for more details. | ||
* | ||
* You should have received a copy of the GNU Lesser General Public | ||
* License along with NoiseLabs-SmartyBundle; if not, see | ||
* <http://www.gnu.org/licenses/>. | ||
*/ | ||
declare(strict_types=1); | ||
|
||
namespace NoiseLabs\Bundle\SmartyBundle\Tests\Application; | ||
|
||
use Symfony\Bundle\FrameworkBundle\Test\WebTestCase as SymfonyWebTestCase; | ||
use Symfony\Component\Filesystem\Filesystem; | ||
use Symfony\Component\HttpKernel\KernelInterface; | ||
|
||
abstract class AbstractWebTestCase extends SymfonyWebTestCase | ||
{ | ||
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(): void | ||
{ | ||
static::deleteTmpDir(); | ||
} | ||
|
||
public static function tearDownAfterClass(): void | ||
{ | ||
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(): string | ||
{ | ||
require_once __DIR__.'/AppKernel.php'; | ||
|
||
return AppKernel::class; | ||
} | ||
|
||
protected static function createKernel(array $options = []): KernelInterface | ||
{ | ||
$class = self::getKernelClass(); | ||
|
||
if (!isset($options['test_case'])) { | ||
throw new \InvalidArgumentException('The option "test_case" must be set.'); | ||
} | ||
|
||
return new $class( | ||
__DIR__, | ||
static::getVarDir(), | ||
$options['test_case'], | ||
$options['root_config'] ?? 'config.yml', | ||
$options['environment'] ?? strtolower(static::getVarDir().$options['test_case']), | ||
$options['debug'] ?? false | ||
); | ||
} | ||
|
||
protected static function getVarDir(): string | ||
{ | ||
return 'SB'.substr(strrchr(static::class, '\\'), 1); | ||
} | ||
} |
Oops, something went wrong.