Issue #3402713 by mstrelan, smustgrave, dww: Fix strict type errors: miscellaneous fixes in core Kernel tests
(cherry picked from commit f60bcea7d7
)
merge-requests/7413/head
parent
e3da4cc32c
commit
8331ba7ee1
|
@ -513,7 +513,7 @@ class FilterKernelTest extends KernelTestBase {
|
|||
'children' => 'Test two',
|
||||
];
|
||||
include_once $this->root . '/core/themes/engines/twig/twig.engine';
|
||||
$render = twig_render_template('container.html.twig', $variables);
|
||||
$render = (string) twig_render_template('container.html.twig', $variables);
|
||||
$render = trim($render);
|
||||
|
||||
// Render text before applying the auto paragraph filter.
|
||||
|
|
|
@ -96,7 +96,7 @@ class LinkItemSerializationTest extends FieldKernelTestBase {
|
|||
->set('query', $parsed_url['query']);
|
||||
$json = json_decode($this->serializer->serialize($entity, 'json'), TRUE);
|
||||
$json['field_test'][0]['options'] = 'string data';
|
||||
$serialized = json_encode($json, TRUE);
|
||||
$serialized = json_encode($json);
|
||||
$this->expectException(\LogicException::class);
|
||||
$this->expectExceptionMessage('The generic FieldItemNormalizer cannot denormalize string values for "options" properties of the "field_test" field (field item class: Drupal\link\Plugin\Field\FieldType\LinkItem).');
|
||||
$this->serializer->deserialize($serialized, EntityTest::class, 'json');
|
||||
|
|
|
@ -23,7 +23,7 @@ class TemporaryQueryTest extends TemporaryQueryTestBase {
|
|||
|
||||
// Assert that the table is indeed a temporary one.
|
||||
$temporary_table_info = $connection->query("SHOW CREATE TABLE {" . $table_name_test . "}")->fetchAssoc();
|
||||
$this->stringContains($temporary_table_info["Create Table"], "CREATE TEMPORARY TABLE");
|
||||
$this->assertStringContainsString('CREATE TEMPORARY TABLE', $temporary_table_info['Create Table']);
|
||||
|
||||
// Assert that both have the same field names.
|
||||
$normal_table_fields = $connection->query("SELECT * FROM {test}")->fetch();
|
||||
|
|
|
@ -86,7 +86,7 @@ class PathPluginTest extends ViewsKernelTestBase {
|
|||
|
||||
// Test with view_mode full.
|
||||
$output = $view->preview();
|
||||
$output = $renderer->renderRoot($output);
|
||||
$output = (string) $renderer->renderRoot($output);
|
||||
foreach ($this->nodes as $node) {
|
||||
$this->assertStringContainsString('This is <strong>not escaped</strong> and this is ' . $node->toLink('the link')->toString(), $output, 'Make sure path field rewriting is not escaped.');
|
||||
}
|
||||
|
|
|
@ -98,7 +98,7 @@ class RowPluginTest extends ViewsKernelTestBase {
|
|||
|
||||
// Test with view_mode full.
|
||||
$output = $view->preview();
|
||||
$output = $renderer->renderRoot($output);
|
||||
$output = (string) $renderer->renderRoot($output);
|
||||
foreach ($this->nodes as $node) {
|
||||
$this->assertStringNotContainsString($node->body->summary, $output, 'Make sure the teaser appears in the output of the view.');
|
||||
$this->assertStringContainsString($node->body->value, $output, 'Make sure the full text appears in the output of the view.');
|
||||
|
@ -107,7 +107,7 @@ class RowPluginTest extends ViewsKernelTestBase {
|
|||
// Test with teasers.
|
||||
$view->rowPlugin->options['view_mode'] = 'teaser';
|
||||
$output = $view->preview();
|
||||
$output = $renderer->renderRoot($output);
|
||||
$output = (string) $renderer->renderRoot($output);
|
||||
foreach ($this->nodes as $node) {
|
||||
$this->assertStringContainsString($node->body->summary, $output, 'Make sure the teaser appears in the output of the view.');
|
||||
$this->assertStringNotContainsString($node->body->value, $output);
|
||||
|
|
|
@ -123,7 +123,8 @@ class WhoIsOnlineBlockTest extends KernelTestBase {
|
|||
$this->assertText($user2->getAccountName(), 'Active user 2 found in online list.');
|
||||
$this->assertNoText($user3->getAccountName(), 'Inactive user not found in online list.');
|
||||
// Verify that online users are ordered correctly.
|
||||
$this->assertGreaterThan(strpos($this->getRawContent(), $user2->getAccountName()), strpos($this->getRawContent(), $user1->getAccountName()));
|
||||
$raw_content = (string) $this->getRawContent();
|
||||
$this->assertGreaterThan(strpos($raw_content, $user2->getAccountName()), strpos($raw_content, $user1->getAccountName()));
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -84,9 +84,9 @@ class ComputedBundleFieldTest extends ViewsKernelTestBase {
|
|||
|
||||
// Entities 1 and 2 should have the computed bundle field. But entity 3
|
||||
// should not.
|
||||
$this->assertStringContainsString('some other string that is also computed', $view->field['computed_bundle_field']->render($view->result[0]));
|
||||
$this->assertStringContainsString('some other string that is also computed', $view->field['computed_bundle_field']->render($view->result[1]));
|
||||
$this->assertStringNotContainsString('some other string that is also computed', $view->field['computed_bundle_field']->render($view->result[2]));
|
||||
$this->assertStringContainsString('some other string that is also computed', (string) $view->field['computed_bundle_field']->render($view->result[0]));
|
||||
$this->assertStringContainsString('some other string that is also computed', (string) $view->field['computed_bundle_field']->render($view->result[1]));
|
||||
$this->assertStringNotContainsString('some other string that is also computed', (string) $view->field['computed_bundle_field']->render($view->result[2]));
|
||||
|
||||
$view->destroy();
|
||||
}
|
||||
|
|
|
@ -64,8 +64,10 @@ class PathValidatorTest extends KernelTestBase {
|
|||
}
|
||||
$this->container->set('router.request_context', new RequestContext());
|
||||
}
|
||||
else {
|
||||
$requestContext->setMethod($method);
|
||||
}
|
||||
|
||||
$requestContext->setMethod($method);
|
||||
/** @var \Drupal\Core\Url $url */
|
||||
$url = $pathValidator->getUrlIfValidWithoutAccessCheck($entity->toUrl()->toString(TRUE)->getGeneratedUrl());
|
||||
$this->assertEquals($method, $requestContext->getMethod());
|
||||
|
|
|
@ -64,7 +64,7 @@ class ClaroTableTest extends KernelTestBase {
|
|||
],
|
||||
];
|
||||
|
||||
$renderedTable = \Drupal::service('renderer')->renderRoot($table);
|
||||
$renderedTable = (string) \Drupal::service('renderer')->renderRoot($table);
|
||||
|
||||
// Confirm that table is rendered.
|
||||
$this->assertStringContainsString('class="class"', $renderedTable);
|
||||
|
|
Loading…
Reference in New Issue