}
}
public function testIsGettingTree()
{
$repository = $this->client->getRepository($this->repoPath);
$files = $repository->getTree('master');
foreach ($files as $file) {
$this->assertInstanceOf('Git\Model\Blob', $file);
$this->assertRegExp('/test_file[0-9]*.txt/', $file->getName());
$this->assertEquals($file->getSize(), '55');
$this->assertEquals($file->getMode(), '100644');
$this->assertRegExp('/[a-f0-9]+/', $file->getHash());
}
}
public function testIsGettingTreeOutput()
{
$repository = $this->client->getRepository($this->repoPath);
$files = $repository->getTree('master')->output();
foreach ($files as $file) {
$this->assertEquals('blob', $file['type']);
$this->assertRegExp('/test_file[0-9]*.txt/', $file['name']);
$this->assertEquals($file['size'], '55');
$this->assertEquals($file['mode'], '100644');
$this->assertRegExp('/[a-f0-9]+/', $file['hash']);
}
}
public function testIsGettingTreesWithinTree()
{
$repository = $this->client->getRepository($this->repoPath);
// Creating folders
mkdir($this->repoPath . '/MyFolder');
mkdir($this->repoPath . '/MyTest');
mkdir($this->repoPath . '/MyFolder/Tests');
// Populating created folders
file_put_contents($this->repoPath . '/MyFolder/crazy.php', 'Lorem ipsum dolor sit amet');
file_put_contents($this->repoPath . '/MyFolder/skywalker.php', 'Lorem ipsum dolor sit amet');
file_put_contents($this->repoPath . '/MyTest/fortytwo.php', 'Lorem ipsum dolor sit amet');
file_put_contents($this->repoPath . '/MyFolder/Tests/web.php', 'Lorem ipsum dolor sit amet');
file_put_contents($this->repoPath . '/MyFolder/Tests/cli.php', 'Lorem ipsum dolor sit amet');
// Adding and commiting
$repository->addAll();
$repository->commit("Creating folders for testIsGettingTreesWithinTrees");
// Checking tree
$files = $repository->getTree('master')->output();
$this->assertEquals('folder', $files[0]['type']);
$this->assertEquals('MyFolder', $files[0]['name']);
$this->assertEquals('', $files[0]['size']);
$this->assertEquals('040000', $files[0]['mode']);
$this->assertEquals('4143e982237f3bdf56b5350f862c334054aad69e', $files[0]['hash']);
$this->assertEquals('folder', $files[1]['type']);
$this->assertEquals('MyTest', $files[1]['name']);
$this->assertEquals('', $files[1]['size']);
$this->assertEquals('040000', $files[1]['mode']);
$this->assertEquals('632240595eabd59e4217d196d6c12efb81f9c011', $files[1]['hash']);
$this->assertEquals('blob', $files[2]['type']);
$this->assertEquals('test_file.txt', $files[2]['name']);
$this->assertEquals('55', $files[2]['size']);
$this->assertEquals('100644', $files[2]['mode']);
$this->assertEquals('a773bfc0fda6f878e3d17d78c667d18297c8831f', $files[2]['hash']);
}
public function testIsGettingBlobsWithinTrees()
{
$repository = $this->client->getRepository($this->repoPath);
$files = $repository->getTree('master:MyFolder/')->output();
$this->assertEquals('folder', $files[0]['type']);
$this->assertEquals('Tests', $files[0]['name']);
$this->assertEquals('', $files[0]['size']);
$this->assertEquals('040000', $files[0]['mode']);
$this->assertEquals('8542f67d011ff2ea5ec49a729ba81a52935676d1', $files[0]['hash']);
$this->assertEquals('blob', $files[1]['type']);
$this->assertEquals('crazy.php', $files[1]['name']);
$this->assertEquals('26', $files[1]['size']);
$this->assertEquals('100644', $files[1]['mode']);
$this->assertEquals('d781006b2d05cc31751954a0fb920c990e825aad', $files[1]['hash']);
$this->assertEquals('blob', $files[2]['type']);
$this->assertEquals('skywalker.php', $files[2]['name']);
$this->assertEquals('26', $files[2]['size']);
$this->assertEquals('100644', $files[2]['mode']);
$this->assertEquals('d781006b2d05cc31751954a0fb920c990e825aad', $files[2]['hash']);
}
public function testIsGettingBlobOutput()
{
$repository = $this->client->getRepository($this->repoPath);
$blob = $repository->getBlob('master:MyFolder/crazy.php')->output();
$this->assertEquals('Lorem ipsum dolor sit amet', $blob);
$blob = $repository->getBlob('master:test_file4.txt')->output();
$this->assertEquals('Your mother is so ugly, glCullFace always returns TRUE.', $blob);
}
public function testIsGettingStatistics()
{
$repository = $this->client->getRepository($this->repoPath);
$stats = $repository->getStatistics('master');