From a2270154b776a1adb84b81b20f2fe095707c7cec Mon Sep 17 00:00:00 2001 From: catch <6915-catch@users.noreply.drupalcode.org> Date: Tue, 6 May 2025 11:43:30 +0100 Subject: [PATCH] Issue #3522795 by alexpott, bbrala: \Drupal\Tests\Core\DefaultContent\FinderTest::testExceptionIfNoUuid() can cause random fails (cherry picked from commit d0d9ddba3def7a90652c7085af7d41a940c7e97c) --- .../Tests/Core/DefaultContent/FinderTest.php | 10 ++------ .../default_content_broken/no-uuid.yml | 23 +++++++++++++++++++ 2 files changed, 25 insertions(+), 8 deletions(-) create mode 100644 core/tests/fixtures/default_content_broken/no-uuid.yml diff --git a/core/tests/Drupal/Tests/Core/DefaultContent/FinderTest.php b/core/tests/Drupal/Tests/Core/DefaultContent/FinderTest.php index 6abfb5b67331..ad6f98c3cf78 100644 --- a/core/tests/Drupal/Tests/Core/DefaultContent/FinderTest.php +++ b/core/tests/Drupal/Tests/Core/DefaultContent/FinderTest.php @@ -4,7 +4,6 @@ namespace Drupal\Tests\Core\DefaultContent; -use Drupal\Component\FileSystem\FileSystem; use Drupal\Core\DefaultContent\Finder; use Drupal\Core\DefaultContent\ImportException; use Drupal\Tests\UnitTestCase; @@ -38,14 +37,9 @@ public function testFoundDataIsInDependencyOrder(): void { * Tests that files without UUIDs will raise an exception. */ public function testExceptionIfNoUuid(): void { - $dir = FileSystem::getOsTemporaryDirectory(); - $this->assertIsString($dir); - /** @var string $dir */ - file_put_contents($dir . '/no-uuid.yml', '_meta: {}'); - $this->expectException(ImportException::class); - $this->expectExceptionMessage("$dir/no-uuid.yml does not have a UUID."); - new Finder($dir); + $this->expectExceptionMessageMatches("#/no-uuid\.yml does not have a UUID\.$#"); + new Finder(__DIR__ . '/../../../../fixtures/default_content_broken'); } } diff --git a/core/tests/fixtures/default_content_broken/no-uuid.yml b/core/tests/fixtures/default_content_broken/no-uuid.yml new file mode 100644 index 000000000000..f95a15c6463a --- /dev/null +++ b/core/tests/fixtures/default_content_broken/no-uuid.yml @@ -0,0 +1,23 @@ +_meta: + version: '1.0' + entity_type: block_content + bundle: basic + default_langcode: en +default: + status: + - + value: true + info: + - + value: 'Useful Info' + reusable: + - + value: true + revision_translation_affected: + - + value: true + body: + - + value: "I'd love to put some useful info here." + format: plain_text + summary: '' -- GitLab