Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add acceptance tests and Docker based CI #83

Open
wants to merge 74 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
74 commits
Select commit Hold shift + click to select a range
0e1f158
test docker stack
keywan-ghadami-oxid Jan 26, 2019
181ea38
init docker swarm to be able to deploy stack
keywan-ghadami-oxid Jan 26, 2019
19146a5
adding network
keywan-ghadami-oxid Jan 26, 2019
bbe58ff
defining network in composer file
keywan-ghadami-oxid Jan 26, 2019
0354a73
user prebuild container
keywan-ghadami-oxid Jan 26, 2019
5ad660f
use minumal travis image
keywan-ghadami-oxid Jan 26, 2019
0d7fdfc
fix travis file
keywan-ghadami-oxid Jan 26, 2019
1bb5a75
fix yaml file
keywan-ghadami-oxid Jan 26, 2019
57f9dd7
refactore to shell scripts
keywan-ghadami-oxid Jan 26, 2019
23dde5d
add test script
keywan-ghadami-oxid Jan 26, 2019
2702bce
configure shop when running tests
keywan-ghadami-oxid Jan 26, 2019
2299631
call test.sh
keywan-ghadami-oxid Jan 27, 2019
c2426d9
using fpm container
keywan-ghadami-oxid Jan 27, 2019
5c68184
moved files to ci folder
keywan-ghadami-oxid Feb 1, 2019
29fa8d6
add httpd config file
keywan-ghadami-oxid Feb 1, 2019
0daf52a
changed directory mapping to /module inside the container
keywan-ghadami-oxid Feb 1, 2019
dc477e4
use host user
keywan-ghadami-oxid Feb 1, 2019
3682a17
some configuration changes
keywan-ghadami-oxid Feb 3, 2019
e04c039
home folder mapping, oxid 6.1, passing term (to allow color in terminal)
keywan-ghadami-oxid Feb 3, 2019
451f886
new folder structure using /oxid to be able to install module from /m…
keywan-ghadami-oxid Feb 3, 2019
5a8667e
remove unsupported domain name
keywan-ghadami-oxid Feb 3, 2019
d78f72d
changed directory mapping, install shop manually
keywan-ghadami-oxid Feb 4, 2019
3d9002e
fix mysql hostname
keywan-ghadami-oxid Feb 4, 2019
78d189c
fix config.inc.php
keywan-ghadami-oxid Feb 4, 2019
aa86d4b
require module (todo make it dynamic)
keywan-ghadami-oxid Feb 4, 2019
ca63a11
add composer repository
keywan-ghadami-oxid Feb 4, 2019
3bacb55
the ci folder must be excluded from installation
keywan-ghadami-oxid Feb 4, 2019
4c1dc4b
use the running fmp container for shell access
keywan-ghadami-oxid Feb 5, 2019
d7073b6
use the current USER to run process in container
keywan-ghadami-oxid Feb 5, 2019
90b0049
git ignore logs
keywan-ghadami-oxid Mar 27, 2019
2e16639
add logs, allow root user access for apache container
keywan-ghadami-oxid Feb 5, 2019
99010d6
fix ports (internal port is now 8080 because non root user can not use
keywan-ghadami-oxid Feb 5, 2019
6b708bb
using /var/www as base as developers maybe used to that folder
keywan-ghadami-oxid Feb 5, 2019
bbc55cd
git ignore logs
keywan-ghadami-oxid Feb 5, 2019
1bdad42
fix folders in fcgi proxy setting and oxid config
keywan-ghadami-oxid Feb 5, 2019
cba2e97
upgrade testing library to version 6
keywan-ghadami-oxid Feb 5, 2019
25ffb4a
initial setup from other develop state
rogoit Jan 17, 2019
7d6268d
add empty unit folder with git ignore file and add composer.lock
rogoit Jan 21, 2019
ecb780b
add selenium to codeception.yml
rogoit Jan 22, 2019
15df77c
adding selenium container
keywan-ghadami-oxid Jan 27, 2019
09dd7a0
resolved dependency conflicts
keywan-ghadami-oxid Jan 27, 2019
a609193
added codeception
keywan-ghadami-oxid Feb 5, 2019
f30d136
fix typo in prepare script
keywan-ghadami-oxid Feb 5, 2019
458ddc3
install flow theme and add servername
keywan-ghadami-oxid Feb 6, 2019
6a85aaf
use bash as quick fix for not working script on travis
keywan-ghadami-oxid Feb 7, 2019
e47bc8f
try executing tests on travis
keywan-ghadami-oxid Feb 7, 2019
9c13189
try executing tests on travis
keywan-ghadami-oxid Feb 7, 2019
908b4e4
add execution flags for scripts
keywan-ghadami-oxid Feb 8, 2019
de2b919
add some debug output
keywan-ghadami-oxid Feb 8, 2019
7f2eeea
add some debug output
keywan-ghadami-oxid Feb 8, 2019
9d52799
try to get container id
keywan-ghadami-oxid Feb 8, 2019
81079b6
switch to docker compose
keywan-ghadami-oxid Feb 8, 2019
625df26
fix docker compose installation
keywan-ghadami-oxid Feb 8, 2019
e61e60c
fix docker compose work directory
keywan-ghadami-oxid Feb 8, 2019
fe700fd
fix docker compose work directory
keywan-ghadami-oxid Feb 8, 2019
97d457d
adapt container execution scripts to docker compose
keywan-ghadami-oxid Feb 8, 2019
6f5ffeb
more debugging on the scripts
keywan-ghadami-oxid Feb 8, 2019
7a2d900
verbose docker compose version
keywan-ghadami-oxid Feb 8, 2019
40d65e7
update docker-compose
keywan-ghadami-oxid Feb 8, 2019
0c0fc9d
verbose docker nodes
keywan-ghadami-oxid Feb 8, 2019
6ac01bc
run docker-compose in background
keywan-ghadami-oxid Feb 8, 2019
43eda2d
run docker-compose in background
keywan-ghadami-oxid Feb 8, 2019
11c0572
run fpm install script in the right directory
keywan-ghadami-oxid Feb 8, 2019
fa7e504
add sleep
keywan-ghadami-oxid Feb 8, 2019
1a696f7
restore git keep
keywan-ghadami-oxid Feb 8, 2019
d190fd4
try running docker compose in detached mode on travis
keywan-ghadami-oxid Feb 8, 2019
043e3f9
adapt path for tests
keywan-ghadami-oxid Feb 8, 2019
98f7461
try running docker compose in detached mode on travis
keywan-ghadami-oxid Feb 8, 2019
70d0c82
fix codeception call
keywan-ghadami-oxid Feb 8, 2019
f373250
fix runtest call
keywan-ghadami-oxid Feb 8, 2019
72d61ff
do not call test twice
keywan-ghadami-oxid Feb 8, 2019
ac35a60
adapt path for tests
keywan-ghadami-oxid Feb 8, 2019
2465955
make shop ready without tests
keywan-ghadami-oxid Mar 27, 2019
26fe46d
add .gitlab-ci.yml
SvenBrunk May 16, 2019
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions .env.dist
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
DB_HOST="localhost"
DB_USER="root"
DB_PASS="root"
DB_NAME="oxid"
WEBSITE_URL="http://oxdev.de"
7 changes: 7 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,3 +1,10 @@
/.idea
/composer.phar
/vendor
/ci/oxideshop/vendor
/ci/oxideshop/composer.lock
/ci/oxideshop/.ide-helper.php
/ci/oxideshop/source
/ci/oxideshop/.phpstorm.meta.php
/ci/oxideshop/test_config.yml
/ci/logs/
Empty file added .gitlab-ci.yml
Empty file.
18 changes: 0 additions & 18 deletions .travis.before_script.sh

This file was deleted.

43 changes: 17 additions & 26 deletions .travis.yml
Original file line number Diff line number Diff line change
@@ -1,36 +1,27 @@
language: php

language: minimal
dist: xenial
php:
- "7.1"

env:
- OXID=6.1
- OXID=6.0

cache:
directories:
- $HOME/OXID
services: mysql

# - OXID=6.0
#cache:
# directories:
# - $HOME/OXID
services:
- docker
before_install:
- echo 'Europe/Berlin' | sudo tee /etc/timezone
- sudo dpkg-reconfigure --frontend noninteractive tzdata
- mysql -e 'CREATE DATABASE oxid;'

- sudo rm /usr/local/bin/docker-compose
- curl -L https://github.com/docker/compose/releases/download/1.23.2/docker-compose-`uname -s`-`uname -m` > docker-compose
- chmod +x docker-compose
- sudo mv docker-compose /usr/local/bin
before_script:
- export BRANCH=$(if [ "$TRAVIS_PULL_REQUEST" == "false" ]; then echo $TRAVIS_BRANCH; else echo $TRAVIS_PULL_REQUEST_BRANCH; fi)
- sh ./.travis.before_script.sh

- bash ./ci/prepare.sh
script:
- cd ~/OXID/
# - ./vendor/bin/runtests-coverage
- ./vendor/bin/runtests
# - php vendor/bin/codacycoverage clover ~/OXID/source/modules/oxcom/moduleinternals/Tests/reports/clover.xml --git-commit=$TRAVIS_COMMIT

- bash ./ci/execOnFpm.sh bash /ci/test.sh
before_cache:
- composer remove "oxid-community/moduleinternals"
- rm -rf ~/OXID/source/modules/oxcom/moduleinternals
- rm -rf ~/OXID/vendor/oxid-community/moduleinternals
- rm -rf ~/OXID/source/tmp/*

# - composer remove "oxid-community/moduleinternals"
# - rm -rf ~/OXID/source/modules/oxcom/moduleinternals
# - rm -rf ~/OXID/vendor/oxid-community/moduleinternals
# - rm -rf ~/OXID/source/tmp/*
20 changes: 20 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,26 @@ Original module (for Oxid eShop 5.x/4.x) by [Alfonsas Cirtautas](https://github.
composer require oxid-community/moduleinternals
```

## Run Codeception tests
First copy .env.dist to .env and set your credentials

### Run all tests
```
.Build/bin/codecept run
```

### Run all in a suite
```
.Build/bin/codecept run acceptance
```

### Params
--steps --html -vvv

Steps will show on cli
Html repourt as file
Verbose to see all information for debugging

## Screenshot

![OXID_moduleinternals](screenshot.png)
Expand Down
Empty file added Testscc/_data/.gitkeep
Empty file.
2 changes: 2 additions & 0 deletions Testscc/_output/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
*
!.gitignore
26 changes: 26 additions & 0 deletions Testscc/_support/AcceptanceTester.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
<?php
namespace OxidCommunity\ModuleInternals\Testscc;

/**
* 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 AcceptanceTester extends \Codeception\Actor
{
use _generated\AcceptanceTesterActions;

/**
* Define custom actions here
*/
}
10 changes: 10 additions & 0 deletions Testscc/_support/Helper/Acceptance.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
<?php
namespace OxidCommunity\ModuleInternals\Testscc\Helper;

