Skip to content

Commit

Permalink
Merge branch 'feature/codeception_tests' into develop
Browse files Browse the repository at this point in the history
  • Loading branch information
einpraegsam committed Dec 20, 2024
2 parents 94bf1ff + ad61cc5 commit 585cb82
Show file tree
Hide file tree
Showing 13 changed files with 226 additions and 14 deletions.
10 changes: 10 additions & 0 deletions .env
Original file line number Diff line number Diff line change
Expand Up @@ -35,3 +35,13 @@ TYPO3_INSTALL_ADMIN_PASSWORD=Password123!
TYPO3_INSTALL_SITE_NAME="Lux"
TYPO3_INSTALL_SITE_SETUP_TYPE=no
TYPO3_INSTALL_WEB_SERVER_CONFIG=apache

# CodeCeption
SELENIARM_PORT_4442=61000
SELENIARM_PORT_4443=61001
SELENIARM_PORT_4444=61002
PORT_CHROME=61003
PORT_FIREFOX=61004
VNC_PORT_CHROME=61005
VNC_PORT_FIREFOX=61006
TEST_URL='https://local.lux.de'
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -26,3 +26,5 @@ var/
/config/
/.phpunit.cache/
/.env.local
/Tests/Acceptance/_output/*
/Tests/Acceptance/_support/_generated/
11 changes: 11 additions & 0 deletions .project/docker/php/Dockerfile
Original file line number Diff line number Diff line change
@@ -1,3 +1,14 @@
FROM in2code/php-dev:8.2-fpm

COPY zz_xdebug.ini /usr/local/etc/php/conf.d/zz_xdebug.ini

USER root

# Install CURL extension
RUN apt-get update && apt-get install -y \
libcurl4-openssl-dev \
&& docker-php-ext-install curl \
&& apt-get clean \
&& rm -rf /var/lib/apt/lists/*

USER www-data
3 changes: 2 additions & 1 deletion .project/tests/.php-cs-fixer.php
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,8 @@
__DIR__ . '/../../Tests',
__DIR__ . '/../../Configuration',
]
);
)
->notPath('#^Acceptance/#');
// Return a Code Sniffing configuration using
// all sniffers needed for PSR-2
// and additionally:
Expand Down
42 changes: 42 additions & 0 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -212,6 +212,48 @@ ifeq ($(shell uname -s), Darwin)
docker-compose exec -u root php chown -R app:app /app/$(TYPO3_CACHE_DIR)/;
endif

## Test: PHP CS Fixer
test-phpcs:
echo "$(EMOJI_robot) Test: Start PHP CS Fixer tests"
docker-compose exec php composer test:php:cs

## Test: PHP Linter
test-phplint:
echo "$(EMOJI_robot) Test: Start PHP Linter tests"
docker-compose exec php composer test:php:lint

## Test: TypoScript Linter
test-tslint:
echo "$(EMOJI_robot) Test: Start TypoScript Linter tests"
docker-compose exec php composer test:ts:lint

## Test: Unit
test-unit:
echo "$(EMOJI_robot) Test: Start unit tests"
docker-compose exec php composer test:unit

## Run acceptance tests
test-acceptance: .selenium-start
echo "$(EMOJI_robot) Test: Start acceptance tests"
docker-compose exec php bash -c "\
sleep 2 && \
./.Build/bin/codecept clean && \
./.Build/bin/codecept build && \
./.Build/bin/codecept run acceptance"
echo "$(EMOJI_broom) Cleaning up selenium services"; \
make .selenium-stop; \
exit $${EXIT_CODE:-0}

## Start Selenium services for testing
.selenium-start:
echo "$(EMOJI_rocket) Starting Selenium services for testing"
docker compose -f docker-compose.yml -f docker-compose.selenium.yml up -d seleniarm-hub chrome firefox

## Stop Selenium services for testing
.selenium-stop:
echo "$(EMOJI_stop) Stopping Selenium services"
docker compose -f docker-compose.selenium.yml stop seleniarm-hub chrome firefox

include .env

# SETTINGS
Expand Down
25 changes: 25 additions & 0 deletions Tests/Acceptance/_support/AcceptanceTester.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
<?php

namespace In2code\Lux\Tests;

use In2code\Lux\Tests\_generated\AcceptanceTesterActions;

/**
* 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 void pause()
*
* @SuppressWarnings(PHPMD)
*/
class AcceptanceTester extends \Codeception\Actor
{
use AcceptanceTesterActions;
}
15 changes: 15 additions & 0 deletions Tests/Acceptance/_support/Helper/BackendTester.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
<?php

namespace In2code\Lux\Tests\Helper;

class BackendTester extends \Codeception\Module
{
public function loginToBackend($I, $username = 'akellner', $password = 'akellner')
{
$I->amOnPage('/typo3/');
$I->fillField('#t3-username', $username);
$I->fillField('#t3-password', $password);
$I->click('Login');
$I->waitForElement('#typo3-cms-backend-backend-toolbaritems-systeminformationtoolbaritem');
}
}
19 changes: 19 additions & 0 deletions Tests/Acceptance/acceptance.suite.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
actor: AcceptanceTester
modules:
enabled:
- WebDriver:
url: https://local.lux.de
browser: chrome
host: seleniarm-hub
port: 4444
path: '/wd/hub'
connection_timeout: 5
restart: true
window_size: maximize
capabilities:
browserName: "chrome"
acceptInsecureCerts: true
'goog:chromeOptions':
args: ["--no-sandbox", "--headless", "--disable-gpu", "--ignore-certificate-errors"]
- \In2code\Lux\Tests\Helper\BackendTester
step_decorators: ~
21 changes: 21 additions & 0 deletions Tests/Acceptance/acceptance/Backend/BackendLoginCest.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
<?php

