From 2c70fa668f9875b71b54b71cc67be401be9a75c0 Mon Sep 17 00:00:00 2001 From: Chi Date: Sun, 26 Feb 2023 08:20:51 +0000 Subject: [PATCH] Fix tests --- tests/src/Functional/TwigTweakTest.php | 4 ++-- tests/src/Kernel/AbstractExtractorTestCase.php | 1 + tests/src/Kernel/CacheMetadataExtractorTest.php | 3 ++- 3 files changed, 5 insertions(+), 3 deletions(-) diff --git a/tests/src/Functional/TwigTweakTest.php b/tests/src/Functional/TwigTweakTest.php index 2f70966..a2391cd 100644 --- a/tests/src/Functional/TwigTweakTest.php +++ b/tests/src/Functional/TwigTweakTest.php @@ -269,14 +269,14 @@ final class TwigTweakTest extends BrowserTestBase { $url = Url::fromUserInput('/node/1/edit', ['absolute' => TRUE]); $link = Link::fromTextAndUrl('Edit', $url)->toString(); $xpath = '//div[@class = "tt-link"]'; - self::assertEquals($link, $this->xpath($xpath)[0]->getHtml()); + self::assertSame((string) $link, $this->xpath($xpath)[0]->getHtml()); // -- Link with HTML. $text = Markup::create('Edit'); $url = Url::fromUserInput('/node/1/edit', ['absolute' => TRUE]); $link = Link::fromTextAndUrl($text, $url)->toString(); $xpath = '//div[@class = "tt-link-html"]'; - self::assertEquals($link, $this->xpath($xpath)[0]->getHtml()); + self::assertSame((string) $link, $this->xpath($xpath)[0]->getHtml()); // -- Status messages. $xpath = '//div[@class = "tt-messages"]//div[contains(@class, "messages--status") and contains(., "Hello world!")]'; diff --git a/tests/src/Kernel/AbstractExtractorTestCase.php b/tests/src/Kernel/AbstractExtractorTestCase.php index f21b15d..af83a52 100644 --- a/tests/src/Kernel/AbstractExtractorTestCase.php +++ b/tests/src/Kernel/AbstractExtractorTestCase.php @@ -50,6 +50,7 @@ abstract class AbstractExtractorTestCase extends KernelTestBase { $this->installConfig(['node', 'twig_tweak_test']); $this->installSchema('file', 'file_usage'); + $this->installEntitySchema('user'); $this->installEntitySchema('file'); $this->installEntitySchema('media'); diff --git a/tests/src/Kernel/CacheMetadataExtractorTest.php b/tests/src/Kernel/CacheMetadataExtractorTest.php index ed3f5c6..23ebc05 100644 --- a/tests/src/Kernel/CacheMetadataExtractorTest.php +++ b/tests/src/Kernel/CacheMetadataExtractorTest.php @@ -90,7 +90,8 @@ final class CacheMetadataExtractorTest extends AbstractTestCase { self::assertRenderArray($expected_build, $build); // -- Wrong type. - self::expectErrorMessage('The input should be either instance of Drupal\Core\Cache\CacheableDependencyInterface or array. stdClass was given.'); + $exception = new \InvalidArgumentException('The input should be either instance of Drupal\Core\Cache\CacheableDependencyInterface or array. stdClass was given.'); + self::expectExceptionObject($exception); /* @noinspection PhpParamsInspection */ $extractor->extractCacheMetadata(new \stdClass()); }