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]);
$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('<b>Edit</b>');
$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!")]';

1
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');

3
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());
}

Loading…
Cancel
Save