Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
139 changes: 139 additions & 0 deletions .codepipeline/local-dev/local-dev-config.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,139 @@
<?php

//======= Override Main Module Company Parameters ============
Config::set('main.application_name', 'Cmfive');
Config::set('main.company_name', '2pi Software');
Config::set('main.company_url', 'https://2pisoftware.com');
Config::set('main.company_support_email', getenv('SMTP_SENDER') ?: '');

//=============== Timezone ===================================
date_default_timezone_set('Australia/Sydney');
Config::set("system.timezone", "Australia/Sydney");

//========== Database Configuration ==========================
Config::set("database", [
"hostname" => "mysqldb",
"username" => "cmfive",
"password" => "cmfive",
"database" => "cmfive",
"driver" => getenv('DB') ?: "mysql",
"backups" =>
[
'outputExt' => 'sql',
'commandPath' => [
'unix' => '/usr/bin/',
'windows' => '"C:\\Program Files\\MySQL\\MySQL Server 5.6\\bin\\'
],
'backupCommand' => [
'unix' => 'mysqldump -u $username -h $hostname -P $port -p\'$password\' $dbname > $filename',
'windows' => 'mysqldump.exe" -h$hostname -P$port -u$username -p$password $dbname > $filename'
],
'restoreCommand' => [
'unix' => 'mysql -u $username -h $hostname -P $port -p\'$password\' $dbname < $filename',
'windows' => 'mysql.exe" -D$dbname -h$hostname -P$port -u$username -p$password < $filename'
],
]
]);

Config::set("report.database", [
"hostname" => "mysqldb",
"username" => "cmfivero",
"password" => "cmfivero",
"database" => "cmfive",
"driver" => getenv('DB') ?: "mysql",
]);

//=========== Email Layer Configuration =====================
Config::append('email', [
"layer" => "smtp", // smtp or sendmail or aws
"command" => "", // used for sendmail layer only
"host" => "email-smtp.ap-southeast-2.amazonaws.com",
"port" => 465,
"auth" => true,
"username" => getenv('SMTP_USERNAME') ?: '<email>',
"password" => getenv('SMTP_PASSWORD') ?: '<password>',
]);

//========== TestRunner Configuration ==========================
Config::set("system.environment", "development");
Config::set("core_template.foundation.reveal.animation", "none");
Config::set("core_template.foundation.reveal.animation_speed", 0);
//========== must be "ENABLED" to run ==========================
//========== "config" will pass through to CmfiveSite helper ===
Config::set('system.environment', "development");
Config::set(
"tests",
[
"testrunner" => "ENABLED",
"config" => '',
"yaml" =>
[
"- WebDriver:" =>
[
"url" => "http://webapp:3000",
"browser" => "chrome",
"wait" => "8",
"host" => "seleniumDrv",
"port" => "4444",
"capabilities" =>
[
"acceptInsecureCerts" => true,
"goog:chromeOptions" => [
"w3c" => "false",
"args" => '['
.'"--headless=new","--disable-gpu",'
.'"-proxy-bypass-list=*","--proxy-server=direct://","--dns-prefetch-disable",'
.'"--disk-cache-size=0","–-media-cache-size=0",'
.'"--window-size=1920,1200","--disable-remote-fonts",'
.'"--ignore-certificate-errors","--disable-extensions","--no-sandbox",'
// .'"--enable-logging=/var/customlog/ch.log","--v=1'
.'"--disable-dev-shm-usage"'
.']'
]
]
],
"- Db:" =>
[
"dsn" => "mysql:host=mysqldb:3306;dbname=cmfive",
"user" => "cmfive",
"password" => "cmfive",
],
"- Asserts:" => "",
]
]
);

//========= Anonymous Access ================================
// bypass authentication if sent from the following IP addresses
// specify an IP address and an array of allowed actions from that IP
Config::set("system.allow_from_ip", [
// "10.0.0.0" => array("action1", "action2"),
]);

// or bypass authentication for the following modules
Config::set("system.allow_module", [
// "rest", // uncomment this to switch on REST access to the database objects.
]);

// or bypass authentication for the following actions
Config::set('system.allow_action', [
"auth/login",
"auth/forgotpassword",
"auth/resetpassword",
//"admin/datamigration"
]);

//========= REST Configuration ==============================
// check the following configuration carefully to secure
// access to the REST infrastructure.
//===========================================================

// use the API_KEY to authenticate with username and password
Config::set('system.rest_api_key', "abcdefghijklmnopqrstuvwxyz1234567890");

