Skip to content

Commit

Permalink
[TASK] Add codeception test setup
Browse files Browse the repository at this point in the history
  • Loading branch information
einpraegsam committed Dec 20, 2024
1 parent 94bf1ff commit e1a4495
Show file tree
Hide file tree
Showing 10 changed files with 150 additions and 13 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
10 changes: 10 additions & 0 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -212,6 +212,16 @@ ifeq ($(shell uname -s), Darwin)
docker-compose exec -u root php chown -R app:app /app/$(TYPO3_CACHE_DIR)/;
endif

## Start Selenium services for testing
.selenium-start:
echo "$(EMOJI_rocket) Starting Selenium services for testing"
docker compose -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;
}
14 changes: 14 additions & 0 deletions Tests/Acceptance/acceptance.suite.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
actor: AcceptanceTester
modules:
enabled:
- WebDriver:
url: https://local.lux.de
browser: chrome
host: seleniarm-hub
port: 4444
window_size: maximize
capabilities:
acceptInsecureCerts: true
'goog:chromeOptions':
args: ["--ignore-certificate-errors"]
step_decorators: ~
13 changes: 13 additions & 0 deletions Tests/Acceptance/acceptance/FirstCest.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
<?php
namespace In2code\Lux\Tests\Acceptance;

use In2code\Lux\Tests\AcceptanceTester;

class FirstCest
{
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 e1a4495

Please sign in to comment.