// here you can define custom actions
// all public methods declared in helper class will be available in $I

class Acceptance extends \Codeception\Module
{

}
10 changes: 10 additions & 0 deletions Testscc/_support/Helper/Unit.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
<?php
namespace OxidCommunity\ModuleInternals\Testcc\Helper;

// here you can define custom actions
// all public methods declared in helper class will be available in $I

class Unit extends \Codeception\Module
{

}
12 changes: 12 additions & 0 deletions Testscc/_support/Page/page.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
<?php
namespace OxidCommunity\ModuleInternals\Testscc\Page;

class page
{
// include url of current page
public static $startpageSearchInput = '#searchParam';
public static $startpageSearchButton = '#header > div > div > div > div.col-xs-12.col-sm-12.col-md-4.col-md-pull-4.search-col > form > div > span > button > i';

// Search result
public static $searchResultHeadline = 'h1';
}
26 changes: 26 additions & 0 deletions Testscc/_support/UnitTester.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
<?php
namespace OxidCommunity\ModuleInternals\Testscc;

/**
* 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 UnitTester extends \Codeception\Actor
{
use _generated\UnitTesterActions;

/**
* Define custom actions here
*/
}
2 changes: 2 additions & 0 deletions Testscc/_support/_generated/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
*
!.gitignore
11 changes: 11 additions & 0 deletions Testscc/acceptance.suite.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
# Codeception Test Suite Configuration
#
# Suite for acceptance tests.
# Perform tests in browser using the WebDriver or PhpBrowser.
# If you need both WebDriver and PHPBrowser tests - create a separate suite.

