/** * Loads the plugins required by the test. */ public function loadPlugins() { if (empty($this->config['plugins']) || !defined('WP_PLUGIN_DIR')) { return; } $pluginsPath = PathUtils::untrailslashit(WP_PLUGIN_DIR) . DIRECTORY_SEPARATOR; $plugins = $this->config['plugins']; foreach ($plugins as $plugin) { $path = $pluginsPath . $plugin; if (!file_exists($path)) { throw new ModuleConfigException("The '{$plugin}' plugin file was not found in the {$pluginsPath} directory; this might be due to a wrong configuration of the `wpRootFolder` setting or a missing inclusion of one ore more additional config files using the `config_file` setting."); continue; } require_once $path; } }
private function getBootstrapFileContents($vendor, $testsPath) { $template = <<<PHP <?php // include Composer autoload files require_once dirname(__FILE__) . '/{{{autoloadFile}}}'; require_once dirname(__FILE__) . '/{{{wpBrowserAutoloadFile}}}'; // load WPLoader and let it do the heavy lifting of starting WordPress and requiring the plugins \$configFile = dirname(__FILE__) . '/{{{codeceptionYml}}}'; \$config = Symfony\\Component\\Yaml\\Yaml::parse(\$configFile); \$moduleContainer = new Codeception\\Lib\\ModuleContainer(new Codeception\\Lib\\Di(), \$config); \$loader = new Codeception\\Module\\WPLoader(\$moduleContainer, \$config['modules']['config']['WPLoader']); \$loader->_initialize(); PHP; $args = []; $backHops = substr_count(PathUtils::untrailslashit(PathUtils::unleadslashit($testsPath)), '/'); $relativeBackHopsPath = implode('/', array_map(function ($n) { return '..'; }, range(0, $backHops))); $args['autoloadFile'] = sprintf("%s/%s/autoload.php", $relativeBackHopsPath, PathUtils::unleadslashit(PathUtils::untrailslashit($vendor))); $args['wpBrowserAutoloadFile'] = sprintf("%s/%s/lucatume/wp-browser/autoload.php", $relativeBackHopsPath, PathUtils::unleadslashit(PathUtils::untrailslashit($vendor))); $args['codeceptionYml'] = sprintf("%s/codeception.yml", $relativeBackHopsPath); return $this->compileTemplate($args, $template); }