// include class of objects that you want available via REST
// be aware that only the listed objects will be available via
// the REST API
Config::set('system.rest_include', [
// "Contact"
]);
38 changes: 21 additions & 17 deletions .codepipeline/local-dev/start.sh
Original file line number Diff line number Diff line change
@@ -1,26 +1,30 @@
#!/bin/bash

./test/.install/install.sh

#setup for XDebug

if ping -c 1 host.docker.internal; then INTERNAL_HOST_IP=host.docker.internal; \
else if ping -c 1 docker.for.mac.localhost; then INTERNAL_HOST_IP=docker.for.mac.localhost; \
else if ping -c 1 docker.for.win.localhost; then INTERNAL_HOST_IP=docker.for.win.localhost; \
else INTERNAL_HOST_IP=$(ip route show default | awk '/default/ {print $3}'); fi; fi; fi;
# if ping -c 1 host.docker.internal; then INTERNAL_HOST_IP=host.docker.internal; \
# else if ping -c 1 docker.for.mac.localhost; then INTERNAL_HOST_IP=docker.for.mac.localhost; \
# else if ping -c 1 docker.for.win.localhost; then INTERNAL_HOST_IP=docker.for.win.localhost; \
# else INTERNAL_HOST_IP=$(ip route show default | awk '/default/ {print $3}'); fi; fi; fi;

# echo "zend_extension=xdebug.so" > /etc/php/8.1/fpm/conf.d/20-xdebug.ini \
# && echo "[xdebug]" >> /etc/php/8.1/fpm/conf.d/20-xdebug.ini \
# && echo "xdebug.mode=debug" >> /etc/php/8.1/fpm/conf.d/20-xdebug.ini \
# && echo "xdebug.client_host=${INTERNAL_HOST_IP}" >> /etc/php/8.1/fpm/conf.d/20-xdebug.ini \
# && echo "xdebug.client_port=9003" >> /etc/php/8.1/fpm/conf.d/20-xdebug.ini \
# && echo "xdebug.remote_connect_back=On" >> /etc/php/8.1/fpm/conf.d/20-xdebug.ini \
# && echo "xdebug.remote_handler=dbgp" >> /etc/php/8.1/fpm/conf.d/20-xdebug.ini \
# && echo "xdebug.remote_log=/tmp/xdebug.log" >> /etc/php/8.1/fpm/conf.d/20-xdebug.ini \
# && echo "xdebug.max_nesting_level=250" >> /etc/php/8.1/fpm/conf.d/20-xdebug.ini
# && echo "xdebug.start_with_request=yes" >> /etc/php/8.1/fpm/conf.d/20-xdebug.ini

echo "zend_extension=xdebug.so" > /etc/php/8.1/fpm/conf.d/20-xdebug.ini \
&& echo "[xdebug]" >> /etc/php/8.1/fpm/conf.d/20-xdebug.ini \
&& echo "xdebug.remote_enable=1" >> /etc/php/8.1/fpm/conf.d/20-xdebug.ini \
&& echo "xdebug.remote_host=${INTERNAL_HOST_IP}" >> /etc/php/8.1/fpm/conf.d/20-xdebug.ini \
&& echo "xdebug.remote_connect_back=0" >> /etc/php/8.1/fpm/conf.d/20-xdebug.ini \
&& echo "xdebug.remote_autostart=1" >> /etc/php/8.1/fpm/conf.d/20-xdebug.ini \
&& echo "xdebug.remote_handler=dbgp" >> /etc/php/8.1/fpm/conf.d/20-xdebug.ini \
&& echo "xdebug.max_nesting_level=250" >> /etc/php/8.1/fpm/conf.d/20-xdebug.ini \
&& echo "xdebug.client_host=${INTERNAL_HOST_IP}" >> /etc/php/8.1/fpm/conf.d/20-xdebug.ini \
&& echo "xdebug.mode=debug" >> /etc/php/8.1/fpm/conf.d/20-xdebug.ini \
&& echo "xdebug.start_with_request=yes" >> /etc/php/8.1/fpm/conf.d/20-xdebug.ini \
&& echo "xdebug.client_port=9003" >> /etc/php/8.1/fpm/conf.d/20-xdebug.ini
&& echo "[xdebug]" >> /etc/php/8.1/fpm/conf.d/20-xdebug.ini \
&& echo "xdebug.mode=debug,develop" >> /etc/php/8.1/fpm/conf.d/20-xdebug.ini \
&& echo "xdebug.discover_client_host=true" >> /etc/php/8.1/fpm/conf.d/20-xdebug.ini \
&& echo "xdebug.max_nesting_level=250" >> /etc/php/8.1/fpm/conf.d/20-xdebug.ini \
&& echo "xdebug.start_with_request=yes" >> /etc/php/8.1/fpm/conf.d/20-xdebug.ini

