Skip to content
Extraits de code Groupes Projets
Valider f1dcc9ba rédigé par diosmosis's avatar diosmosis
Parcourir les fichiers

Instead of hardcoding whitelisting of Overlay methods in UI test URL...

Instead of hardcoding whitelisting of Overlay methods in UI test URL normalizing, use DI to store whitelist and override in ui-test.php DI config for Overlay.
parent cd9f9da2
Aucune branche associée trouvée
Aucune étiquette associée trouvée
Aucune requête de fusion associée trouvée
<?php <?php
use Piwik\Container\StaticContainer;
return array( return array(
// UI tests will remove the port from all URLs to the test server. if a test
// requires the ports in UI tests (eg, Overlay), add the api/controller methods
// to one of these whitelists
'tests.ui.url_normalizer_whitelist.api' => array(),
'tests.ui.url_normalizer_whitelist.controller' => array(),
'Piwik\Config' => \DI\decorate(function (\Piwik\Config $config) { 'Piwik\Config' => \DI\decorate(function (\Piwik\Config $config) {
$config->General['cors_domains'][] = '*'; $config->General['cors_domains'][] = '*';
$config->trusted_hosts[] = $config->tests['http_host']; $config->trusted_hosts[] = $config->tests['http_host'];
...@@ -11,21 +19,26 @@ return array( ...@@ -11,21 +19,26 @@ return array(
'observers.global' => \DI\add(array( 'observers.global' => \DI\add(array(
// removes port from all URLs to the test Piwik server so UI tests will pass no matter
// what port is used
array('Request.dispatch.end', function (&$result) { array('Request.dispatch.end', function (&$result) {
$request = $_GET + $_POST; $request = $_GET + $_POST;
// Overlay needs the full URLs in order to find the links in the embedded page (otherwise the % $apiWhitelist = StaticContainer::get('tests.ui.url_normalizer_whitelist.api');
// tooltips don't show up)
if (!empty($request['method']) if (!empty($request['method'])
&& $request['method'] == 'Overlay.getFollowingPages' && in_array($request['method'], $apiWhitelist)
) { ) {
return; return;
} }
if (!empty($request['module']) && $request['module'] == 'Overlay' $controllerActionWhitelist = StaticContainer::get('tests.ui.url_normalizer_whitelist.controller');
&& !empty($request['action']) && $request['action'] == 'renderSidebar' if (!empty($request['module'])
&& !empty($request['action'])
) { ) {
return; $controllerAction = $request['module'] . '.' . $request['action'];
if (in_array($controllerAction, $controllerActionWhitelist)) {
return;
}
} }
$config = \Piwik\Config::getInstance(); $config = \Piwik\Config::getInstance();
......
<?php
return array(
// Overlay needs the full URLs in order to find the links in the embedded page (otherwise the %
// tooltips don't show up)
'tests.ui.url_normalizer_whitelist.api' => DI\add(array(
'Overlay.getFollowingPages',
)),
'tests.ui.url_normalizer_whitelist.controller' => DI\add(array(
'Overlay.renderSidebar',
)),
);
\ No newline at end of file
0% Chargement en cours ou .
You are about to add 0 people to the discussion. Proceed with caution.
Terminez d'abord l'édition de ce message.
Veuillez vous inscrire ou vous pour commenter