assertStringContainsString("'sudo chown -R xc_vm:xc_vm ' . MAIN_HOME);", $this->between($rInstall, 'private function finalizeHostAfterRuntime(', "\n\t}\n")); // What a proxy install does after it, up to the proxy's startup. $rAfter = $this->between($rInstall, '$this->finalizeHostAfterRuntime(', 'ProxyInstallFlow::runStartup('); $this->assertStringContainsString($rRootOwn, $rAfter); $this->assertStringNotContainsString('chown -R', $rAfter); // The same ownership and mode the key is installed with. $this->assertStringContainsString($rRootOwn, (string) file_get_contents(MAIN_HOME . 'Cli/Commands/ProxyInstallFlow.php')); } /** The text of $rSource from $rFrom up to the next $rTo. */ private function between(string $rSource, string $rFrom, string $rTo): string { $rStart = strpos($rSource, $rFrom); $this->assertNotFalse($rStart, $rFrom); $rEnd = strpos($rSource, $rTo, $rStart); $this->assertNotFalse($rEnd, $rTo); return substr($rSource, $rStart, $rEnd - $rStart); } }