99
1010class GitReferenceTest extends \PHPUnit_Framework_TestCase
1111{
12+ public static $ reference_name = "" ;
13+
14+ public static function setUpBeforeClass ()
15+ {
16+ self ::$ reference_name = trim (preg_replace ("/^ref: / " ,"" ,file_get_contents (dirname (__DIR__ ) . "/.git/HEAD " )));
17+ }
18+
1219 protected function setUp ()
1320 {
1421 //this test still legacy. fix environment probrem soon
15- $ this ->markTestSkipped ();
22+ // $this->markTestSkipped();
1623 }
1724
1825 protected function tearDown ()
@@ -26,7 +33,7 @@ protected function tearDown()
2633 public function testGitRefrenceCanResolve ()
2734 {
2835 $ rep = new Git \Repository (dirname (__DIR__ ) . "/.git/ " );
29- $ reference = $ rep ->lookupRef (" refs/heads/develop " );
36+ $ reference = $ rep ->lookupRef (self :: $ reference_name );
3037 $ this ->assertInstanceof ("Git \\Reference " ,$ reference ,"returned object does not Git \\Reference " );
3138 }
3239
@@ -37,7 +44,7 @@ public function testGitRefrenceCanResolve()
3744 public function testGitReferenceCanUseGetType ()
3845 {
3946 $ rep = new Git \Repository (dirname (__DIR__ ) . "/.git/ " );
40- $ ref = $ rep ->lookupRef (" refs/heads/develop " );
47+ $ ref = $ rep ->lookupRef (self :: $ reference_name );
4148 $ type = $ ref ->getType ();
4249 $ this ->assertEquals (1 ,$ type ,"illegal reference type returned.(this is legacy test. check test file) " );
4350 }
@@ -48,10 +55,10 @@ public function testGitReferenceCanUseGetType()
4855 public function testGitReferenceGetName ()
4956 {
5057 $ rep = new Git \Repository (dirname (__DIR__ ) . "/.git/ " );
51- $ ref = $ rep ->lookupRef (" refs/heads/develop " );
58+ $ ref = $ rep ->lookupRef (self :: $ reference_name );
5259 $ name = $ ref ->getName ();
5360
54- $ this ->assertEquals (" refs/heads/develop " ,$ name ,"reference name missmatched. " );
61+ $ this ->assertEquals (self :: $ reference_name ,$ name ,"reference name missmatched. " );
5562 }
5663
5764 /**
@@ -60,7 +67,7 @@ public function testGitReferenceGetName()
6067 public function testGitReferenceGetId ()
6168 {
6269 $ rep = new Git \Repository (dirname (__DIR__ ) . "/.git/ " );
63- $ ref = $ rep ->lookupRef (" refs/heads/develop " );
70+ $ ref = $ rep ->lookupRef (self :: $ reference_name );
6471 $ id = $ ref ->getId ();
6572
6673 $ this ->assertEquals (40 ,strlen ($ id ),"illegal oid size returned " );
@@ -73,7 +80,7 @@ public function testGitReferenceGetId()
7380 public function testGitReferenceGetTarget ()
7481 {
7582 $ rep = new Git \Repository (dirname (__DIR__ ) . "/.git/ " );
76- $ ref = $ rep ->lookupRef (" refs/heads/develop " );
83+ $ ref = $ rep ->lookupRef (self :: $ reference_name );
7784 try {
7885 $ target = $ ref ->getTarget ();
7986 $ this ->fail ("something wrong. this method allowed symbolic reference only. " );
0 commit comments