assertNotFalse($repair); $this->assertLessThan(strpos($script,'up -d --no-build app'),$repair); $this->assertStringContainsString('run --rm --no-deps -T --entrypoint sh app', $script); } /** @dataProvider verificationStates */ public function test_initializer_reports_the_verified_state(int $verificationExit, int $expectedExit, string $message): void { $script = file_get_contents(dirname(__DIR__, 3) . '/deploy/local-init.sh'); $start = strpos($script, 'echo "本地网页可访问:'); $this->assertNotFalse($start); $process = new Process(['bash', '-c', 'set -eu; compose_file=fixture; credential_file=fixture; docker() { return ' . $verificationExit . '; }; ' . substr($script, $start), ]); $process->setTimeout(5); $process->run(); $this->assertSame($expectedExit, $process->getExitCode()); $this->assertStringContainsString($message, $process->getOutput() . $process->getErrorOutput()); if ($verificationExit !== 0) { $this->assertStringNotContainsString('团队共享系统数据库验证通过', $process->getOutput()); } } public static function verificationStates(): array { return [ 'bootstrap' => [13, 0, '团队数据接入尚未完成'], 'shared success' => [0, 0, '团队共享系统数据库验证通过'], 'config failure' => [10, 10, '未通过验证'], 'network failure' => [11, 11, '未通过验证'], 'schema failure' => [12, 12, '未通过验证'], ]; } }