Commit b1a0df54 authored by Asscheman's avatar Asscheman

Updated the selenium tests

parent 2bc8bff6
......@@ -21,7 +21,7 @@ before_script:
- ./tests/travis/setup/setup_apache.sh --githubaccount=LUMC
## IMPORTANT! convert must be run AFTER the setup_apache.sh
## 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
script:
......@@ -37,9 +37,15 @@ script:
# - vendor/bin/phpunit ./tests/phpunit_selenium/managerTest.php
# - vendor/bin/phpunit ./tests/phpunit_selenium/submitterTest.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
- vendor/bin/phpunit ./tests/phpunit_selenium/
- vendor/bin/phpunit -v ./tests/phpunit_selenium/
notifications:
email:
......
......@@ -15,15 +15,15 @@ testsuitelist[7]='import_suite'
# There for the user is asked what to do. Default is always ask what to do.
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.
FIRSTLOCALHOSTFOLDER='svn'
PROJECTFOLDER='LOVD3'
for i in "$@"
do
case $i in
-l=*|--localhost=*)
FIRSTLOCALHOSTFOLDER="${i#*=}"
-p=*|--projectfolder=*)
PROJECTFOLDER="${i#*=}"
#The input is refering to the github project.
#For local development: /LOVD3_development
#For LUMC development : /LOVD3
......@@ -35,7 +35,7 @@ do
*)
echo Unknown input
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.'
echo "Specify no file when you want te test all testfiles in the phpunit_selenium folder."
exit
......@@ -44,23 +44,14 @@ do
done
SCRIPT=$(readlink -f $0)
SCRIPTPATH=$(dirname $SCRIPT)
SELENIUMTESTTPATH=$(dirname $SCRIPTPATH)/selenium_tests
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.*@@"`
PROJECTPATH=`echo ${SCRIPT} | sed "s@$PROJECTFOLDER.*@$PROJECTFOLDER@"`
LOCALHOSTDIR=`echo ${PROJECTPATH} | sed "s@.*$PROJECTFOLDER@http://localhost/$PROJECTFOLDER@" | sed "s@/test.*@@"`
echo Localhost directory: ${LOCALHOSTDIR}
echo ${TRUNKDIR}
# These are used to replace the locations in the setup script.
NEWSETBROWSERURL="http://localhost"${LOCALHOSTDIR}
NEWSCREENSHOTPATH=${TRUNKDIR}"tests/test_results/error_screenshots"
NEWSCHREENSHOTURL=${NEWSETBROWSERURL}"/tests/test_results/error_screenshots"
NEWSETBROWSERURL="http://localhost"
NEWSCREENSHOTPATH=${PROJECTPATH}"/tests/test_results/error_screenshots"
NEWSCHREENSHOTURL=${LOCALHOSTDIR}"/tests/test_results/error_screenshots"
echo Default browser URL: ${NEWSETBROWSERURL}
echo Screenshot Path: ${NEWSCREENSHOTPATH}
......@@ -77,7 +68,7 @@ totalmethod=0
numberoftests=0
totalnumberoftests=0
cd ${SELENIUMTESTTPATH}
cd ${PROJECTPATH}/tests/selenium_tests
# This is a temporary file used to merge all tests to one file.
# This file is deleted at the end of a conversion.
......@@ -190,7 +181,7 @@ do
totalnumberoftests=$((totalnumberoftests+numberoftests))
for file in $files
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
echo "ERROR (Line:" $LINENO"): target file '"../phpunit_selenium/${dir}.php"' does not exist."
echo "WARNING (Line:" $LINENO"): Conversion is interupted!"
......@@ -258,15 +249,15 @@ echo -----------------------end---------------------------
# 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.
echo --------------Fix Selenium export bugs---------------
for file in "${PHPUNITTESTTPATH}"/*
for file in "${PROJECTPATH}/tests/phpunit_selenium"/*
do
echo "Fix:" ${file}
data=`grep -A 2000 "<?php" ${file} |
sed "s@this->open(\".*./src@this->open(\"$LOCALHOSTDIR/src@" |
sed "s@this->open(\".*./tests@this->open(\"$LOCALHOSTDIR/tests@" |
sed 's/0)$/0);/' |
sed "s@name=variant_file.*./tests/test_data_files/@name=variant_file\"\, \"$TESTDATATPATH@" |
sed "s@name=import.*./tests/test_data_files/@name=import\"\, \"$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\"\, \"$PROJECTPATH/tests/test_data_files@"`
echo "${data}">${file}
sleep 1
echo "done"
......
......@@ -3,7 +3,8 @@
<phpunit backupGlobals="false" colors="true">
<testsuites>
<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>
</testsuites>
</phpunit>
\ No newline at end of file
......@@ -3,6 +3,7 @@ serverFile=selenium-server-standalone-2.50.1.jar
phpVersion=`php -v`
echo "Installing dependencies"
composer install
echo "check firefox version"
......
......@@ -6,13 +6,13 @@ class second_tests extends PHPUnit_Extensions_SeleniumTestCase
protected function setUp()
{
$this->setBrowser('*firefox');
$this->setBrowserUrl('http://127.0.0.1/');
$this->setBrowserUrl('http://localhost/');
$this->shareSession(true);
}
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->assertTitle('phpunit selenium test');
}
......
<?php
//require_once 'PHPUnit/Extensions/SeleniumTestCase.php';
class admin_tests extends PHPUnit_Extensions_SeleniumTestCase
{
protected function setUp()
{
$this->setBrowser('*firefox');
$this->setBrowserUrl('http://127.0.0.1/');
$this->setBrowserUrl('http://localhost/');
$this->shareSession(true);
}
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->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