class_name: AcceptanceTester
modules:
enabled:
- Asserts
- WebDriver
23 changes: 23 additions & 0 deletions Testscc/acceptance/checkconsistency/overviewCest.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
<?php
namespace OxidCommunity\ModuleInternals\Testscc\checkconsistency;

use OxidCommunity\ModuleInternals\Testscc\AcceptanceTester;

class overviewCest
{
public function _before(AcceptanceTester $I)
{
$I->amOnPage('/index.php?cl=checkconsistency&key=abc');
$I->waitForElement('.accordion');
}

/**
* @skip
*/
public function checkConsitencyOverview(AcceptanceTester $I)
{
$I->click('.accordion');
$I->see('module_internals_metadata');
$I->see('OxidCommunity\ModuleInternals\Controller\Admin\Metadatatest');
}
}
30 changes: 30 additions & 0 deletions Testscc/acceptance/startpage/searchCest.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
<?php
namespace OxidCommunity\ModuleInternals\Testscc\startpage;

use OxidCommunity\ModuleInternals\Testscc\AcceptanceTester;
use OxidCommunity\ModuleInternals\Testscc\Page\page;

class searchCest
{
public function _before(AcceptanceTester $I, page $page)
{
$I->amOnPage('/');
$I->waitForElement($page::$startpageSearchInput);
}

public function tryToTest(AcceptanceTester $I, page $page)
{
$search = 'kiteboard';
$I->fillField($page::$startpageSearchInput, $search);
$I->click($page::$startpageSearchButton);

$I->waitForElement($page::$searchResultHeadline);
$I->canSeeInCurrentUrl($search);

$searchInputValue = $I->grabValueFrom($page::$startpageSearchInput);
$I->assertSame($searchInputValue, $search);

$headline = explode(' ', $I->grabTextFrom($page::$searchResultHeadline));
$I->assertContains('"' . $search . '"', $headline);
}
}
8 changes: 8 additions & 0 deletions Testscc/unit.suite.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
# Codeception Test Suite Configuration
#
# Suite for unit or integration tests.

