forked from aces/Loris
-
Notifications
You must be signed in to change notification settings - Fork 0
/
.travis.yml
99 lines (84 loc) · 5.25 KB
/
.travis.yml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
language: php
cache:
directories:
- vendor
php:
- "7.1"
- "7.2"
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
- pecl install -f ast-0.1.6
- php -S localhost:8000 -t htdocs htdocs/router.php 2>1 > /dev/null &
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"
# 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')"
- mkdir -p data/loris/bin/mri
- mysql LorisTest -e "UPDATE Config SET Value='data/loris/bin/mri' WHERE ConfigID=(SELECT ID FROM ConfigSettings WHERE Name='MRICodePath')"
# 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:
- vendor/bin/phan && npm run lint:php && npm run lint:javascript && vendor/bin/phpunit --configuration test/phpunit.xml