Browse Source

Fix tests

merge-requests/30/head
Chi 2 years ago
parent
commit
2c70fa668f
  1. 4
      tests/src/Functional/TwigTweakTest.php
  2. 1
      tests/src/Kernel/AbstractExtractorTestCase.php
  3. 3
      tests/src/Kernel/CacheMetadataExtractorTest.php

4
tests/src/Functional/TwigTweakTest.php

@ -269,14 +269,14 @@ final class TwigTweakTest extends BrowserTestBase {
$url = Url::fromUserInput('/node/1/edit', ['absolute' => TRUE]); $url = Url::fromUserInput('/node/1/edit', ['absolute' => TRUE]);
$link = Link::fromTextAndUrl('Edit', $url)->toString(); $link = Link::fromTextAndUrl('Edit', $url)->toString();
$xpath = '//div[@class = "tt-link"]'; $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. // -- Link with HTML.
$text = Markup::create('<b>Edit</b>'); $text = Markup::create('<b>Edit</b>');
$url = Url::fromUserInput('/node/1/edit', ['absolute' => TRUE]); $url = Url::fromUserInput('/node/1/edit', ['absolute' => TRUE]);
$link = Link::fromTextAndUrl($text, $url)->toString(); $link = Link::fromTextAndUrl($text, $url)->toString();
$xpath = '//div[@class = "tt-link-html"]'; $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. // -- Status messages.
$xpath = '//div[@class = "tt-messages"]//div[contains(@class, "messages--status") and contains(., "Hello world!")]'; $xpath = '//div[@class = "tt-messages"]//div[contains(@class, "messages--status") and contains(., "Hello world!")]';

1
tests/src/Kernel/AbstractExtractorTestCase.php

@ -50,6 +50,7 @@ abstract class AbstractExtractorTestCase extends KernelTestBase {
$this->installConfig(['node', 'twig_tweak_test']); $this->installConfig(['node', 'twig_tweak_test']);
$this->installSchema('file', 'file_usage'); $this->installSchema('file', 'file_usage');
$this->installEntitySchema('user');
$this->installEntitySchema('file'); $this->installEntitySchema('file');
$this->installEntitySchema('media'); $this->installEntitySchema('media');

3
tests/src/Kernel/CacheMetadataExtractorTest.php

@ -90,7 +90,8 @@ final class CacheMetadataExtractorTest extends AbstractTestCase {
self::assertRenderArray($expected_build, $build); self::assertRenderArray($expected_build, $build);
// -- Wrong type. // -- 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 */ /* @noinspection PhpParamsInspection */
$extractor->extractCacheMetadata(new \stdClass()); $extractor->extractCacheMetadata(new \stdClass());
} }

Loading…
Cancel
Save