assertFileNotExists(TESTS_REPO_PATH_1.'/file_0.txt'); $c = $this->getRepository(); $commit = $c->showCommit($c->getCurrentCommit()); $this->assertContains('--- a/file_0.txt', $commit); } /** * @expectedException PHPUnit_Framework_Error_Warning */ public function testUnlinkFileNonHead() { $path = sprintf('git://%s/file_0.txt#HEAD^', TESTS_REPO_PATH_1); unlink($path); } /** * @expectedException PHPUnit_Framework_Error_Warning */ public function testUnlinkNonExistantFile() { $path = sprintf('git://%s/file_does_not_exist.txt', TESTS_REPO_PATH_1); unlink($path); } /** * @expectedException PHPUnit_Framework_Error_Warning */ public function testUnlinkNonFile() { $c = $this->getRepository(); $c->writeFile('directory/test.txt', 'Test'); $path = sprintf('git://%s/directory', TESTS_REPO_PATH_1); unlink($path); } public function testUnlinkFileWithContext() { $path = sprintf('git://%s/file_0.txt', TESTS_REPO_PATH_1); $cntxt = stream_context_create(array( 'git' => array( 'commitMsg' => 'Hello World', 'author' => 'Luke Skywalker ' ) )); unlink($path, $cntxt); $c = $this->getRepository(); $commit = $c->showCommit($c->getCurrentCommit()); $this->assertContains('Hello World', $commit); $this->assertContains('Luke Skywalker ', $commit); } public function testRenameFile() { $pathFrom = sprintf('git://%s/file_0.txt', TESTS_REPO_PATH_1); $pathTo = sprintf('git://%s/test.txt', TESTS_REPO_PATH_1); rename($pathFrom, $pathTo); $this->assertFileNotExists(TESTS_REPO_PATH_1.'/file_0.txt'); $this->assertFileExists(TESTS_REPO_PATH_1.'/test.txt'); $c = $this->getRepository(); $commit = $c->showCommit($c->getCurrentCommit()); $this->assertContains('--- a/file_0.txt', $commit); $this->assertContains('+++ b/test.txt', $commit); } /** * @expectedException PHPUnit_Framework_Error_Warning */ public function testRenameFileNonHead() { $pathFrom = sprintf('git://%s/file_0.txt#HEAD^', TESTS_REPO_PATH_1); $pathTo = sprintf('git://%s/test.txt', TESTS_REPO_PATH_1); rename($pathFrom, $pathTo); } /** * @expectedException PHPUnit_Framework_Error_Warning */ public function testRenameNonExistantFile() { $pathFrom = sprintf('git://%s/file_does_not_exist.txt', TESTS_REPO_PATH_1); $pathTo = sprintf('git://%s/test.txt', TESTS_REPO_PATH_1); rename($pathFrom, $pathTo); } /** * @expectedException PHPUnit_Framework_Error_Warning */ public function testRenameNonFile() { $c = $this->getRepository(); $c->writeFile('directory/test.txt', 'Test'); $pathFrom = sprintf('git://%s/directory', TESTS_REPO_PATH_1); $pathTo = sprintf('git://%s/test.txt', TESTS_REPO_PATH_1); rename($pathFrom, $pathTo); } public function testRenameFileWithContext() { $pathFrom = sprintf('git://%s/file_0.txt', TESTS_REPO_PATH_1); $pathTo = sprintf('git://%s/test.txt', TESTS_REPO_PATH_1); $cntxt = stream_context_create(array( 'git' => array( 'commitMsg' => 'Hello World', 'author' => 'Luke Skywalker ' ) )); rename($pathFrom, $pathTo, $cntxt); $c = $this->getRepository(); $commit = $c->showCommit($c->getCurrentCommit()); $this->assertContains('Hello World', $commit); $this->assertContains('Luke Skywalker ', $commit); } public function testRmdirDirectory() { $c = $this->getRepository(); $c->writeFile('directory/test.txt', 'Test'); $this->assertFileExists(TESTS_REPO_PATH_1.'/directory'); $this->assertFileExists(TESTS_REPO_PATH_1.'/directory/test.txt'); $path = sprintf('git://%s/directory', TESTS_REPO_PATH_1); rmdir($path); $this->assertFileNotExists(TESTS_REPO_PATH_1.'/directory'); $c = $this->getRepository(); $commit = $c->showCommit($c->getCurrentCommit()); $this->assertContains('--- a/directory/test.txt', $commit); } /** * @expectedException PHPUnit_Framework_Error_Warning */ public function testRmdirDirectoryNonHead() { $c = $this->getRepository(); $c->writeFile('directory/test.txt', 'Test'); $path = sprintf('git://%s/directory#HEAD^', TESTS_REPO_PATH_1); rmdir($path); } /** * @expectedException PHPUnit_Framework_Error_Warning */ public function testRmdirNonExistantDirectory() { $path = sprintf('git://%s/directory_does_not_exist', TESTS_REPO_PATH_1); rmdir($path); } /** * @expectedException PHPUnit_Framework_Error_Warning */ public function testRmdirNonDirectory() { $path = sprintf('git://%s/file_0.txt', TESTS_REPO_PATH_1); rmdir($path); } public function testRmdirDirectoryWithContext() { $c = $this->getRepository(); $c->writeFile('directory/test.txt', 'Test'); $this->assertFileExists(TESTS_REPO_PATH_1.'/directory'); $this->assertFileExists(TESTS_REPO_PATH_1.'/directory/test.txt'); $path = sprintf('git://%s/directory', TESTS_REPO_PATH_1); $cntxt = stream_context_create(array( 'git' => array( 'commitMsg' => 'Hello World', 'author' => 'Luke Skywalker ' ) )); rmdir($path, $cntxt); $c = $this->getRepository(); $commit = $c->showCommit($c->getCurrentCommit()); $this->assertContains('Hello World', $commit); $this->assertContains('Luke Skywalker ', $commit); } public function testMkdirDirectory() { $path = sprintf('git://%s/directory', TESTS_REPO_PATH_1); mkdir($path); $this->assertFileExists(TESTS_REPO_PATH_1.'/directory'); $this->assertFileExists(TESTS_REPO_PATH_1.'/directory/.gitkeep'); $c = $this->getRepository(); $commit = $c->showCommit($c->getCurrentCommit()); $this->assertContains('b/directory/.gitkeep', $commit); } /** * @expectedException PHPUnit_Framework_Error_Warning */ public function testMkdirDirectoryNonHead() { $path = sprintf('git://%s/directory#HEAD^', TESTS_REPO_PATH_1); mkdir($path); } /** * @expectedException PHPUnit_Framework_Error_Warning */ public function testMkdirExistantDirectory() { $c = $this->getRepository(); $c->writeFile('directory/test.txt', 'Test'); $path = sprintf('git://%s/directory', TESTS_REPO_PATH_1); mkdir($path); } public function testMkdirDirectoryRecursively() { $path = sprintf('git://%s/directory/directory', TESTS_REPO_PATH_1); mkdir($path, 0777, true); $this->assertFileExists(TESTS_REPO_PATH_1.'/directory'); $this->assertFileExists(TESTS_REPO_PATH_1.'/directory/directory'); $this->assertFileExists(TESTS_REPO_PATH_1.'/directory/directory/.gitkeep'); $c = $this->getRepository(); $commit = $c->showCommit($c->getCurrentCommit()); $this->assertContains('b/directory/directory/.gitkeep', $commit); } /** * @expectedException PHPUnit_Framework_Error_Warning */ public function testMkdirDirectoryRecursivelyFailsIfNotRequested() { $path = sprintf('git://%s/directory/directory', TESTS_REPO_PATH_1); mkdir($path, 0777, false); } public function testMkdirDirectoryWithContext() { $path = sprintf('git://%s/directory', TESTS_REPO_PATH_1); $cntxt = stream_context_create(array( 'git' => array( 'commitMsg' => 'Hello World', 'author' => 'Luke Skywalker ' ) )); mkdir($path, 0777, false, $cntxt); $c = $this->getRepository(); $commit = $c->showCommit($c->getCurrentCommit()); $this->assertContains('Hello World', $commit); $this->assertContains('Luke Skywalker ', $commit); } }