namespace In2code\Lux\Tests\Acceptance\Backend;

use In2code\Lux\Tests\AcceptanceTester;

class BackendLoginCest
{
public function _before(AcceptanceTester $I)
{
$I->loginToBackend($I);
}

public function loginToBackendSuccessfully(AcceptanceTester $I)
{
$I->see('LUX');
$I->see('Analyse');
$I->see('Leads');
$I->see('Kampagnen');
}
}
14 changes: 14 additions & 0 deletions Tests/Acceptance/acceptance/Frontend/SimpleHomepageCest.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
<?php

namespace In2code\Lux\Tests\Acceptance\Frontend;

use In2code\Lux\Tests\AcceptanceTester;

class SimpleHomepageCest
{
public function checkHomepage(AcceptanceTester $I)
{
$I->amOnPage('/');
$I->see('Marketing');
}
}
10 changes: 10 additions & 0 deletions codeception.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
namespace: In2code\Lux\Tests
paths:
tests: Tests/Acceptance
output: Tests/Acceptance/_output
data: Tests/Acceptance/_data
support: Tests/Acceptance/_support
envs: Tests/Acceptance/_envs
extensions:
enabled:
- Codeception\Extension\RunFailed
31 changes: 18 additions & 13 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,23 @@
"typo3/cms-dashboard": "*"
},
"require-dev": {
"codeception/codeception": "^5.1",
"codeception/module-asserts": "^3.0",
"codeception/module-phpbrowser": "^3.0",
"codeception/module-webdriver": "^4.0",
"friendsofphp/php-cs-fixer": "^3.10",
"georgringer/news": "^12.0",
"helmich/typo3-typoscript-lint": "^3.1",
"helhum/typo3-console": "^8.2",
"mikey179/vfsstream": "^1.6",
"phpmd/phpmd": "^2.8",
"symfony/config": ">6.2.0",
"squizlabs/php_codesniffer": "^3.5",
"typo3/cms-adminpanel": "^13.3",
"typo3/cms-belog": "^13.3",
"typo3/cms-beuser": "^13.3",
"typo3/cms-core": "^13.3",
"typo3/cms-dashboard": "^13.3",
"typo3/cms-extbase": "^13.3",
"typo3/cms-extensionmanager": "^13.3",
"typo3/cms-felogin": "^13.3",
Expand All @@ -49,26 +65,14 @@
"typo3/cms-frontend": "^13.3",
"typo3/cms-info": "^13.3",
"typo3/cms-install": "^13.3",
"typo3/cms-lowlevel": "^13.3",
"typo3/cms-recordlist": "^13.3",
"typo3/cms-rte-ckeditor": "^13.3",
"typo3/cms-scheduler": "^13.3",
"typo3/cms-setup": "^13.3",
"typo3/cms-t3editor": "^13.3",
"typo3/cms-tstemplate": "^13.3",
"typo3/cms-lowlevel": "^13.3",
"typo3/cms-adminpanel": "^13.3",
"typo3/cms-belog": "^13.3",
"typo3/cms-beuser": "^13.3",
"typo3/cms-dashboard": "^13.3",
"typo3/testing-framework": "^8.2",
"symfony/config": ">6.2.0",
"mikey179/vfsstream": "^1.6",
"squizlabs/php_codesniffer": "^3.5",
"phpmd/phpmd": "^2.8",
"friendsofphp/php-cs-fixer": "^3.10",
"helmich/typo3-typoscript-lint": "^3.1",
"helhum/typo3-console": "^8.2",
"georgringer/news": "^12.0",
"typo3/cms-indexed-search": "^13.4",
"typo3/cms-form": "^13.4"
},
Expand Down Expand Up @@ -100,6 +104,7 @@
},
"extra": {
"typo3/cms": {
"app-dir": ".Build",
"cms-package-dir": "{$vendor-dir}/typo3/cms",
"web-dir": ".Build/public",
"extension-key": "lux",
Expand Down
37 changes: 37 additions & 0 deletions docker-compose.selenium.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
version: "3.7"

services:
chrome:
image: seleniarm/node-chromium:4.1.2-20220227
volumes:
- /dev/shm:/dev/shm
depends_on:
- seleniarm-hub
environment:
- SE_EVENT_BUS_HOST=seleniarm-hub
- SE_EVENT_BUS_PUBLISH_PORT=4442
- SE_EVENT_BUS_SUBSCRIBE_PORT=4443
ports:
- ${PORT_CHROME}:5900
- ${VNC_PORT_CHROME}:5900 # for vnc

firefox:
image: seleniarm/node-firefox:4.1.2-20220227
volumes:
- /dev/shm:/dev/shm
depends_on:
- seleniarm-hub
environment:
- SE_EVENT_BUS_HOST=seleniarm-hub
- SE_EVENT_BUS_PUBLISH_PORT=4442
- SE_EVENT_BUS_SUBSCRIBE_PORT=4443
ports:
- ${PORT_FIREFOX}:5900
- ${VNC_PORT_FIREFOX}:5900 # for vnc

seleniarm-hub:
image: seleniarm/hub:4.1.2-20220227
ports:
- ${SELENIARM_PORT_4442}:4442
- ${SELENIARM_PORT_4443}:4443
- ${SELENIARM_PORT_4444}:4444

0 comments on commit 585cb82

Please sign in to comment.