Skip to content
This repository has been archived by the owner on Aug 23, 2020. It is now read-only.

Commit

Permalink
prepared tests
Browse files Browse the repository at this point in the history
  • Loading branch information
neustadt committed Jan 21, 2019
1 parent fbf3b3e commit f8983d1
Show file tree
Hide file tree
Showing 6 changed files with 125 additions and 3 deletions.
6 changes: 3 additions & 3 deletions .travis.yml
Expand Up @@ -37,14 +37,14 @@ before_script:
- php ${HOME}/shopware/bin/console sw:plugin:activate ${PLUGIN_NAME}
- cd ${PLUGIN_DIRECTORY}/${PLUGIN_NAME}

#script:
# - composer test
script:
- composer test

after_success:
- ./build.sh

stages:
# - test
- test
- Store-Check
- name: Store-Sync
if: branch = master
Expand Down
3 changes: 3 additions & 0 deletions composer.json
Expand Up @@ -9,5 +9,8 @@
},
"require": {
"composer/installers": "~1.0"
},
"scripts": {
"test": "phpunit -c tests"
}
}
Empty file added tests/Functional/.gitkeep
Empty file.
55 changes: 55 additions & 0 deletions tests/Unit/bootstrap.php
@@ -0,0 +1,55 @@
<?php
/**
* Shopware 5
* Copyright (c) shopware AG.
*
* According to our dual licensing model, this program can be used either
* under the terms of the GNU Affero General Public License, version 3,
* or under a proprietary license.
*
* The texts of the GNU Affero General Public License with an additional
* permission and of our proprietary license can be found at and
* in the LICENSE file you have received along with this program.
*
* This program 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 Affero General Public License for more details.
*
* "Shopware" is a registered trademark of shopware AG.
* The licensing of the program under the AGPLv3 does not imply a
* trademark license. Therefore any rights, title and interest in
* our trademarks remain entirely with us.
*/
use Shopware\Models\Shop\Shop;

require __DIR__ . '/../../../../../autoload.php';

class TestKernel extends \Shopware\Kernel
{
/**
* Static method to start boot kernel without leaving local scope in test helper.
*
* @throws Exception
*/
public static function start()
{
$_SERVER['REMOTE_ADDR'] = '127.0.0.1';
$kernel = new self('testing', true);
$kernel->boot();
$container = $kernel->getContainer();
$container->get('plugins')->Core()->ErrorHandler()->registerErrorHandler(E_ALL | E_STRICT);
/** @var $repository \Shopware\Models\Shop\Repository */
$repository = $container->get('models')->getRepository(Shop::class);
$shop = $repository->getActiveDefault();
$shop->registerResources();
$_SERVER['HTTP_HOST'] = $shop->getHost();
}

protected function getConfigPath()
{
return __DIR__ . '/config.php';
}
}

TestKernel::start();
34 changes: 34 additions & 0 deletions tests/Unit/config.php
@@ -0,0 +1,34 @@
<?php
return array_merge($this->loadConfig($this->AppPath() . 'Configs/Default.php'), [
'front' => [
'throwExceptions' => true,
'disableOutputBuffering' => false,
'showException' => true,
],
'errorHandler' => [
'throwOnRecoverableError' => true,
],
'session' => [
'unitTestEnabled' => true,
'name' => 'SHOPWARESID',
'cookie_lifetime' => 0,
'use_trans_sid' => false,
'gc_probability' => 1,
'gc_divisor' => 100,
'save_handler' => 'db',
],
'mail' => [
'type' => 'file',
'path' => $this->getCacheDir(),
],
'phpSettings' => [
'error_reporting' => E_ALL,
'display_errors' => 1,
'date.timezone' => 'Europe/Berlin',
'max_execution_time' => 0,
],
'csrfProtection' => [
'frontend' => false,
'backend' => false,
],
]);
30 changes: 30 additions & 0 deletions tests/phpunit.xml
@@ -0,0 +1,30 @@
<?xml version="1.0" encoding="UTF-8"?>

<phpunit xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:noNamespaceSchemaLocation="https://schema.phpunit.de/5.5/phpunit.xsd"
bootstrap="./Unit/bootstrap.php"
colors="true"
beStrictAboutOutputDuringTests="true"
beStrictAboutResourceUsageDuringSmallTests="true"
beStrictAboutTestsThatDoNotTestAnything="true"
beStrictAboutTodoAnnotatedTests="true"
verbose="true">

<testsuites>
<testsuite name="DataTableLayout">
<directory>./Functional</directory>
</testsuite>
</testsuites>

<groups>
<exclude>
<group>disable</group>
</exclude>
</groups>

<filter>
<whitelist>
<directory suffix=".php">../engine/Shopware/</directory>
</whitelist>
</filter>
</phpunit>

0 comments on commit f8983d1

Please sign in to comment.