/** * Test commit diff * * @depends testCommitVariables * @param Commit $commit */ public function testCommitDiff(Commit $commit) { $diffs = $commit->getDiff(); $this->assertNotEmpty($diffs); $this->assertContainsOnlyInstancesOf(Diff::className(), $diffs); foreach ($diffs as $diff) { /* @var $diff Diff */ $this->assertInternalType('string', $diff->getDescription()); $this->assertInternalType('string', $diff->getNewFilePath()); $this->assertNotEmpty($diff->getNewFilePath()); $this->assertNotEmpty($diff->getPreviousFilePath()); $this->assertContainsOnly('array', $diff->getLines()); foreach ($diff->getLines() as $diffKey => $lines) { $this->assertInternalType('string', $diffKey); $this->assertRegExp('#^@@[\\s]\\-([\\d]+),?([\\d]+)?[\\s]\\+([\\d]+),?([\\d]+)?[\\s]@@#i', $diffKey); $this->assertArrayHasKey('beginA', $lines); $this->assertArrayHasKey('beginB', $lines); $this->assertArrayHasKey('cntA', $lines); $this->assertArrayHasKey('cntB', $lines); $this->assertInternalType('integer', $lines['beginA']); $this->assertInternalType('integer', $lines['beginB']); $this->assertInternalType('integer', $lines['cntA']); $this->assertInternalType('integer', $lines['cntB']); $this->assertArrayHasKey('lines', $lines); $this->assertInternalType('array', $lines['lines']); $this->assertNotEmpty($lines['lines']); $this->assertContainsOnly('string', $lines['lines']); foreach ($lines['lines'] as $line) { if (!empty($line)) { $this->assertRegExp('#^([\\s]|\\+|\\-|\\\\){1}#i', $line); } } } } return $commit; }
/** * Tests graph history */ public function testGraphHistory() { $graph = $this->repository->getGraphHistory(10, 1); $this->assertInstanceOf(Graph::className(), $graph); $this->assertContainsOnlyInstancesOf(Commit::className(), $graph->getCommits()); $this->assertEquals(10, count($graph->getCommits())); $this->assertGreaterThanOrEqual(0, $graph->getLevels()); $this->assertLessThan(9, $graph->getLevels()); foreach ($graph->getCommits() as $commit) { /* @var $commit Commit */ $this->assertInstanceOf(Commit::className(), $commit); $this->assertGreaterThanOrEqual(0, $commit->graphLevel); $this->assertLessThanOrEqual($graph->getLevels(), $commit->graphLevel); } }