Permalink
Browse files

Add |./start.sh -tests| option

  • Loading branch information...
TheoChevalier committed Jan 14, 2016
1 parent ebf5aa9 commit 6d5834fb7214dee9917ccd34ad96694700b6872e
Showing with 74 additions and 55 deletions.
  1. +2 −2 README.md
  2. +44 −9 start.sh
  3. +2 −22 tests/functional/api.php
  4. +24 −0 tests/functional/includes/init.php
  5. +2 −22 tests/functional/pages.php
View
@@ -71,9 +71,9 @@ Then switch to a new branch where you will work on the patch you want to propose
```bash
git checkout -b my_new_branch
```
- Launch unit tests:
- Launch PHP-cs-fixer, unit and functional tests:
```bash
php vendor/atoum/atoum/bin/atoum -d tests/units/
start.sh -tests
```
- Update dependencies with composer:
```bash
View
@@ -3,23 +3,58 @@
# Use 'start.sh -remote' if you want to access the server from another machine (or a VM)
SERVER="localhost:8082"
SUPPORTED_COMMANDS=(
'-help'
'-remote'
'-tests'
'-tests-server'
)
if [ $# -gt 0 ]
then
if [ $1 = '-remote' ]
then
SERVER="0.0.0.0:8082"
elif [ $1 = '-help' ]
supported_command=false
for command in ${SUPPORTED_COMMANDS[@]};
do
if [ "${command}" == "$1" ];
then
supported_command=true
break
fi
done
if [ "${supported_command}" = false ];
then
echo "Usage: start.sh (PHP web server will be listening to localhost:8082)"
echo "Usage: start.sh -remote (PHP web server will be listening to 0.0.0.0:8082 and accessible from the outside)"
echo "Additional parameters will be ignored."
exit 1
else
echo "Unknown parameter \`${1}\`. Type \`start.sh -help\` to know what the valid parameters are."
exit 1
fi
fi
if [ $# -gt 0 ] && [ $1 = '-help' ]
then
echo "Usage: start.sh (PHP web server will be listening to localhost:8082)"
echo "Usage: start.sh -remote (PHP web server will be listening to 0.0.0.0:8082 and accessible from the outside)"
echo "Usage: start.sh -tests (Run all the unit and functional tests and check PHP syntax with PHP-cs-fixer)"
echo "Usage: start.sh -tests-server (Internal use — Run PHP web server listening to localhost:8083)"
echo "Additional parameters will be ignored."
exit 1
fi
./app/scripts/dev-setup.sh
case "$1" in
-remote)
SERVER="0.0.0.0:8082"
;;
-tests)
php ./vendor/atoum/atoum/bin/atoum -d tests/units/
php ./tests/functional/api.php
php ./tests/functional/pages.php
vendor/bin/php-cs-fixer --diff --dry-run -v fix
exit 1
;;
-tests-server)
SERVER="localhost:8083"
;;
esac
echo -e $(tput setaf 2; tput bold)"Launching PHP development server (php -S ${SERVER} -t web/ app/inc/router.php)"$(tput sgr0)
php -S ${SERVER} -t web/ app/inc/router.php
View
@@ -1,26 +1,6 @@
<?php
define('INSTALL_ROOT', realpath(__DIR__ . '/../../') . '/');
// We always work with UTF8 encoding
mb_internal_encoding('UTF-8');
// Make sure we have a timezone set
date_default_timezone_set('Europe/Paris');
require __DIR__ . '/../../vendor/autoload.php';
// Set an environment variable so that the instance will use content from test files
putenv("AUTOMATED_TESTS=true");
// Launch PHP dev server in the background
chdir(INSTALL_ROOT);
exec('./start.sh -remote > /dev/null 2>&1 & echo $!', $output);
// We will need the pid to kill it, beware, this is the pid of the bash process started with start.sh
$pid = $output[0];
// Pause to let time for the dev server to launch in the background
sleep(3);
include 'includes/init.php';
$paths = [
['', 400, '{"error":"No service requested"}'],
@@ -44,7 +24,7 @@
$obj = new \pchevrel\Verif('Check API HTTP responses');
$obj
->setHost('localhost:8082')
->setHost('localhost:8083')
->setPathPrefix('api/');
$check = function ($object, $paths) {
@@ -0,0 +1,24 @@
<?php
define('INSTALL_ROOT', realpath(__DIR__ . '/../../../') . '/');
// We always work with UTF8 encoding
mb_internal_encoding('UTF-8');
// Make sure we have a timezone set
date_default_timezone_set('Europe/Paris');
require __DIR__ . '/../../../vendor/autoload.php';
// Set an environment variable so that the instance will use content from test files
putenv("AUTOMATED_TESTS=true");
// Launch PHP dev server in the background
chdir(INSTALL_ROOT);
exec('./start.sh -tests-server > /dev/null 2>&1 & echo $!', $output);
// We will need the pid to kill it, beware, this is the pid of the bash process started with start.sh
$pid = $output[0];
// Pause to let time for the dev server to launch in the background
sleep(3);
View
@@ -1,26 +1,6 @@
<?php
define('INSTALL_ROOT', realpath(__DIR__ . '/../../') . '/');
// We always work with UTF8 encoding
mb_internal_encoding('UTF-8');
// Make sure we have a timezone set
date_default_timezone_set('Europe/Paris');
require __DIR__ . '/../../vendor/autoload.php';
// Set an environment variable so that the instance will use content from test files
putenv("AUTOMATED_TESTS=true");
// Launch PHP dev server in the background
chdir(INSTALL_ROOT);
exec('./start.sh -remote > /dev/null 2>&1 & echo $!', $output);
// We will need the pid to kill it, beware, this is the pid of the bash process started with start.sh
$pid = $output[0];
// Pause to let time for the dev server to launch in the background
sleep(3);
include 'includes/init.php';
$paths = [
['channelcomparizon/', 200, 'Compare strings from channel to channel', 'Key'],
@@ -39,7 +19,7 @@
$obj = new \pchevrel\Verif('Check public pages HTTP responses and content');
$obj
->setHost('localhost:8082')
->setHost('localhost:8083')
->setPathPrefix('');
$check = function ($object, $paths) {

0 comments on commit 6d5834f

Please sign in to comment.