Skip to content

Commit 4cc86d8

Browse files
author
Vincent Lequertier
committed
Add functional tests for public pages
1 parent 2831c6c commit 4cc86d8

File tree

3 files changed

+65
-1
lines changed

3 files changed

+65
-1
lines changed

.travis.yml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@ before_script:
1414
script:
1515
- vendor/atoum/atoum/bin/atoum -d tests/units/
1616
- php tests/functional/api.php
17+
- php tests/functional/pages.php
1718
- vendor/bin/php-cs-fixer --diff --dry-run -v fix
1819
notifications:
1920
irc:

composer.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -87,7 +87,7 @@
8787
"atoum/atoum" : "~2.0",
8888
"symfony/var-dumper": "~2.6",
8989
"fabpot/php-cs-fixer": "~1.4",
90-
"pchevrel/verif": "0.3",
90+
"pchevrel/verif": "0.4",
9191
"phpdocumentor/phpdocumentor": "2.*"
9292
},
9393

tests/functional/pages.php

Lines changed: 63 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,63 @@
1+
<?php
2+
define('INSTALL_ROOT', realpath(__DIR__ . '/../../') . '/');
3+
4+
// We always work with UTF8 encoding
5+
mb_internal_encoding('UTF-8');
6+
7+
// Make sure we have a timezone set
8+
date_default_timezone_set('Europe/Paris');
9+
10+
require __DIR__ . '/../../vendor/autoload.php';
11+
12+
// Set an environment variable so that the instance will use content from test files
13+
putenv("AUTOMATED_TESTS=true");
14+
15+
// Launch PHP dev server in the background
16+
chdir(INSTALL_ROOT);
17+
exec('./start.sh -remote > /dev/null 2>&1 & echo $!', $output);
18+
19+
// We will need the pid to kill it, beware, this is the pid of the bash process started with start.sh
20+
$pid = $output[0];
21+
22+
// Pause to let time for the dev server to launch in the background
23+
sleep(3);
24+
25+
$paths = [
26+
['channelcomparizon/', 200, 'Compare strings from channel to channel', 'Key'],
27+
['channelcomparison/', 200, 'Compare strings from channel to channel', 'Key'],
28+
['credits/', 200, 'Transvision 1.0 was created', 'Transvision is hosted on the MozFR server'],
29+
['downloads/', 200, 'Select which strings', 'Generate the TMX'],
30+
['gaia/', 200, 'Translation Status', 'How many strings are translated'],
31+
['news/', 200, 'Version 4.0', 'End user visible changes'],
32+
['productization/', 200, 'Show productization', 'firefox'],
33+
['showrepos/?locale=en-GB', 200, 'Health Status for en-GB', 'General metrics'],
34+
['stats/', 200, 'Repository status overview', 'Status estimate'],
35+
['string/?entity=browser/chrome/browser/places/places.properties:bookmarkResultLabel&repo=central', 200, 'supported_locales', 'Marque-page'],
36+
['unchanged/', 200, 'Display a list of strings identical', 'Locale'],
37+
['variables/', 200, 'Show potential errors related to', 'no errors found'],
38+
];
39+
40+
$obj = new \pchevrel\Verif('Check public pages HTTP responses and content');
41+
$obj
42+
->setHost('localhost:8082')
43+
->setPathPrefix('');
44+
45+
$check = function ($object, $paths) {
46+
foreach ($paths as $values) {
47+
list($path, $http_code, $content, $content2) = $values;
48+
$object
49+
->setPath($path)
50+
->fetchContent()
51+
->hasResponseCode($http_code)
52+
->contains($content)
53+
->contains($content2);
54+
}
55+
};
56+
57+
$check($obj, $paths);
58+
59+
$obj->report();
60+
61+
// Kill PHP dev server by killing all children processes of the bash process we opened in the background
62+
exec('pkill -P ' . $pid);
63+
die($obj->returnStatus());

0 commit comments

Comments
 (0)