/** * @return string * @throws ModuleConfigException */ protected function getPluginsFolder() { if (empty($this->pluginsFolder)) { $path = empty($this->config['pluginsFolder']) ? WP_PLUGIN_DIR : realpath($this->getWpRootFolder() . Utils::unleadslashit($this->config['pluginsFolder'])); if (!file_exists($path)) { throw new ModuleConfigException(__CLASS__, "The path to the plugins folder ('{$path}') doesn't exist."); } $this->pluginsFolder = Utils::untrailslashit($path); } return $this->pluginsFolder; }
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(Utils::untrailslashit(Utils::unleadslashit($testsPath)), '/'); $relativeBackHopsPath = implode('/', array_map(function () { return '..'; }, range(0, $backHops))); $args['autoloadFile'] = sprintf("%s/%s/autoload.php", $relativeBackHopsPath, Utils::unleadslashit(Utils::untrailslashit($vendor))); $args['wpBrowserAutoloadFile'] = sprintf("%s/%s/lucatume/wp-browser/autoload.php", $relativeBackHopsPath, Utils::unleadslashit(Utils::untrailslashit($vendor))); $args['codeceptionYml'] = sprintf("%s/codeception.yml", $relativeBackHopsPath); return $this->compileTemplate($args, $template); }