public function testPropEdit() { $parser = new UnifiedDiffParser(new UnifiedDiffTokenizer(new SvnDiffNormalizer())); $data = file(__DIR__ . '/data/diff_propedit', FILE_IGNORE_NEW_LINES); $diff = $parser->parse($data); $this->assertInstanceOf('ptlis\\DiffParser\\Changeset', $diff); $this->assertEquals(0, count($diff->getFiles())); }
public function testFifthFile() { $parser = new UnifiedDiffParser(new UnifiedDiffTokenizer(new SvnDiffNormalizer())); $data = file(__DIR__ . '/data/diff', FILE_IGNORE_NEW_LINES); $diff = $parser->parse($data); $fileList = $diff->getFiles(); $this->assertEquals(2, count($fileList[4]->getHunks())); $file = new File('tests/Vcs/Git/ChangeBranchTest.php', 'tests/Vcs/Git/ChangeBranchTest.php', File::CHANGED, array(new Hunk(48, 6, 48, 7, array(new Line(48, 48, Line::UNCHANGED, ' $commandExecutor->getArguments()'), new Line(49, 49, Line::UNCHANGED, ' );'), new Line(50, 50, Line::UNCHANGED, ' }'), new Line(-1, 51, Line::ADDED, ''), new Line(51, 52, Line::UNCHANGED, ' public function testBranchDoesntExist()'), new Line(52, 53, Line::UNCHANGED, ' {'), new Line(53, 54, Line::UNCHANGED, ' $this->setExpectedException('))), new Hunk(68, 7, 69, 5, array(new Line(68, 69, Line::UNCHANGED, ' $vcs = new GitVcs($commandExecutor);'), new Line(69, 70, Line::UNCHANGED, ''), new Line(70, 71, Line::UNCHANGED, ' $vcs->changeBranch(\'feat-new-badness\');'), new Line(71, -1, Line::REMOVED, ''), new Line(72, -1, Line::REMOVED, ''), new Line(73, 72, Line::UNCHANGED, ' }'), new Line(74, 73, Line::UNCHANGED, '}'))))); $this->assertEquals($file, $fileList[4]); }
public function testFileRemove() { $parser = new UnifiedDiffParser(new UnifiedDiffTokenizer(new SvnDiffNormalizer())); $data = file(__DIR__ . '/data/diff_remove', FILE_IGNORE_NEW_LINES); $diff = $parser->parse($data); $fileList = $diff->getFiles(); $this->assertEquals(1, count($fileList[0]->getHunks())); $file = new File('README.md', '', File::DELETED, array(new Hunk(0, 1, 0, 0, array(new Line(0, -1, Line::REMOVED, '## Test'))))); $this->assertEquals($file, $fileList[0]); }
public function testFileAdd() { $parser = new UnifiedDiffParser(new UnifiedDiffTokenizer(new GitDiffNormalizer())); $data = file(__DIR__ . '/data/diff_add', FILE_IGNORE_NEW_LINES); $diff = $parser->parse($data); $fileList = $diff->getFiles(); $this->assertEquals(1, count($fileList[0]->getHunks())); $file = new File('', 'README.md', File::CREATED, array(new Hunk(0, 0, 0, 1, array(new Line(-1, 0, Line::ADDED, '## Test'))))); $this->assertEquals($file, $fileList[0]); }