function DiffEngineTest::testDiff

Same name in other branches
  1. 9 core/tests/Drupal/Tests/Component/Diff/Engine/DiffEngineTest.php \Drupal\Tests\Component\Diff\Engine\DiffEngineTest::testDiff()
  2. 8.9.x core/tests/Drupal/Tests/Component/Diff/Engine/DiffEngineTest.php \Drupal\Tests\Component\Diff\Engine\DiffEngineTest::testDiff()

Tests whether op classes returned by DiffEngine::diff() match expectations.

@covers ::diff @dataProvider provideTestDiff

File

core/tests/Drupal/Tests/Component/Diff/Engine/DiffEngineTest.php, line 102

Class

DiffEngineTest
Test DiffEngine class.

Namespace

Drupal\Tests\Component\Diff\Engine

Code

public function testDiff($expected, $from, $to) : void {
    $this->expectDeprecation('Drupal\\Component\\Diff\\Engine\\DiffEngine is deprecated in drupal:10.1.0 and is removed from drupal:11.0.0. Use sebastianbergmann/diff instead. See https://www.drupal.org/node/3337942');
    $diff_engine = new DiffEngine();
    $diff = $diff_engine->diff($from, $to);
    // Make sure we have the same number of results as expected.
    $this->assertSameSize($expected, $diff);
    // Make sure the diff objects match our expectations.
    foreach ($expected as $index => $op_class) {
        $this->assertEquals($op_class, get_class($diff[$index]));
    }
}

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