service php8.1-fpm restart

supervisord -n -c /etc/supervisord.conf
2 changes: 1 addition & 1 deletion .codepipeline/test_agent/configs/test_agent-config.php
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,7 @@
"url" => "http://webapp:3000",
"browser" => "chrome",
"wait" => "60",
"host" => "selenium314",
"host" => "seleniumDrv",
"port" => "4444",
"capabilities" =>
[
Expand Down
6 changes: 4 additions & 2 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,12 +3,14 @@ name: CI
on: pull_request

jobs:
# WAS: michaelw90/PHP-Lint@master, stuck on docker PHP7.3!
# WORKS for: StephaneBour/[email protected] = simply "php -l"
phplint:
name: PHP Lint
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- uses: michaelw90/PHP-Lint@master
- uses: actions/checkout@v3
- uses: overtrue/[email protected]
php-codesniffer74:
name: PHP CS 7.4
runs-on: ubuntu-latest
Expand Down
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,8 @@
/storage/session
/log

.phpunit.result.cache

desktop.ini
docker-compose.override.yml
.env
Expand Down
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -35,4 +35,4 @@ php cmfive.php
[select option 3 and fill in the prompts]
```

From there, navigate to [https://localhost:9002](https://localhost:9002) and log in with your admin account
From there, navigate to: [https://localhost:9002](https://localhost:9002) and log in with your admin account.
32 changes: 20 additions & 12 deletions cmfiveTests.php
Original file line number Diff line number Diff line change
Expand Up @@ -22,9 +22,9 @@
defined('HELP_DIRECTORY') || define('HELP_DIRECTORY', DS . 'acceptance' . DS . 'helpers');
defined('UNIT_DIRECTORY') || define('UNIT_DIRECTORY', DS . 'unit');

defined('CEST_DESTINATION') || define('CEST_DESTINATION', TEST_DIRECTORY . DS . 'tests' . DS . 'acceptance');
defined('STEP_DESTINATION') || define('STEP_DESTINATION', TEST_DIRECTORY . DS . 'tests' . DS . '_support' . DS . 'Step' . DS . 'Acceptance');
defined('HELP_DESTINATION') || define('HELP_DESTINATION', TEST_DIRECTORY . DS . 'tests' . DS . '_support' . DS . 'Helper');
defined('CEST_DESTINATION') || define('CEST_DESTINATION', TEST_DIRECTORY . DS . 'tests' . DS . 'Acceptance');
defined('STEP_DESTINATION') || define('STEP_DESTINATION', TEST_DIRECTORY . DS . 'tests' . DS . 'Support' . DS . 'Step' . DS . 'Acceptance');
defined('HELP_DESTINATION') || define('HELP_DESTINATION', TEST_DIRECTORY . DS . 'tests' . DS . 'Support' . DS . 'Helper');
defined('UNIT_DESTINATION') || define('UNIT_DESTINATION', 'test' . DS . 'unit');

defined('SHARED_SOURCE') || define('SHARED_SOURCE', 'boilerplate');
Expand Down Expand Up @@ -56,7 +56,7 @@
'UA_TestConfig' => "tests.config"
];

defined('DEBUG_RUN') || define('DEBUG_RUN', "run --steps --debug acceptance");
defined('DEBUG_RUN') || define('DEBUG_RUN', "run --steps --debug Acceptance");
defined('PHPUNIT_RUN') || define('PHPUNIT_RUN', "");

ini_set('display_errors', 1);
Expand Down Expand Up @@ -297,10 +297,10 @@ function allowRunner()
}
return true;
} else {
echo "Test runner not enabled in config\n";
echo "Test runner not enabled in config\n";
}
} else {
echo "system/web.php not found\n";
echo "system/web.php not found\n";
}
return false;
}
Expand Down Expand Up @@ -424,13 +424,13 @@ function purgeTestCode()
exec('del ' . CEST_DESTINATION . DS . '*Cest.php');
exec('del ' . STEP_DESTINATION . DS . '*.php');
exec('del ' . HELP_DESTINATION . DS . '*.php');
exec('del ' . HELP_DESTINATION . DS . '..' . DS . '*.php');
// exec('del ' . HELP_DESTINATION . DS . '..' . DS . '*.php');
exec('del ' . UNIT_DESTINATION . DS . '*.php');
} else {
exec('rm -f ' . CEST_DESTINATION . DS . '*Cest.php');
exec('rm -f ' . STEP_DESTINATION . DS . '*.php');
exec('rm -f ' . HELP_DESTINATION . DS . '*.php');
exec('rm -f ' . HELP_DESTINATION . DS . '..' . DS . '*.php');
// exec('rm -f ' . HELP_DESTINATION . DS . '..' . DS . '*.php');
exec('rm -f ' . UNIT_DESTINATION . DS . '*.php');
}
}
Expand Down Expand Up @@ -474,7 +474,7 @@ function reportModules($moduleCapabilities)

function registerConfig()
{
$destPath = BOILERPLATE_TEST_DIRECTORY . DS . "acceptance.suite.dist.yml";
$destPath = BOILERPLATE_TEST_DIRECTORY . DS . "Acceptance.suite.dist.yml";
$ConfigYML = fopen($destPath, "w");

if (!$ConfigYML) {
Expand Down Expand Up @@ -511,21 +511,29 @@ function registerHelpers($moduleCapabilities)
// hence could feed test data (CSV,SQL etc)
// $sharedParam & registerBoilerplateParametersmake it work

$destPath = BOILERPLATE_TEST_DIRECTORY . DS . "acceptance.suite.yml";
$destPath = BOILERPLATE_TEST_DIRECTORY . DS . "Acceptance.suite.yml";
$HelperYML = fopen($destPath, "w");

if (!$HelperYML) {
return;
}

$hdr = "modules:\n enabled:\n";
$hdr = "actor: CmfiveUI\n"
. "gherkin:\n"
. " contexts:\n"
. " default:\n"
. " - \Tests\Support\AcceptanceTester\n"
. " - \Tests\Support\CmfiveUI\n"
. "modules:\n"
. " enabled:\n";

fwrite($HelperYML, $hdr);

foreach ($moduleCapabilities as $capabilities => $capability) {
if ($capabilities == "Helpers") {
foreach ($capability as $handler => $resources) {
foreach ($resources as $resource) {
fwrite($HelperYML, " - Helper\\" . $resource . ":\n");
fwrite($HelperYML, " - Tests\\Support\\Helper\\" . $resource . ":\n");
// per notes above, can insert required values here...
$from = $moduleCapabilities['Paths'][$handler][0];
$from = substr($from, 0, strpos($from, "acceptance")) . "acceptance" . DS;
Expand Down
34 changes: 5 additions & 29 deletions docker-compose.yml
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,6 @@ services:
- TZ=Australia/Sydney
volumes:
- ./:/var/www/html
- codecept:/var/www/html/test/Codeception
- ./test/Codeception/tests/boilerplate:/var/www/html/test/Codeception/tests/boilerplate
- ./test/Codeception/tests/_output:/var/www/html/test/Codeception/tests/_output
ports:
Expand All @@ -41,46 +40,23 @@ services:
links:
- mysqldb
- seleniumsrv
# ------------------------------------------------------------
# For IDE&Debug symlinks are best made on the HOST FS
# Otherwise, to customise mounts etc:
# 1) create a docker-compose.override.yml :
# |-------------->
# | version: '3'
# |
# | services:
# | webapp:
# |-------------->
# 2) add your preferences, eg:
# |-------------->
# | volumes:
# | - hostPathTo/myHostFolderFullOfStuff:/var/hostmounts
# |-------------->
# 3) you can make symlinks in container shell under boilerplate, eg:
# |-------------->
# | cd /var/www/html/modules
# | ln -s /var/hostmounts/myModules/cmfiveModule cmfiveModule
# |-------------->
# ------------------------------------------------------------

seleniumsrv:
# promoting:
# docker run --net=cmfive-boilerplate_default --network-alias=selenium314 -p 4444:4444 selenium/standalone-chrome:3.14.0
image: selenium/standalone-chrome:105.0
container_name: selenium314
hostname: selenium314
image: selenium/standalone-chrome:111.0
container_name: seleniumDrv
hostname: seleniumDrv
ports:
- "4444:4444"
environment:
- TZ=Australia/Sydney
- START_XVFB=false
shm_size: '4gb'
networks:
- default

volumes:
dbdata:
driver: local
codecept:
driver: local

networks:
default:
1 change: 0 additions & 1 deletion system
Submodule system deleted from db3ebc
Loading