integrate web test case
This commit is contained in:
59
core/lib/Thelia/Tests/WebTestCase.php
Normal file
59
core/lib/Thelia/Tests/WebTestCase.php
Normal file
@@ -0,0 +1,59 @@
|
||||
<?php
|
||||
/*************************************************************************************/
|
||||
/* This file is part of the Thelia package. */
|
||||
/* */
|
||||
/* Copyright (c) OpenStudio */
|
||||
/* email : dev@thelia.net */
|
||||
/* web : http://www.thelia.net */
|
||||
/* */
|
||||
/* For the full copyright and license information, please view the LICENSE.txt */
|
||||
/* file that was distributed with this source code. */
|
||||
/*************************************************************************************/
|
||||
|
||||
namespace Thelia\Tests;
|
||||
|
||||
use Thelia\Core\Thelia;
|
||||
|
||||
|
||||
/**
|
||||
* Class WebTestCase
|
||||
* @package Thelia\Tests
|
||||
* @author Manuel Raynaud <mraynaud@openstudio.fr>
|
||||
*/
|
||||
class WebTestCase extends \PHPUnit_Framework_TestCase
|
||||
{
|
||||
/**
|
||||
* @var \Thelia\Core\Thelia
|
||||
*/
|
||||
protected static $kernel;
|
||||
|
||||
/**
|
||||
* @param array $options
|
||||
* @param array $server
|
||||
* @return \Symfony\Component\HttpKernel\Client
|
||||
*/
|
||||
protected static function createClient(array $options = [], array $server = [])
|
||||
{
|
||||
if (null !== static::$kernel) {
|
||||
static::$kernel->shutdown();
|
||||
}
|
||||
|
||||
static::$kernel = new Thelia('test', true);
|
||||
static::$kernel->boot();
|
||||
|
||||
$client = static::$kernel->getContainer()->get('test.client');
|
||||
$client->setServerParameters($server);
|
||||
|
||||
return $client;
|
||||
}
|
||||
|
||||
/**
|
||||
* Shuts the kernel down if it was used in the test.
|
||||
*/
|
||||
protected function tearDown()
|
||||
{
|
||||
if (null !== static::$kernel) {
|
||||
static::$kernel->shutdown();
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -5,6 +5,7 @@
|
||||
* @file
|
||||
* Functions needed for Thelia bootstrap
|
||||
*/
|
||||
ini_set('session.use_cookies', 0);
|
||||
$env = "test";
|
||||
require_once __DIR__ . '/../../../bootstrap.php';
|
||||
|
||||
|
||||
Reference in New Issue
Block a user