Laravel version update
Laravel version update
This commit is contained in:
68
vendor/sebastian/diff/tests/ChunkTest.php
vendored
Normal file
68
vendor/sebastian/diff/tests/ChunkTest.php
vendored
Normal file
@@ -0,0 +1,68 @@
|
||||
<?php declare(strict_types=1);
|
||||
/*
|
||||
* This file is part of sebastian/diff.
|
||||
*
|
||||
* (c) Sebastian Bergmann <sebastian@phpunit.de>
|
||||
*
|
||||
* For the full copyright and license information, please view the LICENSE
|
||||
* file that was distributed with this source code.
|
||||
*/
|
||||
|
||||
namespace SebastianBergmann\Diff;
|
||||
|
||||
use PHPUnit\Framework\TestCase;
|
||||
|
||||
/**
|
||||
* @covers SebastianBergmann\Diff\Chunk
|
||||
*/
|
||||
final class ChunkTest extends TestCase
|
||||
{
|
||||
/**
|
||||
* @var Chunk
|
||||
*/
|
||||
private $chunk;
|
||||
|
||||
protected function setUp()
|
||||
{
|
||||
$this->chunk = new Chunk;
|
||||
}
|
||||
|
||||
public function testCanBeCreatedWithoutArguments()
|
||||
{
|
||||
$this->assertInstanceOf(Chunk::class, $this->chunk);
|
||||
}
|
||||
|
||||
public function testStartCanBeRetrieved()
|
||||
{
|
||||
$this->assertSame(0, $this->chunk->getStart());
|
||||
}
|
||||
|
||||
public function testStartRangeCanBeRetrieved()
|
||||
{
|
||||
$this->assertSame(1, $this->chunk->getStartRange());
|
||||
}
|
||||
|
||||
public function testEndCanBeRetrieved()
|
||||
{
|
||||
$this->assertSame(0, $this->chunk->getEnd());
|
||||
}
|
||||
|
||||
public function testEndRangeCanBeRetrieved()
|
||||
{
|
||||
$this->assertSame(1, $this->chunk->getEndRange());
|
||||
}
|
||||
|
||||
public function testLinesCanBeRetrieved()
|
||||
{
|
||||
$this->assertSame([], $this->chunk->getLines());
|
||||
}
|
||||
|
||||
public function testLinesCanBeSet()
|
||||
{
|
||||
$this->assertSame([], $this->chunk->getLines());
|
||||
|
||||
$testValue = ['line0', 'line1'];
|
||||
$this->chunk->setLines($testValue);
|
||||
$this->assertSame($testValue, $this->chunk->getLines());
|
||||
}
|
||||
}
|
||||
55
vendor/sebastian/diff/tests/DiffTest.php
vendored
Normal file
55
vendor/sebastian/diff/tests/DiffTest.php
vendored
Normal file
@@ -0,0 +1,55 @@
|
||||
<?php declare(strict_types=1);
|
||||
/*
|
||||
* This file is part of sebastian/diff.
|
||||
*
|
||||
* (c) Sebastian Bergmann <sebastian@phpunit.de>
|
||||
*
|
||||
* For the full copyright and license information, please view the LICENSE
|
||||
* file that was distributed with this source code.
|
||||
*/
|
||||
|
||||
namespace SebastianBergmann\Diff;
|
||||
|
||||
use PHPUnit\Framework\TestCase;
|
||||
|
||||
/**
|
||||
* @covers SebastianBergmann\Diff\Diff
|
||||
*
|
||||
* @uses SebastianBergmann\Diff\Chunk
|
||||
*/
|
||||
final class DiffTest extends TestCase
|
||||
{
|
||||
public function testGettersAfterConstructionWithDefault()
|
||||
{
|
||||
$from = 'line1a';
|
||||
$to = 'line2a';
|
||||
$diff = new Diff($from, $to);
|
||||
|
||||
$this->assertSame($from, $diff->getFrom());
|
||||
$this->assertSame($to, $diff->getTo());
|
||||
$this->assertSame([], $diff->getChunks(), 'Expect chunks to be default value "array()".');
|
||||
}
|
||||
|
||||
public function testGettersAfterConstructionWithChunks()
|
||||
{
|
||||
$from = 'line1b';
|
||||
$to = 'line2b';
|
||||
$chunks = [new Chunk(), new Chunk(2, 3)];
|
||||
|
||||
$diff = new Diff($from, $to, $chunks);
|
||||
|
||||
$this->assertSame($from, $diff->getFrom());
|
||||
$this->assertSame($to, $diff->getTo());
|
||||
$this->assertSame($chunks, $diff->getChunks(), 'Expect chunks to be passed value.');
|
||||
}
|
||||
|
||||
public function testSetChunksAfterConstruction()
|
||||
{
|
||||
$diff = new Diff('line1c', 'line2c');
|
||||
$this->assertSame([], $diff->getChunks(), 'Expect chunks to be default value "array()".');
|
||||
|
||||
$chunks = [new Chunk(), new Chunk(2, 3)];
|
||||
$diff->setChunks($chunks);
|
||||
$this->assertSame($chunks, $diff->getChunks(), 'Expect chunks to be passed value.');
|
||||
}
|
||||
}
|
||||
BIN
vendor/sebastian/diff/tests/DifferTest.php
vendored
BIN
vendor/sebastian/diff/tests/DifferTest.php
vendored
Binary file not shown.
83
vendor/sebastian/diff/tests/DifferTestTest.php
vendored
Normal file
83
vendor/sebastian/diff/tests/DifferTestTest.php
vendored
Normal file
@@ -0,0 +1,83 @@
|
||||
<?php declare(strict_types=1);
|
||||
/*
|
||||
* This file is part of sebastian/diff.
|
||||
*
|
||||
* (c) Sebastian Bergmann <sebastian@phpunit.de>
|
||||
*
|
||||
* For the full copyright and license information, please view the LICENSE
|
||||
* file that was distributed with this source code.
|
||||
*/
|
||||
|
||||
namespace SebastianBergmann\Diff;
|
||||
|
||||
use PHPUnit\Framework\TestCase;
|
||||
|
||||
/**
|
||||
* @requires OS Linux
|
||||
*/
|
||||
final class DifferTestTest extends TestCase
|
||||
{
|
||||
private $fileFrom;
|
||||
private $filePatch;
|
||||
|
||||
protected function setUp()
|
||||
{
|
||||
$dir = \realpath(__DIR__ . '/../') . '/';
|
||||
$this->fileFrom = $dir . 'from.txt';
|
||||
$this->filePatch = $dir . 'patch.txt';
|
||||
}
|
||||
|
||||
/**
|
||||
* @dataProvider provideDiffWithLineNumbers
|
||||
*/
|
||||
public function testTheTestProvideDiffWithLineNumbers($expected, $from, $to)
|
||||
{
|
||||
$this->runThisTest($expected, $from, $to);
|
||||
}
|
||||
|
||||
public function provideDiffWithLineNumbers()
|
||||
{
|
||||
require_once __DIR__ . '/DifferTest.php';
|
||||
$test = new DifferTest();
|
||||
$tests = $test->provideDiffWithLineNumbers();
|
||||
|
||||
$tests = \array_filter(
|
||||
$tests,
|
||||
function ($key) {
|
||||
return !\is_string($key) || false === \strpos($key, 'non_patch_compat');
|
||||
},
|
||||
ARRAY_FILTER_USE_KEY
|
||||
);
|
||||
|
||||
return $tests;
|
||||
}
|
||||
|
||||
private function runThisTest(string $expected, string $from, string $to)
|
||||
{
|
||||
$expected = \str_replace('--- Original', '--- from.txt', $expected);
|
||||
$expected = \str_replace('+++ New', '+++ from.txt', $expected);
|
||||
|
||||
@\unlink($this->fileFrom);
|
||||
@\unlink($this->filePatch);
|
||||
|
||||
$this->assertNotFalse(\file_put_contents($this->fileFrom, $from));
|
||||
$this->assertNotFalse(\file_put_contents($this->filePatch, $expected));
|
||||
|
||||
$command = \sprintf(
|
||||
'patch -u --verbose %s < %s', // --posix
|
||||
\escapeshellarg($this->fileFrom),
|
||||
\escapeshellarg($this->filePatch)
|
||||
);
|
||||
|
||||
\exec($command, $output, $d);
|
||||
|
||||
$this->assertSame(0, $d, \sprintf('%s | %s', $command, \implode("\n", $output)));
|
||||
|
||||
$patched = \file_get_contents($this->fileFrom);
|
||||
$this->assertSame($patched, $to);
|
||||
|
||||
@\unlink($this->fileFrom . '.orig');
|
||||
@\unlink($this->fileFrom);
|
||||
@\unlink($this->filePatch);
|
||||
}
|
||||
}
|
||||
@@ -1,175 +0,0 @@
|
||||
<?php
|
||||
/*
|
||||
* This file is part of the Diff package.
|
||||
*
|
||||
* (c) Sebastian Bergmann <sebastian@phpunit.de>
|
||||
*
|
||||
* For the full copyright and license information, please view the LICENSE
|
||||
* file that was distributed with this source code.
|
||||
*/
|
||||
|
||||
namespace SebastianBergmann\Diff\LCS;
|
||||
|
||||
use PHPUnit_Framework_TestCase;
|
||||
|
||||
/**
|
||||
* Some of these tests are volontary stressfull, in order to give some approximative benchmark hints.
|
||||
*/
|
||||
class TimeEfficientImplementationTest extends PHPUnit_Framework_TestCase
|
||||
{
|
||||
private $implementation;
|
||||
private $memory_limit;
|
||||
private $stress_sizes = array(1, 2, 3, 100, 500, 1000, 2000);
|
||||
|
||||
protected function setUp()
|
||||
{
|
||||
$this->memory_limit = ini_get('memory_limit');
|
||||
ini_set('memory_limit', '256M');
|
||||
|
||||
$this->implementation = new TimeEfficientImplementation;
|
||||
}
|
||||
|
||||
protected function tearDown()
|
||||
{
|
||||
ini_set('memory_limit', $this->memory_limit);
|
||||
}
|
||||
|
||||
public function testBothEmpty()
|
||||
{
|
||||
$from = array();
|
||||
$to = array();
|
||||
$common = $this->implementation->calculate($from, $to);
|
||||
|
||||
$this->assertEquals(array(), $common);
|
||||
}
|
||||
|
||||
public function testIsStrictComparison()
|
||||
{
|
||||
$from = array(
|
||||
false, 0, 0.0, '', null, array(),
|
||||
true, 1, 1.0, 'foo', array('foo', 'bar'), array('foo' => 'bar')
|
||||
);
|
||||
$to = $from;
|
||||
$common = $this->implementation->calculate($from, $to);
|
||||
|
||||
$this->assertEquals($from, $common);
|
||||
|
||||
$to = array(
|
||||
false, false, false, false, false, false,
|
||||
true, true, true, true, true, true
|
||||
);
|
||||
$expected = array(
|
||||
false,
|
||||
true,
|
||||
);
|
||||
$common = $this->implementation->calculate($from, $to);
|
||||
|
||||
$this->assertEquals($expected, $common);
|
||||
}
|
||||
|
||||
public function testEqualSequences()
|
||||
{
|
||||
foreach ($this->stress_sizes as $size) {
|
||||
$range = range(1, $size);
|
||||
$from = $range;
|
||||
$to = $range;
|
||||
$common = $this->implementation->calculate($from, $to);
|
||||
|
||||
$this->assertEquals($range, $common);
|
||||
}
|
||||
}
|
||||
|
||||
public function testDistinctSequences()
|
||||
{
|
||||
$from = array('A');
|
||||
$to = array('B');
|
||||
$common = $this->implementation->calculate($from, $to);
|
||||
$this->assertEquals(array(), $common);
|
||||
|
||||
$from = array('A', 'B', 'C');
|
||||
$to = array('D', 'E', 'F');
|
||||
$common = $this->implementation->calculate($from, $to);
|
||||
$this->assertEquals(array(), $common);
|
||||
|
||||
foreach ($this->stress_sizes as $size) {
|
||||
$from = range(1, $size);
|
||||
$to = range($size + 1, $size * 2);
|
||||
$common = $this->implementation->calculate($from, $to);
|
||||
$this->assertEquals(array(), $common);
|
||||
}
|
||||
}
|
||||
|
||||
public function testCommonSubsequence()
|
||||
{
|
||||
$from = array('A', 'C', 'E', 'F', 'G');
|
||||
$to = array('A', 'B', 'D', 'E', 'H');
|
||||
$expected = array('A', 'E');
|
||||
$common = $this->implementation->calculate($from, $to);
|
||||
$this->assertEquals($expected, $common);
|
||||
|
||||
$from = array('A', 'C', 'E', 'F', 'G');
|
||||
$to = array('B', 'C', 'D', 'E', 'F', 'H');
|
||||
$expected = array('C', 'E', 'F');
|
||||
$common = $this->implementation->calculate($from, $to);
|
||||
$this->assertEquals($expected, $common);
|
||||
|
||||
foreach ($this->stress_sizes as $size) {
|
||||
$from = $size < 2 ? array(1) : range(1, $size + 1, 2);
|
||||
$to = $size < 3 ? array(1) : range(1, $size + 1, 3);
|
||||
$expected = $size < 6 ? array(1) : range(1, $size + 1, 6);
|
||||
$common = $this->implementation->calculate($from, $to);
|
||||
|
||||
$this->assertEquals($expected, $common);
|
||||
}
|
||||
}
|
||||
|
||||
public function testSingleElementSubsequenceAtStart()
|
||||
{
|
||||
foreach ($this->stress_sizes as $size) {
|
||||
$from = range(1, $size);
|
||||
$to = array_slice($from, 0, 1);
|
||||
$common = $this->implementation->calculate($from, $to);
|
||||
|
||||
$this->assertEquals($to, $common);
|
||||
}
|
||||
}
|
||||
|
||||
public function testSingleElementSubsequenceAtMiddle()
|
||||
{
|
||||
foreach ($this->stress_sizes as $size) {
|
||||
$from = range(1, $size);
|
||||
$to = array_slice($from, (int) $size / 2, 1);
|
||||
$common = $this->implementation->calculate($from, $to);
|
||||
|
||||
$this->assertEquals($to, $common);
|
||||
}
|
||||
}
|
||||
|
||||
public function testSingleElementSubsequenceAtEnd()
|
||||
{
|
||||
foreach ($this->stress_sizes as $size) {
|
||||
$from = range(1, $size);
|
||||
$to = array_slice($from, $size - 1, 1);
|
||||
$common = $this->implementation->calculate($from, $to);
|
||||
|
||||
$this->assertEquals($to, $common);
|
||||
}
|
||||
}
|
||||
|
||||
public function testReversedSequences()
|
||||
{
|
||||
$from = array('A', 'B');
|
||||
$to = array('B', 'A');
|
||||
$expected = array('A');
|
||||
$common = $this->implementation->calculate($from, $to);
|
||||
$this->assertEquals($expected, $common);
|
||||
|
||||
foreach ($this->stress_sizes as $size) {
|
||||
$from = range(1, $size);
|
||||
$to = array_reverse($from);
|
||||
$common = $this->implementation->calculate($from, $to);
|
||||
|
||||
$this->assertEquals(array(1), $common);
|
||||
}
|
||||
}
|
||||
}
|
||||
44
vendor/sebastian/diff/tests/LineTest.php
vendored
Normal file
44
vendor/sebastian/diff/tests/LineTest.php
vendored
Normal file
@@ -0,0 +1,44 @@
|
||||
<?php declare(strict_types=1);
|
||||
/*
|
||||
* This file is part of sebastian/diff.
|
||||
*
|
||||
* (c) Sebastian Bergmann <sebastian@phpunit.de>
|
||||
*
|
||||
* For the full copyright and license information, please view the LICENSE
|
||||
* file that was distributed with this source code.
|
||||
*/
|
||||
|
||||
namespace SebastianBergmann\Diff;
|
||||
|
||||
use PHPUnit\Framework\TestCase;
|
||||
|
||||
/**
|
||||
* @covers SebastianBergmann\Diff\Line
|
||||
*/
|
||||
final class LineTest extends TestCase
|
||||
{
|
||||
/**
|
||||
* @var Line
|
||||
*/
|
||||
private $line;
|
||||
|
||||
protected function setUp()
|
||||
{
|
||||
$this->line = new Line;
|
||||
}
|
||||
|
||||
public function testCanBeCreatedWithoutArguments()
|
||||
{
|
||||
$this->assertInstanceOf(Line::class, $this->line);
|
||||
}
|
||||
|
||||
public function testTypeCanBeRetrieved()
|
||||
{
|
||||
$this->assertSame(Line::UNCHANGED, $this->line->getType());
|
||||
}
|
||||
|
||||
public function testContentCanBeRetrieved()
|
||||
{
|
||||
$this->assertSame('', $this->line->getContent());
|
||||
}
|
||||
}
|
||||
201
vendor/sebastian/diff/tests/LongestCommonSubsequenceTest.php
vendored
Normal file
201
vendor/sebastian/diff/tests/LongestCommonSubsequenceTest.php
vendored
Normal file
@@ -0,0 +1,201 @@
|
||||
<?php declare(strict_types=1);
|
||||
/*
|
||||
* This file is part of sebastian/diff.
|
||||
*
|
||||
* (c) Sebastian Bergmann <sebastian@phpunit.de>
|
||||
*
|
||||
* For the full copyright and license information, please view the LICENSE
|
||||
* file that was distributed with this source code.
|
||||
*/
|
||||
|
||||
namespace SebastianBergmann\Diff;
|
||||
|
||||
use PHPUnit\Framework\TestCase;
|
||||
|
||||
/**
|
||||
* @coversNothing
|
||||
*/
|
||||
abstract class LongestCommonSubsequenceTest extends TestCase
|
||||
{
|
||||
/**
|
||||
* @var LongestCommonSubsequenceCalculator
|
||||
*/
|
||||
private $implementation;
|
||||
|
||||
/**
|
||||
* @var string
|
||||
*/
|
||||
private $memoryLimit;
|
||||
|
||||
/**
|
||||
* @var int[]
|
||||
*/
|
||||
private $stress_sizes = [1, 2, 3, 100, 500, 1000, 2000];
|
||||
|
||||
protected function setUp()
|
||||
{
|
||||
$this->memoryLimit = \ini_get('memory_limit');
|
||||
\ini_set('memory_limit', '256M');
|
||||
|
||||
$this->implementation = $this->createImplementation();
|
||||
}
|
||||
|
||||
/**
|
||||
* @return LongestCommonSubsequenceCalculator
|
||||
*/
|
||||
abstract protected function createImplementation();
|
||||
|
||||
protected function tearDown()
|
||||
{
|
||||
\ini_set('memory_limit', $this->memoryLimit);
|
||||
}
|
||||
|
||||
public function testBothEmpty()
|
||||
{
|
||||
$from = [];
|
||||
$to = [];
|
||||
$common = $this->implementation->calculate($from, $to);
|
||||
|
||||
$this->assertSame([], $common);
|
||||
}
|
||||
|
||||
public function testIsStrictComparison()
|
||||
{
|
||||
$from = [
|
||||
false, 0, 0.0, '', null, [],
|
||||
true, 1, 1.0, 'foo', ['foo', 'bar'], ['foo' => 'bar']
|
||||
];
|
||||
$to = $from;
|
||||
$common = $this->implementation->calculate($from, $to);
|
||||
|
||||
$this->assertSame($from, $common);
|
||||
|
||||
$to = [
|
||||
false, false, false, false, false, false,
|
||||
true, true, true, true, true, true
|
||||
];
|
||||
|
||||
$expected = [
|
||||
false,
|
||||
true,
|
||||
];
|
||||
|
||||
$common = $this->implementation->calculate($from, $to);
|
||||
|
||||
$this->assertSame($expected, $common);
|
||||
}
|
||||
|
||||
public function testEqualSequences()
|
||||
{
|
||||
foreach ($this->stress_sizes as $size) {
|
||||
$range = \range(1, $size);
|
||||
$from = $range;
|
||||
$to = $range;
|
||||
$common = $this->implementation->calculate($from, $to);
|
||||
|
||||
$this->assertSame($range, $common);
|
||||
}
|
||||
}
|
||||
|
||||
public function testDistinctSequences()
|
||||
{
|
||||
$from = ['A'];
|
||||
$to = ['B'];
|
||||
$common = $this->implementation->calculate($from, $to);
|
||||
$this->assertSame([], $common);
|
||||
|
||||
$from = ['A', 'B', 'C'];
|
||||
$to = ['D', 'E', 'F'];
|
||||
$common = $this->implementation->calculate($from, $to);
|
||||
$this->assertSame([], $common);
|
||||
|
||||
foreach ($this->stress_sizes as $size) {
|
||||
$from = \range(1, $size);
|
||||
$to = \range($size + 1, $size * 2);
|
||||
$common = $this->implementation->calculate($from, $to);
|
||||
$this->assertSame([], $common);
|
||||
}
|
||||
}
|
||||
|
||||
public function testCommonSubsequence()
|
||||
{
|
||||
$from = ['A', 'C', 'E', 'F', 'G'];
|
||||
$to = ['A', 'B', 'D', 'E', 'H'];
|
||||
$expected = ['A', 'E'];
|
||||
$common = $this->implementation->calculate($from, $to);
|
||||
$this->assertSame($expected, $common);
|
||||
|
||||
$from = ['A', 'C', 'E', 'F', 'G'];
|
||||
$to = ['B', 'C', 'D', 'E', 'F', 'H'];
|
||||
$expected = ['C', 'E', 'F'];
|
||||
$common = $this->implementation->calculate($from, $to);
|
||||
$this->assertSame($expected, $common);
|
||||
|
||||
foreach ($this->stress_sizes as $size) {
|
||||
$from = $size < 2 ? [1] : \range(1, $size + 1, 2);
|
||||
$to = $size < 3 ? [1] : \range(1, $size + 1, 3);
|
||||
$expected = $size < 6 ? [1] : \range(1, $size + 1, 6);
|
||||
$common = $this->implementation->calculate($from, $to);
|
||||
|
||||
$this->assertSame($expected, $common);
|
||||
}
|
||||
}
|
||||
|
||||
public function testSingleElementSubsequenceAtStart()
|
||||
{
|
||||
foreach ($this->stress_sizes as $size) {
|
||||
$from = \range(1, $size);
|
||||
$to = \array_slice($from, 0, 1);
|
||||
$common = $this->implementation->calculate($from, $to);
|
||||
|
||||
$this->assertSame($to, $common);
|
||||
}
|
||||
}
|
||||
|
||||
public function testSingleElementSubsequenceAtMiddle()
|
||||
{
|
||||
foreach ($this->stress_sizes as $size) {
|
||||
$from = \range(1, $size);
|
||||
$to = \array_slice($from, (int) ($size / 2), 1);
|
||||
$common = $this->implementation->calculate($from, $to);
|
||||
|
||||
$this->assertSame($to, $common);
|
||||
}
|
||||
}
|
||||
|
||||
public function testSingleElementSubsequenceAtEnd()
|
||||
{
|
||||
foreach ($this->stress_sizes as $size) {
|
||||
$from = \range(1, $size);
|
||||
$to = \array_slice($from, $size - 1, 1);
|
||||
$common = $this->implementation->calculate($from, $to);
|
||||
|
||||
$this->assertSame($to, $common);
|
||||
}
|
||||
}
|
||||
|
||||
public function testReversedSequences()
|
||||
{
|
||||
$from = ['A', 'B'];
|
||||
$to = ['B', 'A'];
|
||||
$expected = ['A'];
|
||||
$common = $this->implementation->calculate($from, $to);
|
||||
$this->assertSame($expected, $common);
|
||||
|
||||
foreach ($this->stress_sizes as $size) {
|
||||
$from = \range(1, $size);
|
||||
$to = \array_reverse($from);
|
||||
$common = $this->implementation->calculate($from, $to);
|
||||
|
||||
$this->assertSame([1], $common);
|
||||
}
|
||||
}
|
||||
|
||||
public function testStrictTypeCalculate()
|
||||
{
|
||||
$diff = $this->implementation->calculate(['5'], ['05']);
|
||||
|
||||
$this->assertInternalType('array', $diff);
|
||||
$this->assertCount(0, $diff);
|
||||
}
|
||||
}
|
||||
22
vendor/sebastian/diff/tests/MemoryEfficientImplementationTest.php
vendored
Normal file
22
vendor/sebastian/diff/tests/MemoryEfficientImplementationTest.php
vendored
Normal file
@@ -0,0 +1,22 @@
|
||||
<?php declare(strict_types=1);
|
||||
/*
|
||||
* This file is part of sebastian/diff.
|
||||
*
|
||||
* (c) Sebastian Bergmann <sebastian@phpunit.de>
|
||||
*
|
||||
* For the full copyright and license information, please view the LICENSE
|
||||
* file that was distributed with this source code.
|
||||
*/
|
||||
|
||||
namespace SebastianBergmann\Diff;
|
||||
|
||||
/**
|
||||
* @covers SebastianBergmann\Diff\MemoryEfficientLongestCommonSubsequenceCalculator
|
||||
*/
|
||||
final class MemoryEfficientImplementationTest extends LongestCommonSubsequenceTest
|
||||
{
|
||||
protected function createImplementation()
|
||||
{
|
||||
return new MemoryEfficientLongestCommonSubsequenceCalculator;
|
||||
}
|
||||
}
|
||||
113
vendor/sebastian/diff/tests/ParserTest.php
vendored
113
vendor/sebastian/diff/tests/ParserTest.php
vendored
@@ -1,6 +1,6 @@
|
||||
<?php
|
||||
<?php declare(strict_types=1);
|
||||
/*
|
||||
* This file is part of the Diff package.
|
||||
* This file is part of sebastian/diff.
|
||||
*
|
||||
* (c) Sebastian Bergmann <sebastian@phpunit.de>
|
||||
*
|
||||
@@ -10,9 +10,16 @@
|
||||
|
||||
namespace SebastianBergmann\Diff;
|
||||
|
||||
use PHPUnit_Framework_TestCase;
|
||||
use PHPUnit\Framework\TestCase;
|
||||
|
||||
class ParserTest extends PHPUnit_Framework_TestCase
|
||||
/**
|
||||
* @covers SebastianBergmann\Diff\Parser
|
||||
*
|
||||
* @uses SebastianBergmann\Diff\Chunk
|
||||
* @uses SebastianBergmann\Diff\Diff
|
||||
* @uses SebastianBergmann\Diff\Line
|
||||
*/
|
||||
final class ParserTest extends TestCase
|
||||
{
|
||||
/**
|
||||
* @var Parser
|
||||
@@ -26,23 +33,28 @@ class ParserTest extends PHPUnit_Framework_TestCase
|
||||
|
||||
public function testParse()
|
||||
{
|
||||
$content = file_get_contents(__DIR__ . '/fixtures/patch.txt');
|
||||
$content = \file_get_contents(__DIR__ . '/fixtures/patch.txt');
|
||||
|
||||
$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);
|
||||
|
||||
$this->assertEquals(20, $chunks[0]->getStart());
|
||||
$this->assertSame(20, $chunks[0]->getStart());
|
||||
|
||||
$this->assertCount(5, $chunks[0]->getLines());
|
||||
$this->assertCount(4, $chunks[0]->getLines());
|
||||
}
|
||||
|
||||
public function testParseWithMultipleChunks()
|
||||
{
|
||||
$content = file_get_contents(__DIR__ . '/fixtures/patch2.txt');
|
||||
$content = \file_get_contents(__DIR__ . '/fixtures/patch2.txt');
|
||||
|
||||
$diffs = $this->parser->parse($content);
|
||||
|
||||
@@ -51,12 +63,89 @@ class ParserTest extends PHPUnit_Framework_TestCase
|
||||
$chunks = $diffs[0]->getChunks();
|
||||
$this->assertCount(3, $chunks);
|
||||
|
||||
$this->assertEquals(20, $chunks[0]->getStart());
|
||||
$this->assertEquals(320, $chunks[1]->getStart());
|
||||
$this->assertEquals(600, $chunks[2]->getStart());
|
||||
$this->assertSame(20, $chunks[0]->getStart());
|
||||
$this->assertSame(320, $chunks[1]->getStart());
|
||||
$this->assertSame(600, $chunks[2]->getStart());
|
||||
|
||||
$this->assertCount(5, $chunks[0]->getLines());
|
||||
$this->assertCount(5, $chunks[1]->getLines());
|
||||
$this->assertCount(5, $chunks[2]->getLines());
|
||||
$this->assertCount(4, $chunks[2]->getLines());
|
||||
}
|
||||
|
||||
public function testParseWithRemovedLines()
|
||||
{
|
||||
$content = <<<A
|
||||
diff --git a/Test.txt b/Test.txt
|
||||
index abcdefg..abcdefh 100644
|
||||
--- a/Test.txt
|
||||
+++ b/Test.txt
|
||||
@@ -49,9 +49,8 @@
|
||||
A
|
||||
-B
|
||||
A;
|
||||
$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);
|
||||
|
||||
$chunk = $chunks[0];
|
||||
$this->assertSame(49, $chunk->getStart());
|
||||
$this->assertSame(49, $chunk->getEnd());
|
||||
$this->assertSame(9, $chunk->getStartRange());
|
||||
$this->assertSame(8, $chunk->getEndRange());
|
||||
|
||||
$lines = $chunk->getLines();
|
||||
$this->assertInternalType('array', $lines);
|
||||
$this->assertContainsOnlyInstancesOf(Line::class, $lines);
|
||||
$this->assertCount(2, $lines);
|
||||
|
||||
/** @var Line $line */
|
||||
$line = $lines[0];
|
||||
$this->assertSame('A', $line->getContent());
|
||||
$this->assertSame(Line::UNCHANGED, $line->getType());
|
||||
|
||||
$line = $lines[1];
|
||||
$this->assertSame('B', $line->getContent());
|
||||
$this->assertSame(Line::REMOVED, $line->getType());
|
||||
}
|
||||
|
||||
public function testParseDiffForMulitpleFiles()
|
||||
{
|
||||
$content = <<<A
|
||||
diff --git a/Test.txt b/Test.txt
|
||||
index abcdefg..abcdefh 100644
|
||||
--- a/Test.txt
|
||||
+++ b/Test.txt
|
||||
@@ -1,3 +1,2 @@
|
||||
A
|
||||
-B
|
||||
|
||||
diff --git a/Test123.txt b/Test123.txt
|
||||
index abcdefg..abcdefh 100644
|
||||
--- a/Test2.txt
|
||||
+++ b/Test2.txt
|
||||
@@ -1,2 +1,3 @@
|
||||
A
|
||||
+B
|
||||
A;
|
||||
$diffs = $this->parser->parse($content);
|
||||
$this->assertCount(2, $diffs);
|
||||
|
||||
/** @var Diff $diff */
|
||||
$diff = $diffs[0];
|
||||
$this->assertSame('a/Test.txt', $diff->getFrom());
|
||||
$this->assertSame('b/Test.txt', $diff->getTo());
|
||||
$this->assertCount(1, $diff->getChunks());
|
||||
|
||||
$diff = $diffs[1];
|
||||
$this->assertSame('a/Test2.txt', $diff->getFrom());
|
||||
$this->assertSame('b/Test2.txt', $diff->getTo());
|
||||
$this->assertCount(1, $diff->getChunks());
|
||||
}
|
||||
}
|
||||
|
||||
22
vendor/sebastian/diff/tests/TimeEfficientImplementationTest.php
vendored
Normal file
22
vendor/sebastian/diff/tests/TimeEfficientImplementationTest.php
vendored
Normal file
@@ -0,0 +1,22 @@
|
||||
<?php declare(strict_types=1);
|
||||
/*
|
||||
* This file is part of sebastian/diff.
|
||||
*
|
||||
* (c) Sebastian Bergmann <sebastian@phpunit.de>
|
||||
*
|
||||
* For the full copyright and license information, please view the LICENSE
|
||||
* file that was distributed with this source code.
|
||||
*/
|
||||
|
||||
namespace SebastianBergmann\Diff;
|
||||
|
||||
/**
|
||||
* @covers SebastianBergmann\Diff\TimeEfficientLongestCommonSubsequenceCalculator
|
||||
*/
|
||||
final class TimeEfficientImplementationTest extends LongestCommonSubsequenceTest
|
||||
{
|
||||
protected function createImplementation()
|
||||
{
|
||||
return new TimeEfficientLongestCommonSubsequenceCalculator;
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user