diff options
author | Andrew Manning <tamanning@zoho.com> | 2016-05-01 22:29:51 -0400 |
---|---|---|
committer | Andrew Manning <tamanning@zoho.com> | 2016-05-01 22:29:51 -0400 |
commit | c2d15e6c3bd8a29bae89d184a999ddac15fcb807 (patch) | |
tree | 96cbbfa98f131d830fbfd154f82e37383bb37bd8 /library/kzykhys/git/test/PHPGit/Command/StashCommandTest.php | |
parent | b1ae4d776c7c093c7f3ff6905e1a5302fbd5e3f6 (diff) | |
download | volse-hubzilla-c2d15e6c3bd8a29bae89d184a999ddac15fcb807.tar.gz volse-hubzilla-c2d15e6c3bd8a29bae89d184a999ddac15fcb807.tar.bz2 volse-hubzilla-c2d15e6c3bd8a29bae89d184a999ddac15fcb807.zip |
New plugin repo is cloned to /store/pluginrepos/REPONAME for analysis
Diffstat (limited to 'library/kzykhys/git/test/PHPGit/Command/StashCommandTest.php')
-rw-r--r-- | library/kzykhys/git/test/PHPGit/Command/StashCommandTest.php | 204 |
1 files changed, 204 insertions, 0 deletions
diff --git a/library/kzykhys/git/test/PHPGit/Command/StashCommandTest.php b/library/kzykhys/git/test/PHPGit/Command/StashCommandTest.php new file mode 100644 index 000000000..bb87e48ea --- /dev/null +++ b/library/kzykhys/git/test/PHPGit/Command/StashCommandTest.php @@ -0,0 +1,204 @@ +<?php + +use PHPGit\Git; +use Symfony\Component\Filesystem\Filesystem; + +require_once __DIR__ . '/../BaseTestCase.php'; + +class StashCommandTest extends BaseTestCase +{ + + public function testStash() + { + $filesystem = new Filesystem(); + + $git = new Git(); + $git->init($this->directory); + $git->setRepository($this->directory); + $filesystem->dumpFile($this->directory . '/README.md', 'hello'); + $git->add('.'); + $git->commit('Initial commit'); + + $filesystem->dumpFile($this->directory . '/README.md', 'hi!'); + $git->stash(); + + $this->assertEquals('hello', file_get_contents($this->directory.'/README.md')); + } + + public function testStashSave() + { + $filesystem = new Filesystem(); + + $git = new Git(); + $git->init($this->directory); + $git->setRepository($this->directory); + $filesystem->dumpFile($this->directory . '/README.md', 'hello'); + $git->add('.'); + $git->commit('Initial commit'); + + $filesystem->dumpFile($this->directory . '/README.md', 'hi!'); + $git->stash->save('stash test'); + + $this->assertEquals('hello', file_get_contents($this->directory.'/README.md')); + } + + public function testStashList() + { + $filesystem = new Filesystem(); + + $git = new Git(); + $git->init($this->directory); + $git->setRepository($this->directory); + $filesystem->dumpFile($this->directory . '/README.md', 'hello'); + $git->add('.'); + $git->commit('Initial commit'); + + $filesystem->dumpFile($this->directory . '/README.md', 'hi!'); + $git->stash(); + + $stashes = $git->stash->lists(); + + $this->assertCount(1, $stashes); + $this->assertEquals('master', $stashes[0]['branch']); + $this->assertStringEndsWith('Initial commit', $stashes[0]['message']); + } + + public function testStashShow() + { + $filesystem = new Filesystem(); + + $git = new Git(); + $git->init($this->directory); + $git->setRepository($this->directory); + $filesystem->dumpFile($this->directory . '/README.md', 'hello'); + $git->add('.'); + $git->commit('Initial commit'); + + $filesystem->dumpFile($this->directory . '/README.md', 'hi!'); + $git->stash(); + $git->stash->show('stash@{0}'); + } + + public function testStashDrop() + { + $filesystem = new Filesystem(); + + $git = new Git(); + $git->init($this->directory); + $git->setRepository($this->directory); + $filesystem->dumpFile($this->directory . '/README.md', 'hello'); + $git->add('.'); + $git->commit('Initial commit'); + + $filesystem->dumpFile($this->directory . '/README.md', 'hi!'); + $git->stash(); + $git->stash->drop(); + + $filesystem->dumpFile($this->directory . '/README.md', 'hi!'); + $git->stash(); + $git->stash->drop('stash@{0}'); + + $this->assertCount(0, $git->stash->lists()); + } + + public function testStashPop() + { + $filesystem = new Filesystem(); + + $git = new Git(); + $git->init($this->directory); + $git->setRepository($this->directory); + $filesystem->dumpFile($this->directory . '/README.md', 'hello'); + $git->add('.'); + $git->commit('Initial commit'); + + $filesystem->dumpFile($this->directory . '/README.md', 'hi!'); + $git->stash->save('stash#1'); + + $filesystem->dumpFile($this->directory . '/README.md', 'bar'); + $git->stash->save('stash#2'); + $git->stash->pop('stash@{1}'); + + $this->assertEquals('hi!', file_get_contents($this->directory.'/README.md')); + $this->assertCount(1, $git->stash->lists()); + } + + public function testStashApply() + { + $filesystem = new Filesystem(); + + $git = new Git(); + $git->init($this->directory); + $git->setRepository($this->directory); + $filesystem->dumpFile($this->directory . '/README.md', 'hello'); + $git->add('.'); + $git->commit('Initial commit'); + + $filesystem->dumpFile($this->directory . '/README.md', 'hi!'); + $git->stash->save('stash#1'); + + $filesystem->dumpFile($this->directory . '/README.md', 'bar'); + $git->stash->save('stash#2'); + $git->stash->apply('stash@{1}'); + + $this->assertEquals('hi!', file_get_contents($this->directory.'/README.md')); + $this->assertCount(2, $git->stash->lists()); + } + + public function testStashBranch() + { + $filesystem = new Filesystem(); + + $git = new Git(); + $git->init($this->directory); + $git->setRepository($this->directory); + $filesystem->dumpFile($this->directory . '/README.md', 'hello'); + $git->add('.'); + $git->commit('Initial commit'); + + $filesystem->dumpFile($this->directory . '/README.md', 'hi!'); + $git->stash(); + + $git->stash->branch('dev', 'stash@{0}'); + $status = $git->status(); + + $this->assertEquals('dev', $status['branch']); + $this->assertEquals('hi!', file_get_contents($this->directory.'/README.md')); + } + + public function testStashClear() + { + $filesystem = new Filesystem(); + + $git = new Git(); + $git->init($this->directory); + $git->setRepository($this->directory); + $filesystem->dumpFile($this->directory . '/README.md', 'hello'); + $git->add('.'); + $git->commit('Initial commit'); + + $filesystem->dumpFile($this->directory . '/README.md', 'hi!'); + $git->stash(); + $git->stash->clear(); + + $this->assertCount(0, $git->stash->lists()); + } + + public function testStashCreate() + { + $filesystem = new Filesystem(); + + $git = new Git(); + $git->init($this->directory); + $git->setRepository($this->directory); + $filesystem->dumpFile($this->directory . '/README.md', 'hello'); + $git->add('.'); + $git->commit('Initial commit'); + + $filesystem->dumpFile($this->directory . '/README.md', 'hi!'); + $object = $git->stash->create(); + + $this->assertNotEmpty($object); + } + +}
\ No newline at end of file |