diff --git a/.travis.yml b/.travis.yml index b903ba94c68..72b4148fb3f 100644 --- a/.travis.yml +++ b/.travis.yml @@ -1,21 +1,99 @@ -sudo: required - -# any language should do it language: php + cache: directories: - vendor php: - "7.1" -services: -- docker + +sudo: false + +addons: + firefox: "44.0" + +before_install: + # Start Xvfb in a desktop screen size, + # otherwise some tests will fail because the links + # are hidden when Selenium tries to find them. + - "/sbin/start-stop-daemon --start --quiet --pidfile /tmp/custom_xvfb_99.pid --make-pidfile --background --exec /usr/bin/Xvfb -- :99 -ac -screen 0 1600x1200x16" + #- "export DISPLAY=:99.0" + #- "sh -e /etc/init.d/xvfb start" + # Ensure node version is up to date + - nvm install node + - mkdir -p project project/libraries + - phpenv config-rm xdebug.ini install: -- sudo apt-get update -- sudo apt-get install -y libapparmor1 -- sudo apt-get install npm -- npm install -- composer install + # Install composer modules + - composer install + - composer require --dev + - phpenv rehash + + # 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" + + - php -S localhost:8000 -t htdocs htdocs/router.php 2>1 > /dev/null & + + # Extracting firefox and setting PATH variable... + - tar -xjf /tmp/firefox-44.0.tar.bz2 --directory /tmp + - export PATH="/tmp/firefox:$PATH" + - echo "Using firefox version `firefox --version`" + + # Start Selenium and redirect Selenium WebDriver + # output to /dev/null so that it doesn't flood the + # screen in the middle of our other tests + - DISPLAY=:99.0 java -jar selenium-server-standalone-2.52.0.jar 2>1 > /dev/null & + +before_script: + # Set up the Loris environment + - mkdir -p project smarty/templates_c project/instruments project/tables_sql + - chmod 777 smarty/templates_c project/instruments project/tables_sql + + # Set up the MySQL database, install the Schema, create a MySQL user + # for the config file, and reset the Loris user's password for testing + - mysql -e 'CREATE DATABASE LorisTest' + - mysql LorisTest < SQL/0000-00-00-schema.sql + - mysql LorisTest < SQL/0000-00-01-Permission.sql + - mysql LorisTest < SQL/0000-00-02-Menus.sql + - mysql LorisTest < SQL/0000-00-03-ConfigTables.sql + - mysql LorisTest < SQL/0000-00-04-Help.sql + - mysql LorisTest < docs/instruments/radiology_review.sql + - mysql LorisTest < test/RBdata.sql + - mysql LorisTest < test/test_instrument/medical_history.sql + - mysql LorisTest -u root -e "GRANT UPDATE,INSERT,SELECT,DELETE,DROP,CREATE TEMPORARY TABLES ON LorisTest.* TO 'SQLTestUser'@'localhost' IDENTIFIED BY 'TestPassword' WITH GRANT OPTION" + - cp docs/config/config.xml project/config.xml + - cp docs/config/config.xml test/config.xml + - sed -i -e "s/%HOSTNAME%/127.0.0.1/g" -e "s/%USERNAME%/SQLTestUser/g" -e "s/%PASSWORD%/TestPassword/g" -e "s/%DATABASE%/LorisTest/g" project/config.xml + - sed -i -e "s/%HOSTNAME%/127.0.0.1/g" -e "s/%USERNAME%/SQLTestUser/g" -e "s/%PASSWORD%/TestPassword/g" -e "s/%DATABASE%/LorisTest/g" test/config.xml + - mysql LorisTest -e "INSERT INTO users (UserID, Password, Real_name, First_name, Last_name, Degree, Position_title, Institution, Department, Address, City, State, Zip_code, Country, Fax, Email, Privilege, PSCPI, DBAccess, Active, Password_hash, Password_expiry, Pending_approval, Doc_Repo_Notifications, Phone) VALUES('travis', NULL, 'unix account', 'unix', 'account', NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, 'unixtest@mail.com', 0, 'N', '', 'Y', '$2y$10$6JvNxHFCugACdUPvCpm3zeSLCEwSKsUyBbfv0/tWKAa8Ga8MmeZIG', '2019-12-06', 'N', 'N', NULL)" + - mysql LorisTest -e "INSERT INTO user_psc_rel VALUES ((SELECT ID FROM users WHERE UserID='travis'), 1)" + # Set the admin account password to a known value for testing. This needs to be done + # after the config.xml is setup. + - cd tools + - echo "testpass" | php ./resetpassword.php admin + - mysql LorisTest -e "UPDATE users SET Pending_approval='N', Password_expiry='2100-01-01' WHERE ID=1" + - cd .. + - mysql LorisTest -e "UPDATE Config SET Value='$(pwd)/' WHERE ConfigID=(SELECT ID FROM ConfigSettings WHERE Name='base')" + - mysql LorisTest -e "UPDATE Config SET Value='http://localhost:8000' WHERE ConfigID=(SELECT ID FROM ConfigSettings WHERE Name='url')" + + # Set up the testing instrument environment + - cp test/test_instrument/NDB_BVL_Instrument_testtest.class.inc project/instruments/NDB_BVL_Instrument_testtest.class.inc + - mysql LorisTest -e "INSERT INTO test_names (Test_name, Full_name, Sub_group,IsDirectEntry) VALUES ('testtest', 'testtest', '1','1')" + - mysql LorisTest -e "INSERT INTO test_battery (Test_name, AgeMinDays, AgeMaxDays, Active, Stage, SubprojectID, Visit_label, CenterID) VALUES ('testtest', '1', '99999', 'Y', 'V1', '1', '2', NULL)" + - cd tools + - find ../project/instruments/NDB_BVL_Instrument_testtest.class.inc | php lorisform_parser.php + - find ../project/instruments/NDB_BVL_Instrument_testtest.class.inc | php generate_tables_sql.php + - cd .. + - mysql LorisTest < project/tables_sql/testtest.sql +#env: + # - "LORIS_DB_CONFIG=test/config.xml" + script: -- npm run lint:php && npm run lint:javascript && docker-compose run -T --rm integration-tests vendor/bin/phpunit --configuration test/phpunit.xml + + - npm run lint:php && npm run lint:javascript && vendor/bin/phpunit --configuration test/phpunit.xml + +dist: precise diff --git a/Dockerfile b/Dockerfile index ba72f349d34..31b3398f471 100644 --- a/Dockerfile +++ b/Dockerfile @@ -2,7 +2,7 @@ FROM ubuntu:14.04 MAINTAINER Dave MacFarlane # Stock images come without apt archive -- needs an update RUN apt-get -qqq update -RUN apt-get -y install php7 php7-json curl git php7-mysql mysql-client +RUN apt-get -y install php5 php5-json curl git php5-mysql mysql-client #RUN git clone https://github.com/aces/Loris.git /var/www/loris #INCLUDE HOSTNAME REPLACEMENT? COPY . /var/www/loris diff --git a/Dockerfile.MySQL b/Dockerfile.MySQL index ebc39e55638..67d0cd2adb4 100644 --- a/Dockerfile.MySQL +++ b/Dockerfile.MySQL @@ -1,4 +1,4 @@ -FROM mysql:5.6 +FROM mysql:5.5 COPY SQL/0000-00-00-schema.sql /0000-00-00-schema.sql COPY SQL/0000-00-01-Permission.sql /0000-00-01-Permission.sql diff --git a/Dockerfile.test.php7 b/Dockerfile.test.php7 index ed5eed5c096..31dfecc4715 100644 --- a/Dockerfile.test.php7 +++ b/Dockerfile.test.php7 @@ -1,4 +1,4 @@ -FROM php:7.1 +FROM php:7.0 RUN apt-get update && \ apt-get install -y mysql-client zlib1g-dev diff --git a/modules/dicom_archive/test/dicom_archiveTest.php b/modules/dicom_archive/test/dicom_archiveTest.php index 2eb286aafe5..0d958fcd397 100644 --- a/modules/dicom_archive/test/dicom_archiveTest.php +++ b/modules/dicom_archive/test/dicom_archiveTest.php @@ -235,7 +235,6 @@ function _clear($name,$location ,$key) function testLinksViewDetails() { $this->safeGet($this->url . "/dicom_archive/"); - sleep(1); $location = "#dynamictable > tbody > tr:nth-child(1) > td:nth-child(8) > a"; $text = $this->webDriver->executescript( "return document.querySelector('$location').textContent" @@ -244,7 +243,6 @@ function testLinksViewDetails() $this->webDriver->executescript( "document.querySelector('$location').click()" ); - sleep(1); $text = $this->webDriver->getPageSource(); $this->assertContains('View Details', $text); }