Commit 5e8b3aa8 authored by Tobias Munk's avatar Tobias Munk

Merge branch 'master' into feature/issue-138

parents fa8ed24a 21973929
Pipeline #8939 failed with stages
......@@ -2,7 +2,6 @@ before_script:
- export BUILD_PREFIX=buildref${CI_BUILD_REF}$(echo ${CI_BUILD_REF_NAME} | tr -dc '[:alnum:]\n\r' | tr '[:upper:]' '[:lower:]')giiant
- export COMPOSE_PROJECT_NAME=${BUILD_PREFIX}
- cd tests
- cp docker-compose.override-dist.yml docker-compose.override.yml
stages:
- test
......@@ -18,7 +17,8 @@ test:
- sleep 10
- docker-compose run --rm phpfpm setup.sh
- set +e
- docker-compose run --rm -e YII_ENV=test phpfpm codecept run --steps --html=_report.html -g mandatory -g ${GIIANT_TEST_DB} cli,unit,functional,acceptance; TESTS_EXIT_CODE=$?
- docker-compose run --rm -e YII_ENV=dev phpfpm bash -c 'codecept run --steps --html=_report.html -g mandatory -g ${GIIANT_TEST_DB} cli' || TESTS_EXIT_CODE=1
- docker-compose run --rm -e YII_ENV=dev phpfpm bash -c 'codecept run --steps --html=_report.html -g mandatory -g ${GIIANT_TEST_DB} unit,acceptance' || TESTS_EXIT_CODE=1
- cp -r _output /tmp/${BUILD_PREFIX}
- set -e
- exit $TESTS_EXIT_CODE
......
......@@ -11,5 +11,11 @@ return yii\helpers\ArrayHelper::merge(
[
'controllerNamespace' => 'app\controllers',
'language' => 'en',
'modules' => [
'sakila' => [
'class' => 'yii\sakila\Module',
'allowedIPs' => '*'
]
]
]
);
......@@ -10,6 +10,9 @@ return [
'gii' => [
'class' => 'yii\gii\Module',
'allowedIPs' => '*'
],
'sakila' => [
'class' => 'app\modules\sakila\Module',
]
],
];
<?php
/**
* Application configuration for unit tests
*/
$_SERVER['SCRIPT_FILENAME'] = YII_TEST_ENTRY_FILE;
$_SERVER['SCRIPT_NAME'] = YII_TEST_ENTRY_URL;
$basePath = '/app';
return yii\helpers\ArrayHelper::merge(
require($basePath . '/src/config/main.php'),
require(__DIR__ . '/config.php'),
[
'controllerNamespace' => 'app\controllers',
'components' => [
'request' => [
// it's not recommended to run functional tests with CSRF validation enabled
'enableCsrfValidation' => false,
'cookieValidationKey' => uniqid('TESTING-'),
// but if you absolutely need it set cookie domain to localhost
/*
'csrfCookie' => [
'domain' => 'localhost',
],
*/
],
],
]
);
<?php
namespace Codeception\Module;
// here you can define custom functions for CliGuy
class CliHelper extends \Codeception\Module
{
public function runShellCmd($command, $failNonZero = true)
{
$data = array();
#exec($command, $data, $resultCode);
exec("/app/yii 'migrate'", $data, $resultCode);
$this->output = implode("\n", $data);
if ($this->output === null) {
\PHPUnit_Framework_Assert::fail("$command can't be executed");
}
if ($resultCode !== 0 && $failNonZero) {
\PHPUnit_Framework_Assert::fail("Result code was $resultCode.\n\n" . $this->output);
}
$this->debug(preg_replace('~s/\e\[\d+(?>(;\d+)*)m//g~', '', $this->output));
}
}
<?php
namespace Codeception\Module;
// here you can define custom actions
// all public methods declared in helper class will be available in $I
class FunctionalHelper extends \Codeception\Module
{
}
<?php
/**
* Inherited Methods
* @method void wantToTest($text)
* @method void wantTo($text)
* @method void execute($callable)
* @method void expectTo($prediction)
* @method void expect($prediction)
* @method void amGoingTo($argumentation)
* @method void am($role)
* @method void lookForwardTo($achieveValue)
* @method void comment($description)
* @method \Codeception\Lib\Friend haveFriend($name, $actorClass = NULL)
*
* @SuppressWarnings(PHPMD)
*/
class FunctionalTester extends \Codeception\Actor
{
use _generated\FunctionalTesterActions;
/**
* Define custom actions here
*/
}
<?php
namespace Codeception\Module;
// here you can define custom actions
// all public methods declared in helper class will be available in $I
class UnitHelper extends \Codeception\Module
{
}
<?php //[STAMP] 33ba7c80e2577d6ac8ef41e7f7aaad5a
<?php //[STAMP] ebc9e817e95a85adbdeda62cb1003395
namespace _generated;
// This class was automatically generated by build task
......@@ -7,7 +7,6 @@ namespace _generated;
use Codeception\Module\Filesystem;
use Codeception\Module\Cli;
use Codeception\Module\CliHelper;
trait CliTesterActions
{
......@@ -487,15 +486,4 @@ trait CliTesterActions
public function seeShellOutputMatches($regex) {
return $this->getScenario()->runStep(new \Codeception\Step\Assertion('seeShellOutputMatches', func_get_args()));
}
/**
* [!] Method is generated. Documentation taken from corresponding module.
*
*
* @see \Codeception\Module\CliHelper::runShellCmd()
*/
public function runShellCmd($command, $failNonZero = null) {
return $this->getScenario()->runStep(new \Codeception\Step\Action('runShellCmd', func_get_args()));
}
}
This diff is collapsed.
<?php //[STAMP] edb6aa7f939a5dbf370d33e2c69c0f52
<?php //[STAMP] 7e9a9989a025d721f4a8bd2b3dc6a71e
namespace _generated;
// This class was automatically generated by build task
......@@ -6,7 +6,6 @@ namespace _generated;
// @codingStandardsIgnoreFile
use Codeception\Module\Asserts;
use Codeception\Module\UnitHelper;
trait UnitTesterActions
{
......
......@@ -22,7 +22,7 @@ class LoginPage extends BasePage
$this->actor->fillField('input[name="login-form[password]"]', $password);
$this->actor->click('Sign in');
if (method_exists($this->actor, 'waitForElement')) {
$this->actor->waitForElement('.user-footer', 5);
$this->actor->waitForText($username, 5);
}
}
}
......@@ -9,7 +9,6 @@ modules:
enabled:
- Filesystem
- Cli
- CliHelper
config:
PhpBrowser:
url: 'http://localhost/myapp/'
version: '2'
services:
phpfpm:
volumes:
# host volume for local debugging of generated files
- tmpvolume:/app/src/modules/${GIIANT_TEST_DB}
volumes:
tmpvolume:
\ No newline at end of file
......@@ -10,15 +10,18 @@ services:
- DB_ENV_MYSQL_ROOT_PASSWORD=secretadmin
- DATABASE_DSN_DB=${GIIANT_TEST_DB}
- GIIANT_TEST_DB=${GIIANT_TEST_DB}
- "APP_MIGRATION_LOOKUP=@vendor/schmunk42/yii2-giiant/tests/_migrations"
- APP_CONFIG_FILE=/app/vendor/schmunk42/yii2-giiant/tests/_config/local.php
- APP_MIGRATION_LOOKUP=@vendor/schmunk42/yii2-giiant/tests/_migrations
depends_on:
- mariadb
- seleniumfirefox
volumes:
- /app
# host volume for local debugging of generated files
# host volume for local development
- ../:/app/vendor/schmunk42/yii2-giiant
- ../tests/_config/local.php:/app/src/config/local.php
# host volume for local debugging of generated files
- ./tmp/${GIIANT_TEST_DB}:/app/src/modules/${GIIANT_TEST_DB}
nginx:
image: schmunk42/nginx:1.9
......@@ -40,7 +43,7 @@ services:
- ./_build/test.cnf:/etc/mysql/conf.d/test.cnf
seleniumfirefox:
image: 'selenium/standalone-firefox-debug:2.48.2'
image: 'selenium/standalone-firefox-debug:2.53.0'
expose:
- '4444'
ports:
......
# Codeception Test Suite Configuration
# suite for functional (integration) tests.
# emulate web requests and make application process them.
# (tip: better to use with frameworks).
# RUN `build` COMMAND AFTER ADDING/REMOVING MODULES.
#basic/web/index.php
class_name: FunctionalTester
modules:
enabled:
- Filesystem
- Yii2
config:
Yii2:
configFile: 'tests/_config/functional.php'
<?php
$config = require(dirname(__DIR__) . '/_config/functional.php');
new yii\web\Application($config);
<?php
// @group sakila
use schmunk42\giiant\tests\_pages\LoginPage;
$I = new FunctionalTester($scenario);
$I->wantTo('ensure that crud works (WITHOUT access rules applied!)');
$I->amOnPage('/en/crud/film');
$I->see('Films', 'h1');
......@@ -3,4 +3,4 @@
# suite for unit (internal) tests.
class_name: UnitTester
modules:
enabled: [Asserts, UnitHelper]
enabled: [Asserts]
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment