diff options
author | diosmosis <benaka@piwik.pro> | 2015-10-29 14:48:22 +0300 |
---|---|---|
committer | diosmosis <benaka@piwik.pro> | 2015-10-29 14:48:22 +0300 |
commit | f1dcc9bae62566c0df71bc7e447a9af8b092492f (patch) | |
tree | 3bd642634585fed27fcc0eea9cb1b73590d9cc08 /config | |
parent | cd9f9da2c76807d4e1748db08a0aebdedfab0cf7 (diff) |
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.
Diffstat (limited to 'config')
-rw-r--r-- | config/environment/ui-test.php | 25 |
1 files changed, 19 insertions, 6 deletions
diff --git a/config/environment/ui-test.php b/config/environment/ui-test.php index eaccd94bee..e7d82534bb 100644 --- a/config/environment/ui-test.php +++ b/config/environment/ui-test.php @@ -1,7 +1,15 @@ <?php +use Piwik\Container\StaticContainer; + 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) { $config->General['cors_domains'][] = '*'; $config->trusted_hosts[] = $config->tests['http_host']; @@ -11,21 +19,26 @@ return 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) { $request = $_GET + $_POST; - // Overlay needs the full URLs in order to find the links in the embedded page (otherwise the % - // tooltips don't show up) + $apiWhitelist = StaticContainer::get('tests.ui.url_normalizer_whitelist.api'); if (!empty($request['method']) - && $request['method'] == 'Overlay.getFollowingPages' + && in_array($request['method'], $apiWhitelist) ) { return; } - if (!empty($request['module']) && $request['module'] == 'Overlay' - && !empty($request['action']) && $request['action'] == 'renderSidebar' + $controllerActionWhitelist = StaticContainer::get('tests.ui.url_normalizer_whitelist.controller'); + if (!empty($request['module']) + && !empty($request['action']) ) { - return; + $controllerAction = $request['module'] . '.' . $request['action']; + if (in_array($controllerAction, $controllerActionWhitelist)) { + return; + } } $config = \Piwik\Config::getInstance(); |