This repository has been archived by the owner on Oct 1, 2021. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 40
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Move test repo to system tmp dir, introduce phpGitRepoCommand
- Loading branch information
Showing
5 changed files
with
62 additions
and
13 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,2 +1 @@ | ||
nbproject | ||
test/repo/.git |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
<?php | ||
|
||
class phpGitRepoCommand | ||
{ | ||
protected $dir; | ||
|
||
protected $command; | ||
|
||
public function __construct($dir, $command) | ||
{ | ||
$this->dir = $dir; | ||
$this->command = $command; | ||
} | ||
|
||
public function run() | ||
{ | ||
|
||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,18 +1,8 @@ | ||
<?php | ||
|
||
require_once dirname(__FILE__).'/vendor/lime.php'; | ||
require_once dirname(__FILE__).'/../lib/phpGitRepo.php'; | ||
require_once dirname(__FILE__).'/phpGitRepoTestHelper.php'; | ||
|
||
$t = new lime_test(); | ||
|
||
$nonExistingDir = '/non/existing/directory'; | ||
$message = $nonExistingDir.' is not a valid git repository'; | ||
try | ||
{ | ||
new phpGitRepo($nonExistingDir); | ||
$t->fail($message); | ||
} | ||
catch(InvalidArgumentException $e) | ||
{ | ||
$t->pass($message); | ||
} | ||
$repo = _createTmpGitRepo($t); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,39 @@ | ||
<?php | ||
|
||
require_once dirname(__FILE__).'/../lib/phpGitRepo.php'; | ||
|
||
/** | ||
* | ||
* @param lime_test $t | ||
* @return phpGitRepo the git repo | ||
*/ | ||
function _createTmpGitRepo(lime_test $t) | ||
{ | ||
$repoDir = sys_get_temp_dir().'/php-git-repo/'.uniqid(); | ||
$t->ok(!is_dir($repoDir.'/.git'), $repoDir.' is not a Git repo'); | ||
|
||
try | ||
{ | ||
new phpGitRepo($repoDir); | ||
$t->fail($repoDir.' is not a valid git repository'); | ||
} | ||
catch(InvalidArgumentException $e) | ||
{ | ||
$t->pass($repoDir.' is not a valid git repository'); | ||
} | ||
|
||
$t->comment('Create Git repo'); | ||
exec('git init '. escapeshellarg($repoDir.'/.git')); | ||
$t->ok(is_dir($repoDir.'/.git'), $repoDir.' is a Git repo'); | ||
|
||
$repo = new phpGitRepo($repoDir); | ||
$t->pass($repoDir.' is a valid git repo'); | ||
|
||
$originalRepoDir = dirname(__FILE__).'/repo'; | ||
foreach(array('README.markdown', 'index.php') as $file) | ||
{ | ||
copy($originalRepoDir.'/'.$file, $repoDir.'/'.$file); | ||
} | ||
|
||
return $repo; | ||
} |