From 3d311825d1bfa16d5bc4feb9639df30a7e0e8109 Mon Sep 17 00:00:00 2001 From: Manuel Raynaud Date: Fri, 20 Jun 2014 09:09:06 +0200 Subject: [PATCH] integrate web test case --- composer.json | 3 +- composer.lock | 114 +++++++++++++++++++++++++- core/lib/Thelia/Tests/WebTestCase.php | 59 +++++++++++++ core/lib/Thelia/Tests/bootstrap.php | 1 + 4 files changed, 175 insertions(+), 2 deletions(-) create mode 100644 core/lib/Thelia/Tests/WebTestCase.php diff --git a/composer.json b/composer.json index c4a2b665f..28c6bd0e2 100644 --- a/composer.json +++ b/composer.json @@ -36,7 +36,8 @@ "swiftmailer/swiftmailer": "5.0.*", "symfony/serializer": "2.3.*", "ensepar/html2pdf": "1.0.1", - "symfony/finder": "~2.2" + "symfony/finder": "~2.2", + "symfony/browser-kit": "2.3.*" }, "require-dev": { "phpunit/phpunit": "4.1.*", diff --git a/composer.lock b/composer.lock index 30991c403..55fdf2088 100644 --- a/composer.lock +++ b/composer.lock @@ -4,7 +4,7 @@ "Read more about it at http://getcomposer.org/doc/01-basic-usage.md#composer-lock-the-lock-file", "This file is @generated automatically" ], - "hash": "73a6895063dd76bcb25eb14ef329e745", + "hash": "e6d2af4c5536d0187aa2515baa3c62ab", "packages": [ { "name": "doctrine/cache", @@ -704,6 +704,63 @@ ], "time": "2013-03-25 15:02:40" }, + { + "name": "symfony/browser-kit", + "version": "v2.3.13", + "target-dir": "Symfony/Component/BrowserKit", + "source": { + "type": "git", + "url": "https://github.com/symfony/BrowserKit.git", + "reference": "97563874c24b65ea8d31b82fe051a161caf83e10" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/symfony/BrowserKit/zipball/97563874c24b65ea8d31b82fe051a161caf83e10", + "reference": "97563874c24b65ea8d31b82fe051a161caf83e10", + "shasum": "" + }, + "require": { + "php": ">=5.3.3", + "symfony/dom-crawler": "~2.0" + }, + "require-dev": { + "symfony/css-selector": "~2.0", + "symfony/process": "~2.0" + }, + "suggest": { + "symfony/process": "" + }, + "type": "library", + "extra": { + "branch-alias": { + "dev-master": "2.3-dev" + } + }, + "autoload": { + "psr-0": { + "Symfony\\Component\\BrowserKit\\": "" + } + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "authors": [ + { + "name": "Fabien Potencier", + "email": "fabien@symfony.com", + "homepage": "http://fabien.potencier.org", + "role": "Lead Developer" + }, + { + "name": "Symfony Community", + "homepage": "http://symfony.com/contributors" + } + ], + "description": "Symfony BrowserKit Component", + "homepage": "http://symfony.com", + "time": "2014-04-18 20:35:25" + }, { "name": "symfony/class-loader", "version": "v2.2.6", @@ -903,6 +960,61 @@ "homepage": "http://symfony.com", "time": "2013-07-21 09:38:59" }, + { + "name": "symfony/dom-crawler", + "version": "v2.4.4", + "target-dir": "Symfony/Component/DomCrawler", + "source": { + "type": "git", + "url": "https://github.com/symfony/DomCrawler.git", + "reference": "e94b29c7cac964e58c406408d238ceeaa3604e78" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/symfony/DomCrawler/zipball/e94b29c7cac964e58c406408d238ceeaa3604e78", + "reference": "e94b29c7cac964e58c406408d238ceeaa3604e78", + "shasum": "" + }, + "require": { + "php": ">=5.3.3" + }, + "require-dev": { + "symfony/css-selector": "~2.0" + }, + "suggest": { + "symfony/css-selector": "" + }, + "type": "library", + "extra": { + "branch-alias": { + "dev-master": "2.4-dev" + } + }, + "autoload": { + "psr-0": { + "Symfony\\Component\\DomCrawler\\": "" + } + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "authors": [ + { + "name": "Fabien Potencier", + "email": "fabien@symfony.com", + "homepage": "http://fabien.potencier.org", + "role": "Lead Developer" + }, + { + "name": "Symfony Community", + "homepage": "http://symfony.com/contributors" + } + ], + "description": "Symfony DomCrawler Component", + "homepage": "http://symfony.com", + "time": "2014-04-18 20:37:09" + }, { "name": "symfony/event-dispatcher", "version": "v2.2.6", diff --git a/core/lib/Thelia/Tests/WebTestCase.php b/core/lib/Thelia/Tests/WebTestCase.php new file mode 100644 index 000000000..2976b6dfa --- /dev/null +++ b/core/lib/Thelia/Tests/WebTestCase.php @@ -0,0 +1,59 @@ + + */ +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(); + } + } +} \ No newline at end of file diff --git a/core/lib/Thelia/Tests/bootstrap.php b/core/lib/Thelia/Tests/bootstrap.php index 86f6d8355..c4733ca1d 100755 --- a/core/lib/Thelia/Tests/bootstrap.php +++ b/core/lib/Thelia/Tests/bootstrap.php @@ -5,6 +5,7 @@ * @file * Functions needed for Thelia bootstrap */ +ini_set('session.use_cookies', 0); $env = "test"; require_once __DIR__ . '/../../../bootstrap.php';