Skip to content

Commit 5ba5753

Browse files
committed
Mobile app support
Adds a MOODLE_MOBILE_VERSION environment parameter do define a Moodle app docker image. If the browser is chrome and it is defined the mobile app will be started and Moodle configured so it is available for behat tests.
1 parent 0b3dcfe commit 5ba5753

File tree

8 files changed

+34
-0
lines changed

8 files changed

+34
-0
lines changed

.travis.yml

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -55,13 +55,17 @@ env:
5555
- "PHP=7.1 DB=mariadb GIT=v3.8.0 SUITE=behat BROWSER=firefox"
5656
- "PHP=7.1 DB=mariadb GIT=v3.7.2 SUITE=behat BROWSER=chrome"
5757
- "PHP=7.0 DB=mariadb GIT=v3.5.8 SUITE=behat BROWSER=firefox"
58+
# Mobile app
59+
- "PHP=7.3 DB=pgsql GIT=master SUITE=app BROWSER=chrome MOBILE=next"
60+
- "PHP=7.3 DB=pgsql GIT=master SUITE=app BROWSER=chrome MOBILE=latest"
5861
install:
5962
- git clone --branch $GIT --depth 1 git://github.com/moodle/moodle $HOME/moodle
6063
- cp config.docker-template.php $HOME/moodle/config.php
6164
- export MOODLE_DOCKER_DB=$DB
6265
- export MOODLE_DOCKER_BROWSER=$BROWSER
6366
- export MOODLE_DOCKER_WWWROOT="$HOME/moodle"
6467
- export MOODLE_DOCKER_PHP_VERSION=$PHP
68+
- export MOODLE_MOBILE_VERSION=$MOBILE
6569
before_script:
6670
- tests/setup.sh
6771
script:

README.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -134,6 +134,7 @@ You can change the configuration of the docker images by setting various environ
134134
| `MOODLE_DOCKER_WEB_HOST` | no | any valid hostname | localhost | The hostname for web |
135135
| `MOODLE_DOCKER_WEB_PORT` | no | any integer value (or bind_ip:integer)| 127.0.0.1:8000| The port number for web. If set to 0, no port is used.<br/>If you want to bind to any host IP different from the default 127.0.0.1, you can specify it with the bind_ip:port format (0.0.0.0 means bind to all) |
136136
| `MOODLE_DOCKER_SELENIUM_VNC_PORT` | no | any integer value (or bind_ip:integer)| not set | If set, the selenium node will expose a vnc session on the port specified. Similar to MOODLE_DOCKER_WEB_PORT, you can optionally define the host IP to bind to. If you just set the port, VNC binds to 127.0.0.1 |
137+
| `MOODLE_MOBILE_VERSION` | no | next, latest, or an app version number| not set | If set will start an instance of the Mmodle app if the chrome browser is selected |
137138

138139
## Advanced usage
139140

bin/moodle-docker-compose

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -44,6 +44,12 @@ if [ -f $filename ]; then
4444
dockercompose="${dockercompose} -f ${filename}"
4545
fi
4646

47+
# Mobile app
48+
if [[ ! -z "$MOODLE_DOCKER_BROWSER" ]] && [[ "$MOODLE_DOCKER_BROWSER" == "chrome" ]] && [[ ! -z "$MOODLE_MOBILE_VERSION" ]];
49+
then
50+
dockercompose="${dockercompose} -f ${basedir}/moodle-app.yml"
51+
fi
52+
4753
# Selenium browser
4854
if [[ ! -z "$MOODLE_DOCKER_BROWSER" ]] && [[ "$MOODLE_DOCKER_BROWSER" != "firefox" ]];
4955
then

bin/moodle-docker-compose.cmd

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,12 @@ if exist %filename% (
3434
SET DOCKERCOMPOSE=%DOCKERCOMPOSE% -f "%filename%"
3535
)
3636

37+
IF "%MOODLE_DOCKER_BROWSER%"=="chrome" (
38+
IF NOT "%MOODLE_MOBILE_VERSION%"=="" (
39+
SET DOCKERCOMPOSE=%DOCKERCOMPOSE% -f "%BASEDIR%\moodle-app.yml"
40+
)
41+
)
42+
3743
IF NOT "%MOODLE_DOCKER_BROWSER%"=="" (
3844
IF NOT "%MOODLE_DOCKER_BROWSER%"=="firefox" (
3945
SET DOCKERCOMPOSE=%DOCKERCOMPOSE% -f "%BASEDIR%\selenium.%MOODLE_DOCKER_BROWSER%.yml"

config.docker-template.php

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -58,6 +58,10 @@
5858

5959
define('PHPUNIT_LONGTEST', true);
6060

61+
if (getenv('MOODLE_DOCKER_MOBILE')) {
62+
$CFG->behat_ionic_wwwroot = 'http://mobileapp:8100';
63+
}
64+
6165
if (getenv('MOODLE_DOCKER_PHPUNIT_EXTRAS')) {
6266
define('TEST_SEARCH_SOLR_HOSTNAME', 'solr');
6367
define('TEST_SEARCH_SOLR_INDEXNAME', 'test');

moodle-app.yml

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
version: "2"
2+
services:
3+
webserver:
4+
environment:
5+
MOODLE_DOCKER_MOBILE: "true"
6+
mobileapp:
7+
image: "moodlehq/moodlemobile2:${MOODLE_MOBILE_VERSION}"

tests/setup.sh

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,9 @@ elif [ "$SUITE" = "phpunit-full" ];
1212
then
1313
export MOODLE_DOCKER_PHPUNIT_EXTERNAL_SERVICES=true
1414
initcmd="bin/moodle-docker-compose exec -T webserver php admin/tool/phpunit/cli/init.php"
15+
elif [ "$SUITE" = "app" ];
16+
then
17+
initcmd="bin/moodle-docker-compose exec -T webserver php admin/tool/behat/cli/init.php"
1518
else
1619
echo "Error, unknown suite '$SUITE'"
1720
exit 1

tests/test.sh

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,9 @@ then
1212
elif [ "$SUITE" = "phpunit-full" ];
1313
then
1414
testcmd="bin/moodle-docker-compose exec -T webserver vendor/bin/phpunit --verbose"
15+
elif [ "$SUITE" = "app" ];
16+
then
17+
testcmd="bin/moodle-docker-compose exec -T webserver php admin/tool/behat/cli/run.php --tags=@app"
1518
else
1619
echo "Error, unknown suite '$SUITE'"
1720
exit 1

0 commit comments

Comments
 (0)