Restore compatibility with PHP < 5.3.6
[gitphp.git] / test / git / GitObjectTest.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
<?php
/**
 * Base git object test class
 *
 * @author Christopher Han <xiphux@gmail.com>
 * @copyright Copyright (c) 2012 Christopher Han
 * @package GitPHP
 * @subpackage Test\Git
 */
class GitPHP_GitObjectTest extends PHPUnit_Framework_TestCase
{
        public function testHash()
        {
                $object = $this->getMockForAbstractClass('GitPHP_GitObject', array($this->getMockBuilder('GitPHP_Project')->disableOriginalConstructor()->getMock(), '1234567890abcdef1234567890ABCDEF12345678'));
                $this->assertEquals('1234567890abcdef1234567890ABCDEF12345678', $object->GetHash());
        }
 
        public function testInvalidHash()
        {
                $this->setExpectedException('GitPHP_InvalidHashException');
 
                $object = $this->getMockForAbstractClass('GitPHP_GitObject', array($this->getMockBuilder('GitPHP_Project')->disableOriginalConstructor()->getMock(), 'invalidhash'));
        }
 
        public function testAbbreviateHash()
        {
                $projectmock = $this->getMockBuilder('GitPHP_Project')->disableOriginalConstructor()->getMock();
                $projectmock->expects($this->once())->method('AbbreviateHash')->with($this->equalTo('1234567890abcdef1234567890ABCDEF12345678'))->will($this->returnValue('12345678'));
 
                $object = $this->getMockForAbstractClass('GitPHP_GitObject', array($projectmock, '1234567890abcdef1234567890ABCDEF12345678'));
 
                $this->assertEquals('12345678', $object->GetHash(true));
                $this->assertEquals('12345678', $object->GetHash(true));        //cached
        }
}
 
comments