Merge pull request #11 from bessl/patch-2
[gitphp.git] / test / git / blob / BlobLoad_GitTest.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
<?php
/**
 * Git blob load test class
 *
 * @author Christopher Han <xiphux@gmail.com>
 * @copyright Copyright (c) 2012 Christopher Han
 * @package GitPHP
 * @subpackage Git\Test\Blob
 */
class GitPHP_BlobLoad_GitTest extends PHPUnit_Framework_TestCase
{
        public function testLoad()
        {
                $projectmock = $this->getMockBuilder('GitPHP_Project')->disableOriginalConstructor()->getMock();
                $projectmock->expects($this->any())->method('GetPath')->will($this->returnValue(GITPHP_TEST_PROJECTROOT . '/testrepo.git'));
                $exemock = $this->getMock('GitPHP_GitExe');
                $exemock->expects($this->once())->method('Execute')->with($this->equalTo(GITPHP_TEST_PROJECTROOT . '/testrepo.git'), $this->equalTo('cat-file'))->will($this->returnValue("blob line 1\nblob line 2"));
 
                $blobmock = $this->getMockBuilder('GitPHP_Blob')->disableOriginalConstructor()->getMock();
                $blobmock->expects($this->any())->method('GetProject')->will($this->returnValue($projectmock));
                $blobmock->expects($this->any())->method('GetHash')->will($this->returnValue('1234567890abcdef1234567890ABCDEF12345678'));
 
                $strategy = new GitPHP_BlobLoad_Git($exemock);
                $this->assertEquals("blob line 1\nblob line 2", $strategy->Load($blobmock));
        }
}
 
comments