Updated to Drupal 8.5. Core Media not yet in use.
[yaffs-website] / web / core / tests / Drupal / Tests / Component / Diff / Engine / DiffEngineTest.php
index 69f92daec9c79932f224b993f7e824a957839492..1714e663be55a4499d5c12f407b8d01c34c61719 100644 (file)
@@ -86,4 +86,21 @@ class DiffEngineTest extends TestCase {
     }
   }
 
+  /**
+   * Tests that two files can be successfully diffed.
+   *
+   * @covers ::diff
+   */
+  public function testDiffInfiniteLoop() {
+    $from = explode("\n", file_get_contents(__DIR__ . '/fixtures/file1.txt'));
+    $to = explode("\n", file_get_contents(__DIR__ . '/fixtures/file2.txt'));
+    $diff_engine = new DiffEngine();
+    $diff = $diff_engine->diff($from, $to);
+    $this->assertCount(4, $diff);
+    $this->assertEquals($diff[0], new DiffOpDelete(['    - image.style.max_650x650']));
+    $this->assertEquals($diff[1], new DiffOpCopy(['    - image.style.max_325x325']));
+    $this->assertEquals($diff[2], new DiffOpAdd(['    - image.style.max_650x650', '_core:', '  default_config_hash: 3mjM9p-kQ8syzH7N8T0L9OnCJDSPvHAZoi3q6jcXJKM']));
+    $this->assertEquals($diff[3], new DiffOpCopy(['fallback_image_style: max_325x325', '']));
+  }
+
 }