Commit 1ff4d2ca authored by David Prévot's avatar David Prévot

New upstream version 3.0.2

parents a951bf34 720fcc7e
......@@ -2,4 +2,5 @@
/composer.lock
/vendor
/.php_cs.cache
/.phpunit.result.cache
/from.txt.orig
\ No newline at end of file
......@@ -3,6 +3,7 @@ language: php
php:
- 7.1
- 7.2
- 7.3
- master
sudo: false
......
......@@ -2,6 +2,12 @@
All notable changes are documented in this file using the [Keep a CHANGELOG](http://keepachangelog.com/) principles.
## [3.0.2] - 2019-02-04
### Changed
* `Chunk::setLines()` now ensures that the `$lines` array only contains `Line` objects
## [3.0.1] - 2018-06-10
### Fixed
......@@ -40,6 +46,7 @@ All notable changes are documented in this file using the [Keep a CHANGELOG](htt
* This component is no longer supported on PHP 5.6
[3.0.2]: https://github.com/sebastianbergmann/diff/compare/3.0.1...3.0.2
[3.0.1]: https://github.com/sebastianbergmann/diff/compare/3.0.0...3.0.1
[3.0.0]: https://github.com/sebastianbergmann/diff/compare/2.0...3.0.0
[2.0.1]: https://github.com/sebastianbergmann/diff/compare/c341c98ce083db77f896a0aa64f5ee7652915970...2.0.1
......
sebastian/diff
Copyright (c) 2002-2018, Sebastian Bergmann <sebastian@phpunit.de>.
Copyright (c) 2002-2019, Sebastian Bergmann <sebastian@phpunit.de>.
All rights reserved.
Redistribution and use in source and binary forms, with or without
......
......@@ -18,7 +18,7 @@
"php": "^7.1"
},
"require-dev": {
"phpunit/phpunit": "^7.0",
"phpunit/phpunit": "^7.5 || ^8.0",
"symfony/process": "^2 || ^3.3 || ^4"
},
"autoload": {
......
......@@ -33,7 +33,7 @@ final class Chunk
private $endRange;
/**
* @var array
* @var Line[]
*/
private $lines;
......@@ -66,13 +66,25 @@ final class Chunk
return $this->endRange;
}
/**
* @return Line[]
*/
public function getLines(): array
{
return $this->lines;
}
/**
* @param Line[] $lines
*/
public function setLines(array $lines): void
{
foreach ($lines as $line) {
if (!$line instanceof Line) {
throw new InvalidArgumentException;
}
}
$this->lines = $lines;
}
}
......@@ -27,6 +27,11 @@ final class ChunkTest extends TestCase
$this->chunk = new Chunk;
}
public function testHasInitiallyNoLines(): void
{
$this->assertSame([], $this->chunk->getLines());
}
public function testCanBeCreatedWithoutArguments(): void
{
$this->assertInstanceOf(Chunk::class, $this->chunk);
......@@ -59,10 +64,10 @@ final class ChunkTest extends TestCase
public function testLinesCanBeSet(): void
{
$this->assertSame([], $this->chunk->getLines());
$lines = [new Line(Line::ADDED, 'added'), new Line(Line::REMOVED, 'removed')];
$this->chunk->setLines($lines);
$testValue = ['line0', 'line1'];
$this->chunk->setLines($testValue);
$this->assertSame($testValue, $this->chunk->getLines());
$this->assertSame($lines, $this->chunk->getLines());
}
}
......@@ -426,24 +426,6 @@ EOF
];
}
public function testConstructorNull(): void
{
$this->assertAttributeInstanceOf(
UnifiedDiffOutputBuilder::class,
'outputBuilder',
new Differ(null)
);
}
public function testConstructorString(): void
{
$this->assertAttributeInstanceOf(
UnifiedDiffOutputBuilder::class,
'outputBuilder',
new Differ("--- Original\n+++ New\n")
);
}
public function testConstructorInvalidArgInt(): void
{
$this->expectException(InvalidArgumentException::class);
......
......@@ -190,7 +190,7 @@ abstract class LongestCommonSubsequenceTest extends TestCase
{
$diff = $this->implementation->calculate(['5'], ['05']);
$this->assertInternalType('array', $diff);
$this->assertIsArray($diff);
$this->assertCount(0, $diff);
}
......
......@@ -38,12 +38,10 @@ final class ParserTest extends TestCase
$diffs = $this->parser->parse($content);
$this->assertInternalType('array', $diffs);
$this->assertContainsOnlyInstancesOf(Diff::class, $diffs);
$this->assertCount(1, $diffs);
$chunks = $diffs[0]->getChunks();
$this->assertInternalType('array', $chunks);
$this->assertContainsOnlyInstancesOf(Chunk::class, $chunks);
$this->assertCount(1, $chunks);
......@@ -85,13 +83,11 @@ index abcdefg..abcdefh 100644
-B
END;
$diffs = $this->parser->parse($content);
$this->assertInternalType('array', $diffs);
$this->assertContainsOnlyInstancesOf(Diff::class, $diffs);
$this->assertCount(1, $diffs);
$chunks = $diffs[0]->getChunks();
$this->assertInternalType('array', $chunks);
$this->assertContainsOnlyInstancesOf(Chunk::class, $chunks);
$this->assertCount(1, $chunks);
......@@ -102,7 +98,6 @@ END;
$this->assertSame(8, $chunk->getEndRange());
$lines = $chunk->getLines();
$this->assertInternalType('array', $lines);
$this->assertContainsOnlyInstancesOf(Line::class, $lines);
$this->assertCount(2, $lines);
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment