Commit b1a0df54 authored by Asscheman's avatar Asscheman

Updated the selenium tests

parent 2bc8bff6
...@@ -21,7 +21,7 @@ before_script: ...@@ -21,7 +21,7 @@ before_script:
- ./tests/travis/setup/setup_apache.sh --githubaccount=LUMC - ./tests/travis/setup/setup_apache.sh --githubaccount=LUMC
## IMPORTANT! convert must be run AFTER the setup_apache.sh ## IMPORTANT! convert must be run AFTER the setup_apache.sh
## setup_apache.sh fix some assumptions where the files are stored! ## setup_apache.sh fix some assumptions where the files are stored!
- ./tests/bash_scripts/convert_selenium_to_phpunit.sh --localhost=LOVD3 --continueall - ./tests/bash_scripts/convert_selenium_to_phpunit.sh --projectfolder=LOVD3 --continueall
- ./tests/travis/setup/setup_selenium_server.sh - ./tests/travis/setup/setup_selenium_server.sh
script: script:
...@@ -37,9 +37,15 @@ script: ...@@ -37,9 +37,15 @@ script:
# - vendor/bin/phpunit ./tests/phpunit_selenium/managerTest.php # - vendor/bin/phpunit ./tests/phpunit_selenium/managerTest.php
# - vendor/bin/phpunit ./tests/phpunit_selenium/submitterTest.php # - vendor/bin/phpunit ./tests/phpunit_selenium/submitterTest.php
# - vendor/bin/phpunit ./tests/phpunit_selenium/tempTest.php # - vendor/bin/phpunit ./tests/phpunit_selenium/tempTest.php
- vendor/bin/phpunit -v tests/travis/tests/simpleTest.php
- vendor/bin/phpunit ./tests/phpunit_selenium/tempTest.php
- vendor/bin/phpunit ./tests/travis/tests/
- vendor/bin/phpunit -v -c tests/travis/phpunit.xml
## Run all tests ## Run all tests
- vendor/bin/phpunit ./tests/phpunit_selenium/ - vendor/bin/phpunit -v ./tests/phpunit_selenium/
notifications: notifications:
email: email:
......
...@@ -5,8 +5,6 @@ ...@@ -5,8 +5,6 @@
"phpunit/php-invoker": "1.1.4", "phpunit/php-invoker": "1.1.4",
"phpunit/dbunit": "2.0.2", "phpunit/dbunit": "2.0.2",
"phpunit/phpunit-story": "1.0.2", "phpunit/phpunit-story": "1.0.2",
"phpunit/dbunit": "*",
"phpunit/phpunit-story": "*",
"sebastian/comparator": "~1.0", "sebastian/comparator": "~1.0",
"ext-curl": "*", "ext-curl": "*",
"ext-dom": "*" "ext-dom": "*"
......
...@@ -15,15 +15,15 @@ testsuitelist[7]='import_suite' ...@@ -15,15 +15,15 @@ testsuitelist[7]='import_suite'
# There for the user is asked what to do. Default is always ask what to do. # There for the user is asked what to do. Default is always ask what to do.
alwaysask=true alwaysask=true
# As default it is assumed that 'svn' the first localhost folder is. ie http://localhost/svn # As default it is assumed that 'LOVD3' is the first localhost folder. ie http://localhost/LOVD3
# When the first folder is different, it must be given as input. # When the first folder is different, it must be given as input.
FIRSTLOCALHOSTFOLDER='svn' PROJECTFOLDER='LOVD3'
for i in "$@" for i in "$@"
do do
case $i in case $i in
-l=*|--localhost=*) -p=*|--projectfolder=*)
FIRSTLOCALHOSTFOLDER="${i#*=}" PROJECTFOLDER="${i#*=}"
#The input is refering to the github project. #The input is refering to the github project.
#For local development: /LOVD3_development #For local development: /LOVD3_development
#For LUMC development : /LOVD3 #For LUMC development : /LOVD3
...@@ -35,7 +35,7 @@ do ...@@ -35,7 +35,7 @@ do
*) *)
echo Unknown input echo Unknown input
echo Usage: echo Usage:
column -t -s "/" <<<' -l=<folder> /|/ --localhost=<folder> / Give the first localhost folder when it is not "svn". This is used in the Travis CI test. column -t -s "/" <<<' -p=<folder> /|/ --projectfolder=<folder> / Give the first localhost folder when it is not "svn". This is used in the Travis CI test.
-c /|/ --continueall / If set, it will not ask for actions during convert, but always continues with convert. This might create corrupt phpunit test files.' -c /|/ --continueall / If set, it will not ask for actions during convert, but always continues with convert. This might create corrupt phpunit test files.'
echo "Specify no file when you want te test all testfiles in the phpunit_selenium folder." echo "Specify no file when you want te test all testfiles in the phpunit_selenium folder."
exit exit
...@@ -44,23 +44,14 @@ do ...@@ -44,23 +44,14 @@ do
done done
SCRIPT=$(readlink -f $0) SCRIPT=$(readlink -f $0)
SCRIPTPATH=$(dirname $SCRIPT) PROJECTPATH=`echo ${SCRIPT} | sed "s@$PROJECTFOLDER.*@$PROJECTFOLDER@"`
SELENIUMTESTTPATH=$(dirname $SCRIPTPATH)/selenium_tests LOCALHOSTDIR=`echo ${PROJECTPATH} | sed "s@.*$PROJECTFOLDER@http://localhost/$PROJECTFOLDER@" | sed "s@/test.*@@"`
PHPUNITTESTTPATH=$(dirname $SCRIPTPATH)/phpunit_selenium
TESTDATATPATH=$(dirname $SCRIPTPATH)/test_data_files/
#DOCROOT=$(grep -h DocumentRoot /etc/apache2/sites-enabled/*default* | head -n 1 | awk '{print $2}' | sed 's\//\\\//g');
#LOCALHOSTDIR=`echo $SCRIPTPATH | sed "s/.*${DOCROOT}//" | sed "s@/trunk.*@@"`
echo ${SCRIPTPATH}
LOCALHOSTDIR=`echo ${SCRIPTPATH} | sed "s@.*$FIRSTLOCALHOSTFOLDER@/$FIRSTLOCALHOSTFOLDER@" | sed "s@/test.*@@"`
TRUNKDIR=`echo ${SCRIPT} | sed "s@test.*@@"`
echo Localhost directory: ${LOCALHOSTDIR} echo Localhost directory: ${LOCALHOSTDIR}
echo ${TRUNKDIR}
# These are used to replace the locations in the setup script. # These are used to replace the locations in the setup script.
NEWSETBROWSERURL="http://localhost"${LOCALHOSTDIR} NEWSETBROWSERURL="http://localhost"
NEWSCREENSHOTPATH=${TRUNKDIR}"tests/test_results/error_screenshots" NEWSCREENSHOTPATH=${PROJECTPATH}"/tests/test_results/error_screenshots"
NEWSCHREENSHOTURL=${NEWSETBROWSERURL}"/tests/test_results/error_screenshots" NEWSCHREENSHOTURL=${LOCALHOSTDIR}"/tests/test_results/error_screenshots"
echo Default browser URL: ${NEWSETBROWSERURL} echo Default browser URL: ${NEWSETBROWSERURL}
echo Screenshot Path: ${NEWSCREENSHOTPATH} echo Screenshot Path: ${NEWSCREENSHOTPATH}
...@@ -77,7 +68,7 @@ totalmethod=0 ...@@ -77,7 +68,7 @@ totalmethod=0
numberoftests=0 numberoftests=0
totalnumberoftests=0 totalnumberoftests=0
cd ${SELENIUMTESTTPATH} cd ${PROJECTPATH}/tests/selenium_tests
# This is a temporary file used to merge all tests to one file. # This is a temporary file used to merge all tests to one file.
# This file is deleted at the end of a conversion. # This file is deleted at the end of a conversion.
...@@ -190,7 +181,7 @@ do ...@@ -190,7 +181,7 @@ do
totalnumberoftests=$((totalnumberoftests+numberoftests)) totalnumberoftests=$((totalnumberoftests+numberoftests))
for file in $files for file in $files
do do
# Test if source and target files exists. If not then the conversion is interupted. # Test if source and target files exists. If not then the conversion is interrupted.
if [ ! -f "../phpunit_selenium/${newfilename}.php" ]; then if [ ! -f "../phpunit_selenium/${newfilename}.php" ]; then
echo "ERROR (Line:" $LINENO"): target file '"../phpunit_selenium/${dir}.php"' does not exist." echo "ERROR (Line:" $LINENO"): target file '"../phpunit_selenium/${dir}.php"' does not exist."
echo "WARNING (Line:" $LINENO"): Conversion is interupted!" echo "WARNING (Line:" $LINENO"): Conversion is interupted!"
...@@ -258,15 +249,15 @@ echo -----------------------end--------------------------- ...@@ -258,15 +249,15 @@ echo -----------------------end---------------------------
# 4 When files are imported the location must be modified, depending on the installation. # 4 When files are imported the location must be modified, depending on the installation.
# 5 When files are imported the location must be modified, depending on the installation. # 5 When files are imported the location must be modified, depending on the installation.
echo --------------Fix Selenium export bugs--------------- echo --------------Fix Selenium export bugs---------------
for file in "${PHPUNITTESTTPATH}"/* for file in "${PROJECTPATH}/tests/phpunit_selenium"/*
do do
echo "Fix:" ${file} echo "Fix:" ${file}
data=`grep -A 2000 "<?php" ${file} | data=`grep -A 2000 "<?php" ${file} |
sed "s@this->open(\".*./src@this->open(\"$LOCALHOSTDIR/src@" | sed "s@this->open(\".*./src@this->open(\"$LOCALHOSTDIR/src@" |
sed "s@this->open(\".*./tests@this->open(\"$LOCALHOSTDIR/tests@" | sed "s@this->open(\".*./tests@this->open(\"$LOCALHOSTDIR/tests@" |
sed 's/0)$/0);/' | sed 's/0)$/0);/' |
sed "s@name=variant_file.*./tests/test_data_files/@name=variant_file\"\, \"$TESTDATATPATH@" | sed "s@name=variant_file.*./tests/test_data_files/@name=variant_file\"\, \"$PROJECTPATH/tests/test_data_files@" |
sed "s@name=import.*./tests/test_data_files/@name=import\"\, \"$TESTDATATPATH@"` sed "s@name=import.*./tests/test_data_files/@name=import\"\, \"$PROJECTPATH/tests/test_data_files@"`
echo "${data}">${file} echo "${data}">${file}
sleep 1 sleep 1
echo "done" echo "done"
......
...@@ -3,7 +3,8 @@ ...@@ -3,7 +3,8 @@
<phpunit backupGlobals="false" colors="true"> <phpunit backupGlobals="false" colors="true">
<testsuites> <testsuites>
<testsuite name="simpleTest"> <testsuite name="simpleTest">
<file>./trunk/tests/travis/tests/simpleTest.php</file> <file> /home/travis/build/dasscheman/LOVD3/tests/travis/tests/simpleTest.php</file>
<file> /home/travis/build/dasscheman/LOVD3/tests/travis/tests/simpleSecondTest.php</file>
</testsuite> </testsuite>
</testsuites> </testsuites>
</phpunit> </phpunit>
\ No newline at end of file
...@@ -3,6 +3,7 @@ serverFile=selenium-server-standalone-2.50.1.jar ...@@ -3,6 +3,7 @@ serverFile=selenium-server-standalone-2.50.1.jar
phpVersion=`php -v` phpVersion=`php -v`
echo "Installing dependencies"
composer install composer install
echo "check firefox version" echo "check firefox version"
......
...@@ -6,13 +6,13 @@ class second_tests extends PHPUnit_Extensions_SeleniumTestCase ...@@ -6,13 +6,13 @@ class second_tests extends PHPUnit_Extensions_SeleniumTestCase
protected function setUp() protected function setUp()
{ {
$this->setBrowser('*firefox'); $this->setBrowser('*firefox');
$this->setBrowserUrl('http://127.0.0.1/'); $this->setBrowserUrl('http://localhost/');
$this->shareSession(true); $this->shareSession(true);
} }
public function testLoadPageAgain() public function testLoadPageAgain()
{ {
$this->open('http://127.0.0.1/trunk/tests/travis/simpleTest.html'); $this->open('http://localhost/LOVD3/tests/travis/simpleTest.html');
$this->waitForPageToLoad ( "30000" ); $this->waitForPageToLoad ( "30000" );
$this->assertTitle('phpunit selenium test'); $this->assertTitle('phpunit selenium test');
} }
......
<?php <?php
//require_once 'PHPUnit/Extensions/SeleniumTestCase.php';
class admin_tests extends PHPUnit_Extensions_SeleniumTestCase class admin_tests extends PHPUnit_Extensions_SeleniumTestCase
{ {
protected function setUp() protected function setUp()
{ {
$this->setBrowser('*firefox'); $this->setBrowser('*firefox');
$this->setBrowserUrl('http://127.0.0.1/'); $this->setBrowserUrl('http://localhost/');
$this->shareSession(true); $this->shareSession(true);
} }
public function testLoadPage() public function testLoadPage()
{ {
$this->open('http://127.0.0.1/trunk/tests/travis/simpleTest.html'); $this->open('http://localhost/LOVD3/tests/travis/simpleTest.html');
$this->waitForPageToLoad ( "30000" ); $this->waitForPageToLoad ( "30000" );
$this->assertTitle('phpunit selenium test'); $this->assertTitle('phpunit selenium test');
} }
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment