|
| 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