/** * @covers nochso\Omni\VcsVersionInfo::extractTag * @covers nochso\Omni\VcsVersionInfo::readMercurial */ public function testMercurial() { if (!OS::hasBinary('hg') || getenv('TRAVIS')) { $this->markTestSkipped('hg (Mercurial) has to be available for this test.'); } $repoDir = Path::combine(self::$base, 'hg'); Folder::ensure($repoDir); // Set up a new repo with a single committed file Exec::create('hg')->run('init', $repoDir); // From now on prefix all 'hg' commands with repo and cwd path $hg = Exec::create('hg', '--repository', $repoDir, '--cwd', $repoDir); $fooPath = Path::combine($repoDir, 'foo.txt'); touch($fooPath); $hg->run('add', $fooPath); $hg->run('commit', '-m init', '-u', 'Unit tester'); $vcs = new VcsVersionInfo('name', null, $repoDir); $this->assertRegExp('/^[0-9a-f]+$/', $vcs->getVersion(), 'Version without a tag must be rev hash'); file_put_contents($fooPath, 'throw dirt at tree'); $vcs = new VcsVersionInfo('name', null, $repoDir); $this->assertRegExp('/^[0-9a-f]+-dirty$/', $vcs->getVersion(), 'Dirty version without a tag must end in -dirty'); $hg->run('tag', '-u', 'Unit tester', '1.0.0'); $hg->run('update', '1.0.0'); $vcs = new VcsVersionInfo('name', null, $repoDir); $this->assertSame('1.0.0-dirty', $vcs->getVersion(), 'Dirty version with a tag must end in -dirty'); $hg->run('update', '--clean', '1.0.0'); $vcs = new VcsVersionInfo('name', null, $repoDir); $this->assertSame('1.0.0', $vcs->getVersion(), 'Clean version at specific tag'); file_put_contents($fooPath, 'move on to next commit'); $hg->run('commit', '-m move-on', '-u', 'Unit tester'); $vcs = new VcsVersionInfo('name', null, $repoDir); $this->assertRegExp('/^1\\.0\\.0-1-m[0-9a-f]+$/', $vcs->getVersion(), 'Commit after latest tag'); file_put_contents($fooPath, 'throw more dirt at tree'); $vcs = new VcsVersionInfo('name', null, $repoDir); $this->assertRegExp('/^1\\.0\\.0-1-m[0-9a-f]+-dirty$/', $vcs->getVersion(), 'Commit after latest tag'); Folder::delete($repoDir); }
public function testDelete_FailToDeleteRootFolder_MustThrow() { $root = vfsStream::setup('root', 0444); $folder = vfsStream::newDirectory('test', 0444)->at($root); $this->expectException('RuntimeException'); Folder::delete($folder->url()); }