actor: UnitTester
modules:
enabled:
- Asserts
2 changes: 2 additions & 0 deletions Testscc/unit/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
*
!.gitignore
3 changes: 3 additions & 0 deletions ci/.env
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
OXID=6.1
GID=1000
UID=1000
55 changes: 55 additions & 0 deletions ci/docker-compose.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,55 @@
version: "3"
services:

selenium:
image: selenium/standalone-chrome
networks:
- frontend
ports:
- 4444:4444

fpm:
image: keywanghadamioxid/php-fpm-oxid
networks:
- frontend
volumes:
- ${PWD}/:/ci
- ${PWD}/..:/module
- /etc/passwd:/etc/passwd:ro
- /etc/group:/etc/group:ro
- ${HOME}:${HOME}
depends_on:
- mysql
user: "${UID}:${GID}"

apache:
user: "${UID}"
image: httpd:2.4-alpine
depends_on:
- mysql
- fpm
volumes:
- ${PWD}/:/ci
- ${PWD}/logs:/usr/local/apache2/logs
- ${PWD}/httpd.conf:/usr/local/apache2/conf/httpd.conf
- /etc/passwd:/etc/passwd:ro
- /etc/group:/etc/group:ro
- ${HOME}:${HOME}
ports:
- 8080:8080
networks:
- frontend

mysql:
image: mysql:5.7
hostname: mysql
environment:
MYSQL_DATABASE: oxid
MYSQL_USER: oxid
MYSQL_PASSWORD: oxid
MYSQL_ROOT_PASSWORD: oxid
networks:
- frontend

networks:
frontend:
Loading