public static function from($repoDir) { // ask Git for the details $result = ExecInGitRepo::run($repoDir, ['git', 'branch', '--no-color']); // tidy up the returned text $branches = explode(PHP_EOL, $result->getOutput(), -1); $branches = ReplaceMatchingRegex::in($branches, '/^\\* /', ''); $branches = TrimWhitespace::from($branches); // all done return $branches; }
/** * @covers ::run */ public function testCanCallStatically() { // ---------------------------------------------------------------- // setup your test $repoDir = realpath(__DIR__ . '/../..'); // ---------------------------------------------------------------- // perform the change $result = ExecInGitRepo::run($repoDir, ['git', 'status']); // ---------------------------------------------------------------- // test the results $this->assertTrue($result instanceof ProcessResult); $this->assertEquals(0, $result->getReturnCode()); $this->assertNotEmpty($result->getOutput()); }