File tree 5 files changed +62
-13
lines changed
5 files changed +62
-13
lines changed Original file line number Diff line number Diff line change 1
1
nbproject
2
- test /repo /.git
Original file line number Diff line number Diff line change 12
12
* Tickets: http://github.com/ornicar/php-git-repo/issues
13
13
*/
14
14
15
+ require_once (dirname (__FILE__ ).'/phpGitRepoCommand.php ' );
16
+
15
17
class phpGitRepo
16
18
{
17
19
/**
Original file line number Diff line number Diff line change
1
+ <?php
2
+
3
+ class phpGitRepoCommand
4
+ {
5
+ protected $ dir ;
6
+
7
+ protected $ command ;
8
+
9
+ public function __construct ($ dir , $ command )
10
+ {
11
+ $ this ->dir = $ dir ;
12
+ $ this ->command = $ command ;
13
+ }
14
+
15
+ public function run ()
16
+ {
17
+
18
+ }
19
+ }
Original file line number Diff line number Diff line change 1
1
<?php
2
2
3
3
require_once dirname (__FILE__ ).'/vendor/lime.php ' ;
4
- require_once dirname (__FILE__ ).'/../lib/phpGitRepo .php ' ;
4
+ require_once dirname (__FILE__ ).'/phpGitRepoTestHelper .php ' ;
5
5
6
6
$ t = new lime_test ();
7
7
8
- $ nonExistingDir = '/non/existing/directory ' ;
9
- $ message = $ nonExistingDir .' is not a valid git repository ' ;
10
- try
11
- {
12
- new phpGitRepo ($ nonExistingDir );
13
- $ t ->fail ($ message );
14
- }
15
- catch (InvalidArgumentException $ e )
16
- {
17
- $ t ->pass ($ message );
18
- }
8
+ $ repo = _createTmpGitRepo ($ t );
Original file line number Diff line number Diff line change
1
+ <?php
2
+
3
+ require_once dirname (__FILE__ ).'/../lib/phpGitRepo.php ' ;
4
+
5
+ /**
6
+ *
7
+ * @param lime_test $t
8
+ * @return phpGitRepo the git repo
9
+ */
10
+ function _createTmpGitRepo (lime_test $ t )
11
+ {
12
+ $ repoDir = sys_get_temp_dir ().'/php-git-repo/ ' .uniqid ();
13
+ $ t ->ok (!is_dir ($ repoDir .'/.git ' ), $ repoDir .' is not a Git repo ' );
14
+
15
+ try
16
+ {
17
+ new phpGitRepo ($ repoDir );
18
+ $ t ->fail ($ repoDir .' is not a valid git repository ' );
19
+ }
20
+ catch (InvalidArgumentException $ e )
21
+ {
22
+ $ t ->pass ($ repoDir .' is not a valid git repository ' );
23
+ }
24
+
25
+ $ t ->comment ('Create Git repo ' );
26
+ exec ('git init ' . escapeshellarg ($ repoDir .'/.git ' ));
27
+ $ t ->ok (is_dir ($ repoDir .'/.git ' ), $ repoDir .' is a Git repo ' );
28
+
29
+ $ repo = new phpGitRepo ($ repoDir );
30
+ $ t ->pass ($ repoDir .' is a valid git repo ' );
31
+
32
+ $ originalRepoDir = dirname (__FILE__ ).'/repo ' ;
33
+ foreach (array ('README.markdown ' , 'index.php ' ) as $ file )
34
+ {
35
+ copy ($ originalRepoDir .'/ ' .$ file , $ repoDir .'/ ' .$ file );
36
+ }
37
+
38
+ return $ repo ;
39
+ }
You can’t perform that action at this time.
0 commit comments