function DiffOpOutputBuilderTest::provideTestDiff

Same name in other branches
  1. 10 core/tests/Drupal/Tests/Component/Diff/DiffOpOutputBuilderTest.php \Drupal\Tests\Component\Diff\DiffOpOutputBuilderTest::provideTestDiff()

Return value

array

  • Expected output in terms of return class. A list of class names expected to be returned by DiffEngine::diff().
  • An array of strings to change from.
  • An array of strings to change to.

File

core/tests/Drupal/Tests/Component/Diff/DiffOpOutputBuilderTest.php, line 29

Class

DiffOpOutputBuilderTest
@coversDefaultClass \Drupal\Component\Diff\DiffOpOutputBuilder

Namespace

Drupal\Tests\Component\Diff

Code

public static function provideTestDiff() : array {
    return [
        'empty' => [
            [],
            [],
            [],
        ],
        'add' => [
            [
                new DiffOpAdd([
                    'a',
                ]),
            ],
            [],
            [
                'a',
            ],
        ],
        'copy' => [
            [
                new DiffOpCopy([
                    'a',
                ]),
            ],
            [
                'a',
            ],
            [
                'a',
            ],
        ],
        'change' => [
            [
                new DiffOpChange([
                    'a',
                ], [
                    'b',
                ]),
            ],
            [
                'a',
            ],
            [
                'b',
            ],
        ],
        'copy-and-change' => [
            [
                new DiffOpCopy([
                    'a',
                ]),
                new DiffOpChange([
                    'b',
                ], [
                    'c',
                ]),
            ],
            [
                'a',
                'b',
            ],
            [
                'a',
                'c',
            ],
        ],
        'copy-change-copy' => [
            [
                new DiffOpCopy([
                    'a',
                ]),
                new DiffOpChange([
                    'b',
                ], [
                    'c',
                ]),
                new DiffOpCopy([
                    'd',
                ]),
            ],
            [
                'a',
                'b',
                'd',
            ],
            [
                'a',
                'c',
                'd',
            ],
        ],
        'copy-change-copy-add' => [
            [
                new DiffOpCopy([
                    'a',
                ]),
                new DiffOpChange([
                    'b',
                ], [
                    'c',
                ]),
                new DiffOpCopy([
                    'd',
                ]),
                new DiffOpAdd([
                    'e',
                ]),
            ],
            [
                'a',
                'b',
                'd',
            ],
            [
                'a',
                'c',
                'd',
                'e',
            ],
        ],
        'copy-delete' => [
            [
                new DiffOpCopy([
                    'a',
                ]),
                new DiffOpDelete([
                    'b',
                    'd',
                ]),
            ],
            [
                'a',
                'b',
                'd',
            ],
            [
                'a',
            ],
        ],
        'change-copy' => [
            [
                new DiffOpChange([
                    'aa',
                    'bb',
                    'cc',
                ], [
                    'a',
                    'c',
                ]),
                new DiffOpCopy([
                    'd',
                ]),
            ],
            [
                'aa',
                'bb',
                'cc',
                'd',
            ],
            [
                'a',
                'c',
                'd',
            ],
        ],
        'copy-change-copy-change' => [
            [
                new DiffOpCopy([
                    'a',
                ]),
                new DiffOpChange([
                    'bb',
                ], [
                    'b',
                    'c',
                ]),
                new DiffOpCopy([
                    'd',
                ]),
                new DiffOpChange([
                    'ee',
                ], [
                    'e',
                ]),
            ],
            [
                'a',
                'bb',
                'd',
                'ee',
            ],
            [
                'a',
                'b',
                'c',
                'd',
                'e',
            ],
        ],
    ];
}

Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.