/** * @return string */ protected function getWpRootFolder() { if (empty($this->wpRootFolder)) { // allow me not to bother with traling slashes $wpRootFolder = rtrim($this->config['wpRootFolder'], '/') . '/'; // maybe the user is using the `~` symbol for home? $this->wpRootFolder = PathUtils::homeify($wpRootFolder); } return $this->wpRootFolder; }
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); }