diff --git a/.travis.yml b/.travis.yml index e6452a50157..6cb26817d09 100644 --- a/.travis.yml +++ b/.travis.yml @@ -29,13 +29,8 @@ install: - composer install - phpenv rehash - # Install jslint - - npm install -g jslint - - # Install ESLint and plugins - - npm -g install eslint@3.8.1 - - npm -g install eslint-config-google@0.6.0 - - npm -g install eslint-plugin-react + # Install node modules specified in package.json + - npm install # Download a Selenium Web Driver release - wget "http://selenium-release.storage.googleapis.com/2.52/selenium-server-standalone-2.52.0.jar" @@ -79,54 +74,8 @@ before_script: # - "LORIS_DB_CONFIG=test/config.xml" script: - # Run PHP -l on everything to ensure there's no syntax - # errors. - - for i in `ls php/libraries/*.class.inc modules/*/php/* modules/*/ajax/* htdocs/*.php htdocs/*/*.php`; - do - php -l $i || exit $?; - done - - # Run PHPCS on the entire libraries directory. - - vendor/bin/phpcs --standard=docs/LorisCS.xml php/libraries php/exceptions php/installer - - vendor/bin/phpcs --standard=docs/LorisCS.xml --extensions=php/php htdocs - - # Run PHPCS on some scripts - - vendor/bin/phpcs --standard=docs/LorisCS.xml tools/CouchDB_Import_MRI.php - - vendor/bin/phpcs --standard=docs/LorisCS.xml tools/assign_missing_instruments.php - - vendor/bin/phpcs --standard=docs/LorisCS.xml tools/data_dictionary_builder.php - - vendor/bin/phpcs --standard=docs/LorisCS.xml tools/generic_includes.php - - # Run PHPCS on specific modules - - vendor/bin/phpcs --standard=docs/LorisCS.xml modules/imaging_uploader/php/NDB_Menu_Filter_imaging_uploader.class.inc - - vendor/bin/phpcs --standard=docs/LorisCS.xml modules/imaging_uploader/php/File_Decompress.class.inc - - vendor/bin/phpcs --standard=docs/LorisCS.xml --extensions=php/php,inc/php modules/genomic_browser - - vendor/bin/phpcs --standard=docs/LorisCS.xml --extensions=php/php,inc/php modules/candidate_list - - vendor/bin/phpcs --standard=docs/LorisCS.xml --extensions=php/php,inc/php modules/conflict_resolver - - vendor/bin/phpcs --standard=docs/LorisCS.xml --extensions=php/php,inc/php modules/dashboard - - vendor/bin/phpcs --standard=docs/LorisCS.xml --extensions=php/php,inc/php modules/examiner - - vendor/bin/phpcs --standard=docs/LorisCS.xml --extensions=php/php,inc/php modules/training - - vendor/bin/phpcs --standard=docs/LorisCS.xml --extensions=php/php,inc/php modules/brainbrowser - - vendor/bin/phpcs --standard=docs/LorisCS.xml --extensions=php/php,inc/php modules/configuration - - vendor/bin/phpcs --standard=docs/LorisCS.xml --extensions=php/php,inc/php modules/acknowledgements - - vendor/bin/phpcs --standard=docs/LorisCS.xml --extensions=php/php,inc/php modules/data_release - - vendor/bin/phpcs --standard=docs/LorisCS.xml --extensions=php/php,inc/php modules/media - - vendor/bin/phpcs --standard=docs/LorisCS.xml --extensions=php/php,inc/php modules/candidate_parameters/ajax - - vendor/bin/phpcs --standard=docs/LorisCS.xml --extensions=php/php,inc/php modules/dicom_archive - - vendor/bin/phpcs --standard=docs/LorisCS.xml --extensions=php/php,inc/php modules/create_timepoint - - vendor/bin/phpcs --standard=docs/LorisCS.xml --extensions=php/php,inc/php modules/issue_tracker - - # Run JSLINT on specific scripts - - jslint htdocs/js/jquery.dynamictable.js - - # Run ESLint on Loris modules - - eslint modules/ - - # Run ESLint on generic React components - - eslint jsx/ - - # Run ESLint on specific scripts - - eslint htdocs/js/util/ - - eslint Gruntfile.js + - npm run lint:php + - npm run lint:javascript # Run unit tests to make sure functions still do what they should. - vendor/bin/phpunit --configuration test/phpunit.xml --coverage-clover=coverage.xml diff --git a/Dockerfile.test.db b/Dockerfile.test.db new file mode 100644 index 00000000000..414ff8e6992 --- /dev/null +++ b/Dockerfile.test.db @@ -0,0 +1,27 @@ +FROM mysql:5.7 + +ARG BASE_DIR + +COPY SQL/0000-00-00-schema.sql /0000-00-00-schema.sql +COPY SQL/0000-00-01-Permission.sql /0000-00-01-Permission.sql +COPY SQL/0000-00-02-Menus.sql /0000-00-02-Menus.sql +COPY SQL/0000-00-03-ConfigTables.sql /0000-00-03-ConfigTables.sql +COPY SQL/0000-00-04-Help.sql /0000-00-04-Help.sql +COPY SQL/0000-00-99-indexes.sql /0000-00-99-indexes.sql + +COPY test/sql/CreateTestUser.sql /0000-01-00-TestUser.sql +COPY docs/instruments/radiology_review.sql /radiology_review.sql + +RUN echo "Use LorisTest;" | cat - \ + 0000-00-00-schema.sql \ + 0000-00-01-Permission.sql \ + 0000-00-02-Menus.sql \ + 0000-00-03-ConfigTables.sql \ + 0000-00-04-Help.sql \ + 0000-00-99-indexes.sql \ + 0000-01-00-TestUser.sql \ + radiology_review.sql > /docker-entrypoint-initdb.d/0000-compiled.sql + +RUN echo "Use LorisTest;" >> /docker-entrypoint-initdb.d/0001-paths.sql +RUN echo "UPDATE Config SET Value='${BASE_DIR}/' WHERE ConfigID=(SELECT ID FROM ConfigSettings WHERE Name='base');" >> /docker-entrypoint-initdb.d/0001-paths.sql +RUN echo "UPDATE Config SET Value='http://web:8000' WHERE ConfigID=(SELECT ID FROM ConfigSettings WHERE Name='url');" >> /docker-entrypoint-initdb.d/0001-paths.sql diff --git a/Dockerfile.test.php7 b/Dockerfile.test.php7 new file mode 100644 index 00000000000..31dfecc4715 --- /dev/null +++ b/Dockerfile.test.php7 @@ -0,0 +1,7 @@ +FROM php:7.0 + +RUN apt-get update && \ + apt-get install -y mysql-client zlib1g-dev + +# Install extensions through the scripts the container provides +RUN docker-php-ext-install pdo_mysql zip diff --git a/Dockerfile.test.php7.debug b/Dockerfile.test.php7.debug new file mode 100644 index 00000000000..58e8c57da64 --- /dev/null +++ b/Dockerfile.test.php7.debug @@ -0,0 +1,12 @@ +FROM php:7.0 + +RUN apt-get update && \ + apt-get install -y mysql-client zlib1g-dev + +RUN yes | pecl install xdebug-2.4.1 +RUN echo "zend_extension=$(find /usr/local/lib/php/extensions/ -name xdebug.so)" > /usr/local/etc/php/conf.d/xdebug.ini +RUN echo "xdebug.remote_enable=on" >> /usr/local/etc/php/conf.d/xdebug.ini +RUN echo "xdebug.remote_autostart=on" >> /usr/local/etc/php/conf.d/xdebug.ini + +# Install extensions through the scripts the container provides +RUN docker-php-ext-install pdo_mysql zip diff --git a/docker-compose.yml b/docker-compose.yml new file mode 100644 index 00000000000..7d94668c23d --- /dev/null +++ b/docker-compose.yml @@ -0,0 +1,111 @@ +version: '2' +services: + db: + build: + context: . + dockerfile: Dockerfile.test.db + args: + BASE_DIR: /app/ + environment: + - MYSQL_DATABASE=LorisTest + - MYSQL_RANDOM_ROOT_PASSWORD=yes + + selenium: + image: selenium/standalone-firefox-debug:2.53.1 + ports: + - "5900:5900" + + web: + build: + context: . + dockerfile: Dockerfile.test.php7 + volumes: + - ./:/app + environment: + - LORIS_DB_CONFIG=/app/test/config.xml + depends_on: + - db + command: php -S 0.0.0.0:8000 -t /app/htdocs /app/htdocs/router.php + + unit-tests: + build: + context: . + dockerfile: Dockerfile.test.php7 + volumes: + - ./:/app + working_dir: /app + environment: + - LORIS_DB_CONFIG=test/config.xml + depends_on: + - db + entrypoint: /app/test/wait-for-services.sh + + integration-tests: + build: + context: . + dockerfile: Dockerfile.test.php7 + volumes: + - ./:/app + working_dir: /app + environment: + - LORIS_DB_CONFIG=test/config.xml + - SELENIUM_REQUIRED=true + depends_on: + - db + - selenium + - web + entrypoint: /app/test/wait-for-services.sh + + selenium-debug: + image: selenium/standalone-firefox-debug:2.53.1 + links: + - web-debug:web + ports: + - "5901:5900" + + web-debug: + build: + context: . + dockerfile: Dockerfile.test.php7.debug + volumes: + - ./:/app + environment: + - LORIS_DB_CONFIG=/app/test/config.xml + - XDEBUG_CONFIG=remote_host=${XDEBUG_REMOTE_HOST} + - PHP_IDE_CONFIG=serverName=LorisTests + depends_on: + - db + command: php -S 0.0.0.0:8000 -t /app/htdocs /app/htdocs/router.php + + unit-tests-debug: + build: + context: . + dockerfile: Dockerfile.test.php7.debug + volumes: + - ./:/app + working_dir: /app + environment: + - LORIS_DB_CONFIG=test/config.xml + - XDEBUG_CONFIG=remote_host=${XDEBUG_REMOTE_HOST} + - PHP_IDE_CONFIG=serverName=LorisTests + depends_on: + - db + entrypoint: /app/test/wait-for-services.sh + + integration-tests-debug: + build: + context: . + dockerfile: Dockerfile.test.php7.debug + volumes: + - ./:/app + working_dir: /app + environment: + - LORIS_DB_CONFIG=test/config.xml + - SELENIUM_REQUIRED=true + - XDEBUG_CONFIG=remote_host=${XDEBUG_REMOTE_HOST} + - PHP_IDE_CONFIG=serverName=LorisTests + links: + - db + - selenium-debug:selenium + - web-debug:web + entrypoint: /app/test/wait-for-services.sh diff --git a/modules/instrument_list/test/instrument_listTest.php b/modules/instrument_list/test/instrument_listTest.php index fa335483e03..768afd6e2d2 100644 --- a/modules/instrument_list/test/instrument_listTest.php +++ b/modules/instrument_list/test/instrument_listTest.php @@ -38,6 +38,9 @@ class InstrumentListTestIntegrationTest extends LorisIntegrationTest */ function testInstrumentListDoespageLoad() { + $this->markTestSkipped( + 'Test is outdated/broken. This module requires candID and sessionID query parameters' + ); $this->webDriver->get($this->url . "/instrument_list/"); $bodyText = $this->webDriver->findElement( WebDriverBy::cssSelector("body") @@ -52,6 +55,9 @@ function testInstrumentListDoespageLoad() */ function testInstrumentListDoespageLoadWithPermission() { + $this->markTestSkipped( + 'Test is outdated/broken. This module requires candID and sessionID query parameters' + ); $this->setupPermissions(array("access_all_profiles")); $this->webDriver->get($this->url . "/instrument_list/"); $bodyText = $this->webDriver->findElement( diff --git a/modules/next_stage/test/next_stageTest.php b/modules/next_stage/test/next_stageTest.php index 410ccd84986..0c98bb99e8d 100644 --- a/modules/next_stage/test/next_stageTest.php +++ b/modules/next_stage/test/next_stageTest.php @@ -107,7 +107,7 @@ function testNextStageDateError() $Subproject->sendKeys("Control"); $startVisit = $this->webDriver->findElement(WebDriverBy::Name("fire_away")); - $startVisit->click(); + $startVisit->submit(); $bodyText = $this->webDriver->findElement(WebDriverBy::cssSelector("body"))->getText(); $this->assertContains("Both Date fields must match.", $bodyText); @@ -133,7 +133,7 @@ function testNextStageSuccess() $Subproject->sendKeys("Control"); $startVisit = $this->webDriver->findElement(WebDriverBy::Name("fire_away")); - $startVisit->click(); + $startVisit->submit(); $bodyText = $this->webDriver->findElement(WebDriverBy::cssSelector("body"))->getText(); $this->assertContains("Next stage started.", $bodyText); diff --git a/package.json b/package.json index 58f2745a62e..40b8e9a57a8 100644 --- a/package.json +++ b/package.json @@ -12,15 +12,21 @@ "babel-cli": "^6.8.0", "babel-preset-es2015": "^6.6.0", "babel-preset-react": "^6.5.0", - "eslint": "^3.1.1", - "eslint-config-google": "^0.6.0", + "eslint": "3.8.1", + "eslint-config-google": "0.6.0", "eslint-plugin-react": "^5.2.2", "grunt": "^1.0.1", "grunt-babel": "^6.0.0", + "jslint": "^0.10.3", "load-grunt-tasks": "^3.5.0" }, "scripts": { - "test": "echo \"Error: no test specified\" && exit 1" + "lint:javascript": "./test/run-js-linter.sh", + "lint:php": "./test/run-php-linter.sh", + "tests:unit": "./test/dockerized-unit-tests.sh", + "tests:unit:debug": "DEBUG=true ./test/dockerized-unit-tests.sh", + "tests:integration": "./test/dockerized-integration-tests.sh", + "tests:integration:debug": "DEBUG=true ./test/dockerized-integration-tests.sh" }, "repository": { "type": "git", diff --git a/test/README.md b/test/README.md new file mode 100644 index 00000000000..61b9ba0c057 --- /dev/null +++ b/test/README.md @@ -0,0 +1,87 @@ +# Dockerized Test Suite + +## Requirements +You will need Docker Engine, Docker Compose, and NodeJS. + +Please follow the directions [here](https://docs.docker.com/engine/installation/) to install Docker Engine. Be sure to also [create a Docker group](https://docs.docker.com/engine/installation/linux/ubuntulinux/#/create-a-docker-group) so Docker can be run without using `sudo`. + +Next, install Docker Compose: + +``` +curl -L https://github.com/docker/compose/releases/download/1.8.1/docker-compose-`uname -s`-`uname -m` > ~/docker-compose +chmod +x ~/docker-compose +sudo mv ~/docker-compose /usr/local/bin/docker-compose +``` + +Make sure you have NodeJS installed. If not, follow the instructions [here](https://nodejs.org/en/download/package-manager/). + +Finally, run `npm install` in the root folder (this is only required for Javascript linting). + +## Basic Workflow + +**To run all the unit tests:** + +``` +npm run tests:unit +``` + +**To run all of the integration tests:** + +``` +npm run tests:integration +``` + +You can see the integration tests in action by connecting your VNC viewer to `:5900` and supplying the password `secret`. + + +**To run PHP linting:** + +``` +npm run lint:php +``` + +**To run Javascript linting:** + +``` +npm run lint:javascript +``` + +## Advanced Workflow + +#### Command-Line Options +You can pass any [PHPUnit command-line options](https://phpunit.de/manual/current/en/textui.html) by appending `--` followed by the options. For example, say you only wanted to run the unit tests contained in the `CandidateTest` class. To achieve this you could run the following command: + +``` +npm run tests:unit -- --filter CandidateTest +``` + +Or, to run a specific test within `CandidateTest`: + +``` +npm run tests:unit -- --filter CandidateTest::testValidatePSCID +``` + +#### Debugging + +Both the unit and integration tests can be run with XDebug enabled. + +``` +npm run tests:unit:debug +``` +Or +``` +npm run tests:integration:debug +``` + +You must specify a remote host for XDebug to connect to via the `XDEBUG_REMOTE_HOST` environment variable when using either of these commands. + + +## Todo + +- Run integration tests in parallel + +## Issues + +- By default npm will output some irrelevant info when a script returns a non-zero error code, as described [here](https://github.com/npm/npm/issues/8821). To prevent this pass `-s` or `--silent` to `npm run`, e.g. `npm run -s tests:unit`. + +- Running the entire integration test suite with XDebug enabled sometimes results in a segmentation fault. This appears to be an issue with XDebug itself. diff --git a/test/config.xml b/test/config.xml new file mode 100644 index 00000000000..330158458d5 --- /dev/null +++ b/test/config.xml @@ -0,0 +1,180 @@ + + + + + + 1 + http://selenium:4444/wd/hub + + + + + db + SQLTestUser + TestPassword + LorisTest + SQLTestUser + TestPassword + Example database + + + + false + + + + + + + sequential + + + + + + + + random + + BBB + + + + + + + candidate_comment + ProbandDoB + MRI_Done + + + + + + user + /^[A-Z0-9]{2}$/i + 2 + V%value% + + V01 + V02 + + + + + + user + /^[A-Z0-9]{2}$/i + 2 + V%value% + + V01 + V02 + + + + + + aosi + 0.5 + AOSI + + + adi_r_proband + 89.5 + ADI-R (Proband) + + + adi_r_subject + 89.5 + ADI-R (Subject) + + + csbs + 79.5 + CSBS + + + ados_module1 + 79.5 + ADOS (Module1) + + + ados_module2 + 79.5 + ADOS (Module2) + + + + + + 0 + + + + + + + + + + + + + + + false + + study_consent + + + + + + + + + 0 + + + + + + false + + + + sampleInstrument + + sampleInstrumentPermissionName + + + sampleInstrument2 + sampleInstrument2PermissionName + + + + + %MINCTOOLSPATH% + + diff --git a/test/dockerized-integration-tests.sh b/test/dockerized-integration-tests.sh new file mode 100755 index 00000000000..37516f861a0 --- /dev/null +++ b/test/dockerized-integration-tests.sh @@ -0,0 +1,12 @@ +#!/bin/bash +set -e + +if [ "$DEBUG" == "true" ] +then + CONTAINER=integration-tests-debug +else + CONTAINER=integration-tests +fi + +docker-compose run -T --rm ${CONTAINER} vendor/bin/phpunit --configuration test/phpunit.xml --testsuite LorisCoreIntegrationTests $* +docker-compose run -T --rm ${CONTAINER} vendor/bin/phpunit --configuration test/phpunit.xml --testsuite LorisModuleIntegrationTests $* diff --git a/test/dockerized-unit-tests.sh b/test/dockerized-unit-tests.sh new file mode 100755 index 00000000000..653b7915b52 --- /dev/null +++ b/test/dockerized-unit-tests.sh @@ -0,0 +1,11 @@ +#!/bin/bash +set -e + +if [ "$DEBUG" == "true" ] +then + CONTAINER=unit-tests-debug +else + CONTAINER=unit-tests +fi + +docker-compose run -T --rm ${CONTAINER} vendor/bin/phpunit --configuration test/phpunit.xml --testsuite LorisUnitTests $* diff --git a/test/fixtures/tables/NDB_BVL_FeedbackTest.xml b/test/fixtures/tables/NDB_BVL_FeedbackTest.xml index b1c69689012..17303979b0d 100644 --- a/test/fixtures/tables/NDB_BVL_FeedbackTest.xml +++ b/test/fixtures/tables/NDB_BVL_FeedbackTest.xml @@ -194,7 +194,7 @@ 2015-05-14 20:40:46 - - + Y diff --git a/test/integration.sh b/test/integration.sh index 4e686c6ae11..120ee6de477 100755 --- a/test/integration.sh +++ b/test/integration.sh @@ -74,8 +74,8 @@ if [ ! -z "$module" ]; then ../vendor/bin/phpunit --configuration phpunit.xml ../modules/$module/test else # Run all integration tests - ../vendor/bin/phpunit --configuration phpunit.xml --testsuite 'Loris Core Integration Tests' - ../vendor/bin/phpunit --configuration phpunit.xml --testsuite 'Loris Module Integration Tests' + ../vendor/bin/phpunit --configuration phpunit.xml --testsuite 'LorisCoreIntegrationTests' + ../vendor/bin/phpunit --configuration phpunit.xml --testsuite 'LorisModuleIntegrationTests' fi kill $php_pid diff --git a/test/integrationtests/LorisIntegrationTest.class.inc b/test/integrationtests/LorisIntegrationTest.class.inc index 4c3125c4449..2ab7c279719 100644 --- a/test/integrationtests/LorisIntegrationTest.class.inc +++ b/test/integrationtests/LorisIntegrationTest.class.inc @@ -90,13 +90,16 @@ abstract class LorisIntegrationTest extends PHPUnit_Framework_TestCase $user = User::factory('UnitTester'); $user->updatePassword('4test4'); + $dev = $this->config->getSettingFromXML('dev'); + $selenium_url = isset($dev['selenium_url']) ? $dev['selenium_url'] : 'http://localhost:4444/wd/hub'; + $capabilities = array( WebDriverCapabilityType::BROWSER_NAME => 'firefox', WebDriverCapabilityType::JAVASCRIPT_ENABLED => true, ); $this->webDriver = RemoteWebDriver::create( - 'http://localhost:4444/wd/hub', + $selenium_url, $capabilities ); diff --git a/test/phpunit.xml b/test/phpunit.xml index fdfe6b36ec1..7ab841f533e 100644 --- a/test/phpunit.xml +++ b/test/phpunit.xml @@ -4,16 +4,16 @@ verbose="true" colors="true"> - + ./unittests/ ./unittests/api - + ./integrationtests/ - + ../modules/candidate_list/test/ ../modules/candidate_parameters/test/ ../modules/brainbrowser/test/ diff --git a/test/run-js-linter.sh b/test/run-js-linter.sh new file mode 100755 index 00000000000..9df4875a0e0 --- /dev/null +++ b/test/run-js-linter.sh @@ -0,0 +1,15 @@ +#!/usr/bin/env bash +set -e + +# Run JSLINT on specific scripts +./node_modules/jslint/bin/jslint.js htdocs/js/jquery.dynamictable.js + +# Run ESLint on Loris modules +./node_modules/eslint/bin/eslint.js modules/ + +# Run ESLint on generic React components +./node_modules/eslint/bin/eslint.js eslint jsx/ + +# Run ESLint on specific scripts +./node_modules/eslint/bin/eslint.js eslint htdocs/js/util/ +./node_modules/eslint/bin/eslint.js eslint Gruntfile.js diff --git a/test/run-php-linter.sh b/test/run-php-linter.sh new file mode 100755 index 00000000000..c145501297d --- /dev/null +++ b/test/run-php-linter.sh @@ -0,0 +1,38 @@ +#!/usr/bin/env bash +set -e + +# Run PHP -l on everything to ensure there's no syntax +# errors. +for i in `ls php/libraries/*.class.inc modules/*/php/* modules/*/ajax/* htdocs/*.php htdocs/*/*.php`; +do + php -l $i || exit $?; +done + +# Run PHPCS on the entire libraries directory. +vendor/bin/phpcs --standard=docs/LorisCS.xml php/libraries php/exceptions php/installer +vendor/bin/phpcs --standard=docs/LorisCS.xml --extensions=php/php htdocs + +# Run PHPCS on some scripts +vendor/bin/phpcs --standard=docs/LorisCS.xml tools/CouchDB_Import_MRI.php +vendor/bin/phpcs --standard=docs/LorisCS.xml tools/assign_missing_instruments.php +vendor/bin/phpcs --standard=docs/LorisCS.xml tools/data_dictionary_builder.php +vendor/bin/phpcs --standard=docs/LorisCS.xml tools/generic_includes.php + +# Run PHPCS on specific modules +vendor/bin/phpcs --standard=docs/LorisCS.xml modules/imaging_uploader/php/NDB_Menu_Filter_imaging_uploader.class.inc +vendor/bin/phpcs --standard=docs/LorisCS.xml modules/imaging_uploader/php/File_Decompress.class.inc +vendor/bin/phpcs --standard=docs/LorisCS.xml --extensions=php/php,inc/php modules/genomic_browser +vendor/bin/phpcs --standard=docs/LorisCS.xml --extensions=php/php,inc/php modules/candidate_list +vendor/bin/phpcs --standard=docs/LorisCS.xml --extensions=php/php,inc/php modules/conflict_resolver +vendor/bin/phpcs --standard=docs/LorisCS.xml --extensions=php/php,inc/php modules/dashboard +vendor/bin/phpcs --standard=docs/LorisCS.xml --extensions=php/php,inc/php modules/examiner +vendor/bin/phpcs --standard=docs/LorisCS.xml --extensions=php/php,inc/php modules/training +vendor/bin/phpcs --standard=docs/LorisCS.xml --extensions=php/php,inc/php modules/brainbrowser +vendor/bin/phpcs --standard=docs/LorisCS.xml --extensions=php/php,inc/php modules/configuration +vendor/bin/phpcs --standard=docs/LorisCS.xml --extensions=php/php,inc/php modules/acknowledgements +vendor/bin/phpcs --standard=docs/LorisCS.xml --extensions=php/php,inc/php modules/data_release +vendor/bin/phpcs --standard=docs/LorisCS.xml --extensions=php/php,inc/php modules/media +vendor/bin/phpcs --standard=docs/LorisCS.xml --extensions=php/php,inc/php modules/candidate_parameters/ajax +vendor/bin/phpcs --standard=docs/LorisCS.xml --extensions=php/php,inc/php modules/dicom_archive +vendor/bin/phpcs --standard=docs/LorisCS.xml --extensions=php/php,inc/php modules/create_timepoint +vendor/bin/phpcs --standard=docs/LorisCS.xml --extensions=php/php,inc/php modules/issue_tracker diff --git a/test/sql/CreateTestUser.sql b/test/sql/CreateTestUser.sql new file mode 100644 index 00000000000..571b3482be3 --- /dev/null +++ b/test/sql/CreateTestUser.sql @@ -0,0 +1,2 @@ +GRANT UPDATE,INSERT,SELECT,DELETE,DROP,CREATE TEMPORARY TABLES ON LorisTest.* TO 'SQLTestUser'@'%' IDENTIFIED BY 'TestPassword' WITH GRANT OPTION; +UPDATE users SET Password_MD5=CONCAT('aa', MD5('aatestpass')), Pending_approval='N', Password_expiry='2100-01-01' WHERE ID=1; diff --git a/test/unittests.sh b/test/unittests.sh index 758221c71a2..af9b82d4392 100755 --- a/test/unittests.sh +++ b/test/unittests.sh @@ -38,5 +38,5 @@ elif [ $# -eq 1 ]; then ../vendor/bin/phpunit --configuration phpunit.xml $1 ./unittests/$1.php else # Run all unittest -../vendor/bin/phpunit --debug --configuration phpunit.xml --testsuite 'LorisUnitTests for php/libraries' +../vendor/bin/phpunit --debug --configuration phpunit.xml --testsuite 'LorisUnitTests' fi diff --git a/test/wait-for-services.sh b/test/wait-for-services.sh new file mode 100755 index 00000000000..fdf219b26a8 --- /dev/null +++ b/test/wait-for-services.sh @@ -0,0 +1,22 @@ +#!/bin/bash + +# Wrapper script which waits until MySQL and Selenium are up and serving requests. + +set -e + +cmd="$@" + +echo "Waiting for mysqld..." +while ! mysqladmin ping -h db -u SQLTestUser --password="TestPassword" --silent ; do + sleep 1 +done + +if [ "$SELENIUM_REQUIRED" = true ] ; then + echo "Waiting for Selenium..." + until $(curl --output /dev/null --silent --head --fail http://selenium:4444/wd/hub); do + sleep 1 + done + echo "Selenium is alive" +fi + +exec $cmd