From d945fab217f6ad5c929b809143131acdb3c6d437 Mon Sep 17 00:00:00 2001 From: dkinzer Date: Wed, 19 Jul 2017 15:22:28 -0400 Subject: [PATCH] Add BeforeSuite file shiv. REF CIVIC-6610 When stage file proxy is enabled we need to make sure some required files are present in public:// By adding a BeforeSuite step that copies these files from a site to the local environment, we fix errors that arise from files not being present in the testing environment. --- .../DKANExtension/Context/RawDKANContext.php | 37 +++++++++++++++++++ 1 file changed, 37 insertions(+) diff --git a/test/dkanextension/src/Drupal/DKANExtension/Context/RawDKANContext.php b/test/dkanextension/src/Drupal/DKANExtension/Context/RawDKANContext.php index 1d1d30faf5..b6255a7846 100644 --- a/test/dkanextension/src/Drupal/DKANExtension/Context/RawDKANContext.php +++ b/test/dkanextension/src/Drupal/DKANExtension/Context/RawDKANContext.php @@ -67,6 +67,43 @@ public static function disableAdminMenuCache(BeforeSuiteScope $scope) { variable_set('admin_menu_cache_client', FALSE); } + /** + * @BeforeSuite + */ + public static function moveStageFileProxyFiles(BeforeSuiteScope $scope) { + // Only need to run this once. + if (variable_get('stage_file_proxy_setup', FALSE)) { + return; + } + + global $conf; + if (!isset($conf['default']['stage_file_proxy_origin']) || $conf['default']['stage_file_proxy_origin'] == 'changeme') { + return; + } + + // Fix missing font files. + $font_files = array('eot', 'svg', 'ttf', 'woff'); + + // Add the file usage. + foreach ($font_files as $ext) { + $filename = 'dkan-topics'; + $theme_path = drupal_get_path('theme', 'nuboot_radix'); + $source = $theme_path . '/assets/fonts/' . $filename . '.' . $ext; + $destination = 'public://' . $filename . '.' . $ext; + copy($source, $destination); + } + + if (isset($conf['default']['stage_file_proxy_files'])) { + $proxy_files = (array) $conf['default']['stage_file_proxy_files']; + foreach ($proxy_files as $file) { + $source = $conf['default']['stage_file_proxy_origin'] . '/' . $file; + $destination = 'public://' . $file; + $copy($source, $destination); + } + } + variable_set('stage_file_proxy_setup', TRUE); + } + /** * @AfterSuite */