Issue #3402293 by dww, mstrelan, smustgrave: Fix strict type errors: Convert FormattableMarkup to strings (simple replacement) in core/modules/*/tests/src/Kernel/*
parent
d6f1a5a4ae
commit
df70716e5a
|
@ -2,7 +2,6 @@
|
|||
|
||||
namespace Drupal\Tests\dblog\Kernel;
|
||||
|
||||
use Drupal\Component\Render\FormattableMarkup;
|
||||
use Drupal\Core\Database\Database;
|
||||
use Drupal\KernelTests\KernelTestBase;
|
||||
use Drupal\Tests\dblog\Functional\FakeLogEntries;
|
||||
|
@ -40,7 +39,7 @@ class DbLogTest extends KernelTestBase {
|
|||
$this->generateLogEntries($row_limit + 10);
|
||||
// Verify that the database log row count exceeds the row limit.
|
||||
$count = Database::getConnection()->select('watchdog')->countQuery()->execute()->fetchField();
|
||||
$this->assertGreaterThan($row_limit, $count, new FormattableMarkup('Dblog row count of @count exceeds row limit of @limit', ['@count' => $count, '@limit' => $row_limit]));
|
||||
$this->assertGreaterThan($row_limit, $count, "Dblog row count of $count exceeds row limit of $row_limit");
|
||||
|
||||
// Get the number of enabled modules. Cron adds a log entry for each module.
|
||||
$implementation_count = 0;
|
||||
|
@ -52,12 +51,13 @@ class DbLogTest extends KernelTestBase {
|
|||
);
|
||||
|
||||
$cron_detailed_count = $this->runCron();
|
||||
$this->assertEquals($implementation_count + 2, $cron_detailed_count, new FormattableMarkup('Cron added @count of @expected new log entries', ['@count' => $cron_detailed_count, '@expected' => $implementation_count + 2]));
|
||||
$expected_count = $implementation_count + 2;
|
||||
$this->assertEquals($expected_count, $cron_detailed_count, "Cron added $cron_detailed_count of $expected_count new log entries");
|
||||
|
||||
// Test disabling of detailed cron logging.
|
||||
$this->config('system.cron')->set('logging', 0)->save();
|
||||
$cron_count = $this->runCron();
|
||||
$this->assertEquals(1, $cron_count, new FormattableMarkup('Cron added @count of @expected new log entries', ['@count' => $cron_count, '@expected' => 1]));
|
||||
$this->assertEquals(1, $cron_count, "Cron added $cron_count of 1 new log entries");
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
@ -2,7 +2,6 @@
|
|||
|
||||
namespace Drupal\Tests\field\Kernel\EntityReference;
|
||||
|
||||
use Drupal\Component\Render\FormattableMarkup;
|
||||
use Drupal\Core\Cache\Cache;
|
||||
use Drupal\Core\Cache\CacheableMetadata;
|
||||
use Drupal\Core\Field\FieldStorageDefinitionInterface;
|
||||
|
@ -163,7 +162,7 @@ class EntityReferenceFormatterTest extends EntityKernelTestBase {
|
|||
->view($referencing_entity, 'default');
|
||||
|
||||
// Verify the un-accessible item still exists.
|
||||
$this->assertEquals($this->referencedEntity->id(), $referencing_entity->{$field_name}->target_id, new FormattableMarkup('The un-accessible item still exists after @name formatter was executed.', ['@name' => $name]));
|
||||
$this->assertEquals($this->referencedEntity->id(), $referencing_entity->{$field_name}->target_id, "The un-accessible item still exists after $name formatter was executed.");
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -215,7 +214,7 @@ class EntityReferenceFormatterTest extends EntityKernelTestBase {
|
|||
$this->assertSame('default | ' . $this->referencedEntity->label() . $expected_rendered_name_field_1 . $expected_rendered_body_field_1, (string) $build[0]['#markup'], sprintf('The markup returned by the %s formatter is correct for an item with a saved entity.', $formatter));
|
||||
$expected_cache_tags = Cache::mergeTags(\Drupal::entityTypeManager()->getViewBuilder($this->entityType)->getCacheTags(), $this->referencedEntity->getCacheTags());
|
||||
$expected_cache_tags = Cache::mergeTags($expected_cache_tags, FilterFormat::load('full_html')->getCacheTags());
|
||||
$this->assertEquals($expected_cache_tags, $build[0]['#cache']['tags'], new FormattableMarkup('The @formatter formatter has the expected cache tags.', ['@formatter' => $formatter]));
|
||||
$this->assertEquals($expected_cache_tags, $build[0]['#cache']['tags'], "The $formatter formatter has the expected cache tags.");
|
||||
|
||||
// Test the second field item.
|
||||
$expected_rendered_name_field_2 = '
|
||||
|
|
|
@ -2,7 +2,6 @@
|
|||
|
||||
namespace Drupal\Tests\field\Kernel;
|
||||
|
||||
use Drupal\Component\Render\FormattableMarkup;
|
||||
use Drupal\field\Entity\FieldConfig;
|
||||
use Drupal\field\Entity\FieldStorageConfig;
|
||||
|
||||
|
@ -59,17 +58,17 @@ class FieldAttachStorageTest extends FieldKernelTestBase {
|
|||
$this->assertCount($cardinality, $entity->{$this->fieldTestData->field_name}, 'Current revision: expected number of values');
|
||||
for ($delta = 0; $delta < $cardinality; $delta++) {
|
||||
// The field value loaded matches the one inserted or updated.
|
||||
$this->assertEquals($values[$current_revision][$delta]['value'], $entity->{$this->fieldTestData->field_name}[$delta]->value, new FormattableMarkup('Current revision: expected value %delta was found.', ['%delta' => $delta]));
|
||||
$this->assertEquals($values[$current_revision][$delta]['value'], $entity->{$this->fieldTestData->field_name}[$delta]->value, "Current revision: expected value $delta was found.");
|
||||
}
|
||||
|
||||
// Confirm each revision loads the correct data.
|
||||
foreach (array_keys($values) as $revision_id) {
|
||||
$entity = $storage->loadRevision($revision_id);
|
||||
// Number of values per field loaded equals the field cardinality.
|
||||
$this->assertCount($cardinality, $entity->{$this->fieldTestData->field_name}, new FormattableMarkup('Revision %revision_id: expected number of values.', ['%revision_id' => $revision_id]));
|
||||
$this->assertCount($cardinality, $entity->{$this->fieldTestData->field_name}, "Revision $revision_id: expected number of values.");
|
||||
for ($delta = 0; $delta < $cardinality; $delta++) {
|
||||
// The field value loaded matches the one inserted or updated.
|
||||
$this->assertEquals($values[$revision_id][$delta]['value'], $entity->{$this->fieldTestData->field_name}[$delta]->value, new FormattableMarkup('Revision %revision_id: expected value %delta was found.', ['%revision_id' => $revision_id, '%delta' => $delta]));
|
||||
$this->assertEquals($values[$revision_id][$delta]['value'], $entity->{$this->fieldTestData->field_name}[$delta]->value, "Revision $revision_id: expected value $delta was found.");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -140,7 +139,7 @@ class FieldAttachStorageTest extends FieldKernelTestBase {
|
|||
continue;
|
||||
}
|
||||
// The field value loaded matches the one inserted.
|
||||
$this->assertEquals($values[$index][$field_name], $entity->{$field_name}->value, new FormattableMarkup('Entity %index: expected value was found.', ['%index' => $index]));
|
||||
$this->assertEquals($values[$index][$field_name], $entity->{$field_name}->value, "Entity $index: expected value was found.");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -2,7 +2,6 @@
|
|||
|
||||
namespace Drupal\Tests\field\Kernel;
|
||||
|
||||
use Drupal\Component\Render\FormattableMarkup;
|
||||
use Drupal\Core\Database\Database;
|
||||
use Drupal\Core\Entity\Sql\SqlContentEntityStorage;
|
||||
use Drupal\entity_test\Entity\EntityTest;
|
||||
|
@ -139,7 +138,7 @@ class FieldDataCountTest extends FieldKernelTestBase {
|
|||
/** @var \Drupal\Core\Entity\RevisionableStorageInterface $storage */
|
||||
$storage = $this->container->get('entity_type.manager')->getStorage($entity_type);
|
||||
$entity = $storage->loadRevision($first_revision);
|
||||
$this->assertCount($cardinality, $entity->{$this->fieldTestData->field_name_2}, new FormattableMarkup('Revision %revision_id: expected number of values.', ['%revision_id' => $first_revision]));
|
||||
$this->assertCount($cardinality, $entity->{$this->fieldTestData->field_name_2}, "Revision $first_revision: expected number of values.");
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
@ -2,7 +2,6 @@
|
|||
|
||||
namespace Drupal\Tests\field\Kernel;
|
||||
|
||||
use Drupal\Component\Render\FormattableMarkup;
|
||||
use Drupal\entity_test\Entity\EntityTest;
|
||||
use Drupal\field\Entity\FieldConfig;
|
||||
use Drupal\field\Entity\FieldStorageConfig;
|
||||
|
@ -69,11 +68,11 @@ class FieldImportDeleteTest extends FieldKernelTestBase {
|
|||
$active = $this->container->get('config.storage');
|
||||
$sync = $this->container->get('config.storage.sync');
|
||||
$this->copyConfig($active, $sync);
|
||||
$this->assertTrue($sync->delete($field_storage_config_name), new FormattableMarkup('Deleted field storage: @field_storage', ['@field_storage' => $field_storage_config_name]));
|
||||
$this->assertTrue($sync->delete($field_storage_config_name_2), new FormattableMarkup('Deleted field storage: @field_storage', ['@field_storage' => $field_storage_config_name_2]));
|
||||
$this->assertTrue($sync->delete($field_config_name), new FormattableMarkup('Deleted field: @field', ['@field' => $field_config_name]));
|
||||
$this->assertTrue($sync->delete($field_config_name_2a), new FormattableMarkup('Deleted field: @field', ['@field' => $field_config_name_2a]));
|
||||
$this->assertTrue($sync->delete($field_config_name_2b), new FormattableMarkup('Deleted field: @field', ['@field' => $field_config_name_2b]));
|
||||
$this->assertTrue($sync->delete($field_storage_config_name), "Deleted field storage: $field_storage_config_name");
|
||||
$this->assertTrue($sync->delete($field_storage_config_name_2), "Deleted field storage: $field_storage_config_name_2");
|
||||
$this->assertTrue($sync->delete($field_config_name), "Deleted field: $field_config_name");
|
||||
$this->assertTrue($sync->delete($field_config_name_2a), "Deleted field: $field_config_name_2a");
|
||||
$this->assertTrue($sync->delete($field_config_name_2b), "Deleted field: $field_config_name_2b");
|
||||
|
||||
$deletes = $this->configImporter()->getUnprocessedConfiguration('delete');
|
||||
$this->assertCount(5, $deletes, 'Importing configuration will delete 3 fields and 2 field storages.');
|
||||
|
|
|
@ -2,7 +2,6 @@
|
|||
|
||||
namespace Drupal\Tests\field\Kernel;
|
||||
|
||||
use Drupal\Component\Render\FormattableMarkup;
|
||||
use Drupal\Core\Extension\ExtensionDiscovery;
|
||||
use Drupal\Core\Field\BaseFieldDefinition;
|
||||
use Drupal\entity_test\Entity\EntityTest;
|
||||
|
@ -21,8 +20,8 @@ class FieldTypePluginManagerTest extends FieldKernelTestBase {
|
|||
$field_type_manager = \Drupal::service('plugin.manager.field.field_type');
|
||||
foreach (['test_field', 'shape', 'hidden_test_field'] as $type) {
|
||||
$definition = $field_type_manager->getDefinition($type);
|
||||
$this->assertSame($field_type_manager->getDefaultStorageSettings($type), $definition['class']::defaultStorageSettings(), new FormattableMarkup("%type storage settings were returned", ['%type' => $type]));
|
||||
$this->assertSame($field_type_manager->getDefaultFieldSettings($type), $definition['class']::defaultFieldSettings(), new FormattableMarkup(" %type field settings were returned", ['%type' => $type]));
|
||||
$this->assertSame($field_type_manager->getDefaultStorageSettings($type), $definition['class']::defaultStorageSettings(), "$type storage settings were returned");
|
||||
$this->assertSame($field_type_manager->getDefaultFieldSettings($type), $definition['class']::defaultFieldSettings(), "$type field settings were returned");
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -49,7 +48,7 @@ class FieldTypePluginManagerTest extends FieldKernelTestBase {
|
|||
$instance = $field_type_manager->createInstance($type, $configuration);
|
||||
|
||||
$this->assertInstanceOf($class, $instance);
|
||||
$this->assertEquals($field_name, $instance->getName(), new FormattableMarkup('Instance name is @name', ['@name' => $field_name]));
|
||||
$this->assertEquals($field_name, $instance->getName(), "Instance name is $field_name");
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -80,7 +79,7 @@ class FieldTypePluginManagerTest extends FieldKernelTestBase {
|
|||
$instance = $field_type_manager->createInstance($type, $configuration);
|
||||
|
||||
$this->assertInstanceOf($class, $instance);
|
||||
$this->assertEquals($field_name, $instance->getName(), new FormattableMarkup('Instance name is @name', ['@name' => $field_name]));
|
||||
$this->assertEquals($field_name, $instance->getName(), "Instance name is $field_name");
|
||||
$this->assertEquals('Jenny', $instance->getFieldDefinition()->getLabel(), 'Instance label is Jenny');
|
||||
$this->assertEquals([['value' => 8675309]], $instance->getFieldDefinition()->getDefaultValue($entity), 'Instance default_value is 8675309');
|
||||
}
|
||||
|
|
|
@ -2,7 +2,6 @@
|
|||
|
||||
namespace Drupal\Tests\field\Kernel;
|
||||
|
||||
use Drupal\Component\Render\FormattableMarkup;
|
||||
use Drupal\field\Entity\FieldConfig;
|
||||
use Drupal\language\Entity\ConfigurableLanguage;
|
||||
use Drupal\field\Entity\FieldStorageConfig;
|
||||
|
@ -137,7 +136,7 @@ class TranslationTest extends FieldKernelTestBase {
|
|||
foreach ($items as $delta => $item) {
|
||||
$result = $result && $item['value'] == $entity->getTranslation($langcode)->{$this->fieldName}[$delta]->value;
|
||||
}
|
||||
$this->assertTrue($result, new FormattableMarkup('%language translation correctly handled.', ['%language' => $langcode]));
|
||||
$this->assertTrue($result, "$langcode translation correctly handled.");
|
||||
}
|
||||
|
||||
// Test default values.
|
||||
|
@ -174,7 +173,7 @@ class TranslationTest extends FieldKernelTestBase {
|
|||
// @todo Test every translation once the Entity Translation API allows for
|
||||
// multilingual defaults.
|
||||
$langcode = $entity->language()->getId();
|
||||
$this->assertEquals($field->getDefaultValueLiteral(), $entity->getTranslation($langcode)->{$field_name_default}->getValue(), new FormattableMarkup('Default value correctly populated for language %language.', ['%language' => $langcode]));
|
||||
$this->assertEquals($field->getDefaultValueLiteral(), $entity->getTranslation($langcode)->{$field_name_default}->getValue(), "Default value correctly populated for language $langcode.");
|
||||
|
||||
$storage = \Drupal::entityTypeManager()->getStorage($entity_type_id);
|
||||
// Check that explicit empty values are not overridden with default values.
|
||||
|
@ -190,7 +189,7 @@ class TranslationTest extends FieldKernelTestBase {
|
|||
}
|
||||
|
||||
foreach ($entity->getTranslationLanguages() as $langcode => $language) {
|
||||
$this->assertEquals([], $entity->getTranslation($langcode)->{$field_name_default}->getValue(), new FormattableMarkup('Empty value correctly populated for language %language.', ['%language' => $langcode]));
|
||||
$this->assertEquals([], $entity->getTranslation($langcode)->{$field_name_default}->getValue(), "Empty value correctly populated for language $langcode.");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -2,7 +2,6 @@
|
|||
|
||||
namespace Drupal\Tests\filter\Kernel;
|
||||
|
||||
use Drupal\Component\Render\FormattableMarkup;
|
||||
use Drupal\Core\Language\LanguageInterface;
|
||||
use Drupal\Core\Session\AnonymousUserSession;
|
||||
use Drupal\Core\TypedData\OptionsProviderInterface;
|
||||
|
@ -454,7 +453,7 @@ class FilterAPITest extends EntityKernelTestBase {
|
|||
break;
|
||||
}
|
||||
}
|
||||
$this->assertTrue($filter_format_violation_found, new FormattableMarkup('Validation violation for invalid value "%invalid_value" found', ['%invalid_value' => $invalid_value]));
|
||||
$this->assertTrue($filter_format_violation_found, 'Validation violation for invalid value "' . $invalid_value . '" found');
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
@ -2,7 +2,6 @@
|
|||
|
||||
namespace Drupal\Tests\filter\Kernel;
|
||||
|
||||
use Drupal\Component\Render\FormattableMarkup;
|
||||
use Drupal\filter\Entity\FilterFormat;
|
||||
use Drupal\KernelTests\KernelTestBase;
|
||||
|
||||
|
@ -90,16 +89,16 @@ class FilterCrudTest extends KernelTestBase {
|
|||
* Verifies that a text format is properly stored.
|
||||
*/
|
||||
public function verifyTextFormat($format) {
|
||||
$t_args = ['%format' => $format->label()];
|
||||
$default_langcode = \Drupal::languageManager()->getDefaultLanguage()->getId();
|
||||
|
||||
// Verify the loaded filter has all properties.
|
||||
$filter_format = FilterFormat::load($format->id());
|
||||
$this->assertEquals($format->id(), $filter_format->id(), new FormattableMarkup('filter_format_load: Proper format id for text format %format.', $t_args));
|
||||
$this->assertEquals($format->label(), $filter_format->label(), new FormattableMarkup('filter_format_load: Proper title for text format %format.', $t_args));
|
||||
$this->assertEquals($format->get('weight'), $filter_format->get('weight'), new FormattableMarkup('filter_format_load: Proper weight for text format %format.', $t_args));
|
||||
$format_label = $format->label();
|
||||
$this->assertEquals($format->id(), $filter_format->id(), "filter_format_load: Proper format id for text format $format_label.");
|
||||
$this->assertEquals($format->label(), $filter_format->label(), "filter_format_load: Proper title for text format $format_label.");
|
||||
$this->assertEquals($format->get('weight'), $filter_format->get('weight'), "filter_format_load: Proper weight for text format $format_label.");
|
||||
// Check that the filter was created in site default language.
|
||||
$this->assertEquals($default_langcode, $format->language()->getId(), new FormattableMarkup('filter_format_load: Proper language code for text format %format.', $t_args));
|
||||
$this->assertEquals($default_langcode, $format->language()->getId(), "filter_format_load: Proper language code for text format $format_label.");
|
||||
|
||||
// Verify the permission exists and has the correct dependencies.
|
||||
$permissions = \Drupal::service('user.permissions')->getPermissions();
|
||||
|
|
|
@ -2,7 +2,6 @@
|
|||
|
||||
namespace Drupal\Tests\media\Kernel;
|
||||
|
||||
use Drupal\Component\Render\FormattableMarkup;
|
||||
use Drupal\language\Entity\ConfigurableLanguage;
|
||||
use Drupal\content_translation\ContentTranslationHandler;
|
||||
|
||||
|
@ -97,11 +96,11 @@ class MediaTranslationTest extends MediaKernelTestBase {
|
|||
foreach ($items as $delta => $item) {
|
||||
$result = $result && $item['value'] == $media_translation->{$source_field_definition->getName()}[$delta]->value;
|
||||
}
|
||||
$this->assertTrue($result, new FormattableMarkup('%language translation field value not correct.', ['%language' => $langcode]));
|
||||
$this->assertSame('public://' . $langcode . '.png', $media_translation->getSource()->getMetadata($media_translation, 'thumbnail_uri'), new FormattableMarkup('%language translation thumbnail metadata attribute is not correct.', ['%language' => $langcode]));
|
||||
$this->assertSame('public://' . $langcode . '.png', $media_translation->get('thumbnail')->entity->getFileUri(), new FormattableMarkup('%language translation thumbnail value is not correct.', ['%language' => $langcode]));
|
||||
$this->assertEquals('Test Thumbnail ' . $langcode, $media_translation->getSource()->getMetadata($media_translation, 'test_thumbnail_alt'), new FormattableMarkup('%language translation thumbnail alt metadata attribute is not correct.', ['%language' => $langcode]));
|
||||
$this->assertSame('Test Thumbnail ' . $langcode, $media_translation->get('thumbnail')->alt, new FormattableMarkup('%language translation thumbnail alt value is not correct.', ['%language' => $langcode]));
|
||||
$this->assertTrue($result, "$langcode translation field value not correct.");
|
||||
$this->assertSame('public://' . $langcode . '.png', $media_translation->getSource()->getMetadata($media_translation, 'thumbnail_uri'), "$langcode translation thumbnail metadata attribute is not correct.");
|
||||
$this->assertSame('public://' . $langcode . '.png', $media_translation->get('thumbnail')->entity->getFileUri(), "$langcode translation thumbnail value is not correct.");
|
||||
$this->assertEquals('Test Thumbnail ' . $langcode, $media_translation->getSource()->getMetadata($media_translation, 'test_thumbnail_alt'), "$langcode translation thumbnail alt metadata attribute is not correct.");
|
||||
$this->assertSame('Test Thumbnail ' . $langcode, $media_translation->get('thumbnail')->alt, "$langcode translation thumbnail alt value is not correct.");
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -2,7 +2,6 @@
|
|||
|
||||
namespace Drupal\Tests\migrate_drupal_ui\Kernel;
|
||||
|
||||
use Drupal\Component\Render\FormattableMarkup;
|
||||
use Drupal\KernelTests\FileSystemModuleDiscoveryDataProviderTrait;
|
||||
use Drupal\Tests\migrate_drupal\Kernel\MigrateDrupalTestBase;
|
||||
|
||||
|
@ -33,7 +32,7 @@ class MigrationLabelExistTest extends MigrateDrupalTestBase {
|
|||
/** @var \Drupal\migrate\Plugin\Migration $migration */
|
||||
foreach ($migrations as $migration) {
|
||||
$migration_id = $migration->getPluginId();
|
||||
$this->assertNotEmpty($migration->label(), new FormattableMarkup('Label found for @migration_id.', ['@migration_id' => $migration_id]));
|
||||
$this->assertNotEmpty($migration->label(), "Label found for $migration_id.");
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -2,7 +2,6 @@
|
|||
|
||||
namespace Drupal\Tests\mysql\Kernel\mysql;
|
||||
|
||||
use Drupal\Component\Render\FormattableMarkup;
|
||||
use Drupal\Core\Command\DbDumpApplication;
|
||||
use Drupal\Core\Config\DatabaseStorage;
|
||||
use Drupal\Core\Database\Database;
|
||||
|
@ -196,9 +195,9 @@ class DbDumpTest extends DriverSpecificKernelTestBase {
|
|||
// The tables should now exist and the schemas should match the originals.
|
||||
foreach ($this->tables as $table) {
|
||||
$this->assertTrue($schema
|
||||
->tableExists($table), new FormattableMarkup('Table @table created by the database script.', ['@table' => $table]));
|
||||
$this->assertSame($this->originalTableSchemas[$table], $this->getTableSchema($table), new FormattableMarkup('The schema for @table was properly restored.', ['@table' => $table]));
|
||||
$this->assertSame($this->originalTableIndexes[$table], $this->getTableIndexes($table), new FormattableMarkup('The indexes for @table were properly restored.', ['@table' => $table]));
|
||||
->tableExists($table), "Table $table created by the database script.");
|
||||
$this->assertSame($this->originalTableSchemas[$table], $this->getTableSchema($table), "The schema for $table was properly restored.");
|
||||
$this->assertSame($this->originalTableIndexes[$table], $this->getTableIndexes($table), "The indexes for $table were properly restored.");
|
||||
}
|
||||
|
||||
// Ensure the test config has been replaced.
|
||||
|
|
|
@ -2,7 +2,6 @@
|
|||
|
||||
namespace Drupal\Tests\node\Kernel;
|
||||
|
||||
use Drupal\Component\Render\FormattableMarkup;
|
||||
use Drupal\Core\Database\Database;
|
||||
use Drupal\node\Entity\Node;
|
||||
|
||||
|
@ -90,7 +89,7 @@ class NodeAccessRecordsTest extends NodeAccessTestBase {
|
|||
$grants = node_test_node_grants($web_user, $op);
|
||||
$altered_grants = $grants;
|
||||
\Drupal::moduleHandler()->alter('node_grants', $altered_grants, $web_user, $op);
|
||||
$this->assertNotEquals($grants, $altered_grants, new FormattableMarkup('Altered the %op grant for a user.', ['%op' => $op]));
|
||||
$this->assertNotEquals($grants, $altered_grants, "Altered the $op grant for a user.");
|
||||
}
|
||||
|
||||
// Check that core does not grant access to an unpublished node when an
|
||||
|
|
|
@ -2,7 +2,6 @@
|
|||
|
||||
namespace Drupal\Tests\node\Kernel;
|
||||
|
||||
use Drupal\Component\Render\FormattableMarkup;
|
||||
use Drupal\KernelTests\Core\Entity\EntityKernelTestBase;
|
||||
use Drupal\node\Entity\Node;
|
||||
use Drupal\node\Entity\NodeType;
|
||||
|
@ -119,35 +118,35 @@ class NodeFieldAccessTest extends EntityKernelTestBase {
|
|||
// Checks on view operations.
|
||||
foreach ($test_users as $account) {
|
||||
$may_view = $node1->{$field}->access('view', $account);
|
||||
$this->assertTrue($may_view, new FormattableMarkup('Any user may view the field @name.', ['@name' => $field]));
|
||||
$this->assertTrue($may_view, "Any user may view the field $field.");
|
||||
}
|
||||
|
||||
// Checks on edit operations.
|
||||
$may_update = $node1->{$field}->access('edit', $page_creator_user);
|
||||
$this->assertFalse($may_update, new FormattableMarkup('Users with permission "edit own page content" is not allowed to the field @name.', ['@name' => $field]));
|
||||
$this->assertFalse($may_update, 'Users with permission "edit own page content" is not allowed to the field ' . $field . '.');
|
||||
$may_update = $node2->{$field}->access('edit', $page_creator_user);
|
||||
$this->assertFalse($may_update, new FormattableMarkup('Users with permission "edit own page content" is not allowed to the field @name.', ['@name' => $field]));
|
||||
$this->assertFalse($may_update, 'Users with permission "edit own page content" is not allowed to the field ' . $field . '.');
|
||||
$may_update = $node2->{$field}->access('edit', $page_manager_user);
|
||||
$this->assertFalse($may_update, new FormattableMarkup('Users with permission "edit any page content" is not allowed to the field @name.', ['@name' => $field]));
|
||||
$this->assertFalse($may_update, 'Users with permission "edit any page content" is not allowed to the field ' . $field . '.');
|
||||
$may_update = $node1->{$field}->access('edit', $page_manager_user);
|
||||
$this->assertFalse($may_update, new FormattableMarkup('Users with permission "edit any page content" is not allowed to the field @name.', ['@name' => $field]));
|
||||
$this->assertFalse($may_update, 'Users with permission "edit any page content" is not allowed to the field ' . $field . '.');
|
||||
$may_update = $node2->{$field}->access('edit', $page_unrelated_user);
|
||||
$this->assertFalse($may_update, new FormattableMarkup('Users not having permission "edit any page content" is not allowed to the field @name.', ['@name' => $field]));
|
||||
$this->assertFalse($may_update, 'Users not having permission "edit any page content" is not allowed to the field ' . $field . '.');
|
||||
$may_update = $node1->{$field}->access('edit', $content_admin_user) && $node3->status->access('edit', $content_admin_user);
|
||||
$this->assertTrue($may_update, new FormattableMarkup('Users with permission "administer nodes" may edit @name fields on all nodes.', ['@name' => $field]));
|
||||
$this->assertTrue($may_update, 'Users with permission "administer nodes" may edit ' . $field . ' fields on all nodes.');
|
||||
}
|
||||
|
||||
foreach ($this->readOnlyFields as $field) {
|
||||
// Check view operation.
|
||||
foreach ($test_users as $account) {
|
||||
$may_view = $node1->{$field}->access('view', $account);
|
||||
$this->assertTrue($may_view, new FormattableMarkup('Any user may view the field @name.', ['@name' => $field]));
|
||||
$this->assertTrue($may_view, "Any user may view the field $field.");
|
||||
}
|
||||
|
||||
// Check edit operation.
|
||||
foreach ($test_users as $account) {
|
||||
$may_view = $node1->{$field}->access('edit', $account);
|
||||
$this->assertFalse($may_view, new FormattableMarkup('No user is not allowed to edit the field @name.', ['@name' => $field]));
|
||||
$this->assertFalse($may_view, "No user is not allowed to edit the field $field.");
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -3,7 +3,6 @@
|
|||
namespace Drupal\Tests\node\Kernel;
|
||||
|
||||
use Drupal\Component\Utility\Html;
|
||||
use Drupal\Component\Render\FormattableMarkup;
|
||||
use Drupal\Core\Render\BubbleableMetadata;
|
||||
use Drupal\node\Entity\Node;
|
||||
use Drupal\node\Entity\NodeType;
|
||||
|
@ -126,7 +125,7 @@ class NodeTokenReplaceTest extends TokenReplaceKernelTestBase {
|
|||
|
||||
foreach ($tests as $input => $expected) {
|
||||
$output = $this->tokenService->replace($input, ['node' => $node], ['language' => $this->interfaceLanguage]);
|
||||
$this->assertEquals($output, $expected, new FormattableMarkup('Node token %token replaced for unpublished node.', ['%token' => $input]));
|
||||
$this->assertEquals($output, $expected, "Node token $input replaced for unpublished node.");
|
||||
}
|
||||
|
||||
// Repeat for a node without a summary.
|
||||
|
|
|
@ -2,7 +2,6 @@
|
|||
|
||||
namespace Drupal\Tests\system\Kernel\Block;
|
||||
|
||||
use Drupal\Component\Render\FormattableMarkup;
|
||||
use Drupal\KernelTests\KernelTestBase;
|
||||
use Drupal\system\Entity\Menu;
|
||||
use Drupal\block\Entity\Block;
|
||||
|
@ -226,7 +225,7 @@ class SystemMenuBlockTest extends KernelTestBase {
|
|||
foreach ($blocks as $id => $block) {
|
||||
$block_build = $block->build();
|
||||
$items = $block_build['#items'] ?? [];
|
||||
$this->assertSame($no_active_trail_expectations[$id], $this->convertBuiltMenuToIdTree($items), new FormattableMarkup('Menu block %id with no active trail renders the expected tree.', ['%id' => $id]));
|
||||
$this->assertSame($no_active_trail_expectations[$id], $this->convertBuiltMenuToIdTree($items), "Menu block $id with no active trail renders the expected tree.");
|
||||
}
|
||||
|
||||
// Scenario 2: test all block instances when there's an active trail.
|
||||
|
@ -278,7 +277,7 @@ class SystemMenuBlockTest extends KernelTestBase {
|
|||
foreach ($blocks as $id => $block) {
|
||||
$block_build = $block->build();
|
||||
$items = $block_build['#items'] ?? [];
|
||||
$this->assertSame($active_trail_expectations[$id], $this->convertBuiltMenuToIdTree($items), new FormattableMarkup('Menu block %id with an active trail renders the expected tree.', ['%id' => $id]));
|
||||
$this->assertSame($active_trail_expectations[$id], $this->convertBuiltMenuToIdTree($items), "Menu block $id with an active trail renders the expected tree.");
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -2,7 +2,6 @@
|
|||
|
||||
namespace Drupal\Tests\system\Kernel\Common;
|
||||
|
||||
use Drupal\Component\Render\FormattableMarkup;
|
||||
use Drupal\Component\Utility\UrlHelper;
|
||||
use Drupal\Core\Cache\Cache;
|
||||
use Drupal\Core\Language\Language;
|
||||
|
@ -33,13 +32,13 @@ class UrlTest extends KernelTestBase {
|
|||
$encoded_path = "%3CSCRIPT%3Ealert%28%27XSS%27%29%3C/SCRIPT%3E";
|
||||
|
||||
$link = Link::fromTextAndUrl($text, Url::fromUserInput('/' . $path))->toString();
|
||||
$this->assertStringContainsString($encoded_path, $link, new FormattableMarkup('XSS attack @path was filtered by \Drupal\Core\Utility\LinkGeneratorInterface::generate().', ['@path' => $path]));
|
||||
$this->assertStringNotContainsString($path, $link, new FormattableMarkup('XSS attack @path was filtered by \Drupal\Core\Utility\LinkGeneratorInterface::generate().', ['@path' => $path]));
|
||||
$this->assertStringContainsString($encoded_path, $link, "XSS attack $path was filtered by \\Drupal\\Core\\Utility\\LinkGeneratorInterface::generate().");
|
||||
$this->assertStringNotContainsString($path, $link, "XSS attack $path was filtered by \\Drupal\\Core\\Utility\\LinkGeneratorInterface::generate().");
|
||||
|
||||
// Test \Drupal\Core\Url.
|
||||
$link = Url::fromUri('base:' . $path)->toString();
|
||||
$this->assertStringContainsString($encoded_path, $link, new FormattableMarkup('XSS attack @path was filtered by #theme', ['@path' => $path]));
|
||||
$this->assertStringNotContainsString($path, $link, new FormattableMarkup('XSS attack @path was filtered by #theme', ['@path' => $path]));
|
||||
$this->assertStringContainsString($encoded_path, $link, "XSS attack $path was filtered by #theme");
|
||||
$this->assertStringNotContainsString($path, $link, "XSS attack $path was filtered by #theme");
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -97,17 +96,17 @@ class UrlTest extends KernelTestBase {
|
|||
$hreflang_override_link['#options']['attributes']['hreflang'] = 'foo';
|
||||
|
||||
$rendered = $renderer->renderRoot($hreflang_link);
|
||||
$this->assertTrue($this->hasAttribute('hreflang', $rendered, $langcode), new FormattableMarkup('hreflang attribute with value @langcode is present on a rendered link when langcode is provided in the render array.', ['@langcode' => $langcode]));
|
||||
$this->assertTrue($this->hasAttribute('hreflang', $rendered, $langcode), "hreflang attribute with value $langcode is present on a rendered link when langcode is provided in the render array.");
|
||||
|
||||
$rendered = $renderer->renderRoot($hreflang_override_link);
|
||||
$this->assertTrue($this->hasAttribute('hreflang', $rendered, 'foo'), new FormattableMarkup('hreflang attribute with value @hreflang is present on a rendered link when @hreflang is provided in the render array.', ['@hreflang' => 'foo']));
|
||||
$this->assertTrue($this->hasAttribute('hreflang', $rendered, 'foo'), 'hreflang attribute with value foo is present on a rendered link when @hreflang is provided in the render array.');
|
||||
|
||||
// Test adding a custom class in links produced by
|
||||
// \Drupal\Core\Utility\LinkGeneratorInterface::generate() and #type 'link'.
|
||||
// Test the link generator.
|
||||
$class_l = $this->randomMachineName();
|
||||
$link_l = Link::fromTextAndUrl($this->randomMachineName(), Url::fromRoute('common_test.destination', [], ['attributes' => ['class' => [$class_l]]]))->toString();
|
||||
$this->assertTrue($this->hasAttribute('class', $link_l, $class_l), new FormattableMarkup('Custom class @class is present on link when requested by Link::toString()', ['@class' => $class_l]));
|
||||
$this->assertTrue($this->hasAttribute('class', $link_l, $class_l), "Custom class $class_l is present on link when requested by Link::toString()");
|
||||
|
||||
// Test #type.
|
||||
$class_theme = $this->randomMachineName();
|
||||
|
@ -122,7 +121,7 @@ class UrlTest extends KernelTestBase {
|
|||
],
|
||||
];
|
||||
$link_theme = $renderer->renderRoot($type_link);
|
||||
$this->assertTrue($this->hasAttribute('class', $link_theme, $class_theme), new FormattableMarkup('Custom class @class is present on link when requested by #type', ['@class' => $class_theme]));
|
||||
$this->assertTrue($this->hasAttribute('class', $link_theme, $class_theme), "Custom class $class_theme is present on link when requested by #type");
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
@ -2,7 +2,6 @@
|
|||
|
||||
namespace Drupal\Tests\system\Kernel\Extension;
|
||||
|
||||
use Drupal\Component\Render\FormattableMarkup;
|
||||
use Drupal\Core\Entity\ContentEntityTypeInterface;
|
||||
use Drupal\Core\Extension\MissingDependencyException;
|
||||
use Drupal\Core\Extension\ModuleUninstallValidatorException;
|
||||
|
@ -71,7 +70,7 @@ class ModuleHandlerTest extends KernelTestBase {
|
|||
protected function assertModuleList(array $expected_values, string $condition): void {
|
||||
$expected_values = array_values(array_unique($expected_values));
|
||||
$enabled_modules = array_keys($this->container->get('module_handler')->getModuleList());
|
||||
$this->assertEquals($expected_values, $enabled_modules, new FormattableMarkup('@condition: extension handler returns correct results', ['@condition' => $condition]));
|
||||
$this->assertEquals($expected_values, $enabled_modules, "$condition: extension handler returns correct results");
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
@ -479,7 +479,7 @@ class FunctionsTest extends KernelTestBase {
|
|||
// thing. We expect a single <ul> with appropriate links contained within
|
||||
// it.
|
||||
$render_array = $base_array;
|
||||
$html = \Drupal::service('renderer')->renderRoot($render_array);
|
||||
$html = (string) \Drupal::service('renderer')->renderRoot($render_array);
|
||||
$dom = Html::load($html);
|
||||
$this->assertEquals(1, $dom->getElementsByTagName('ul')->length, 'One "ul" tag found in the rendered HTML.');
|
||||
$list_elements = $dom->getElementsByTagName('li');
|
||||
|
@ -494,8 +494,8 @@ class FunctionsTest extends KernelTestBase {
|
|||
// sure we get two separate <ul>'s with the appropriate links contained
|
||||
// within each.
|
||||
$render_array = $base_array;
|
||||
$child_html = \Drupal::service('renderer')->renderRoot($render_array['first_child']);
|
||||
$parent_html = \Drupal::service('renderer')->renderRoot($render_array);
|
||||
$child_html = (string) \Drupal::service('renderer')->renderRoot($render_array['first_child']);
|
||||
$parent_html = (string) \Drupal::service('renderer')->renderRoot($render_array);
|
||||
// First check the child HTML.
|
||||
$dom = Html::load($child_html);
|
||||
$this->assertEquals(1, $dom->getElementsByTagName('ul')->length, 'One "ul" tag found in the rendered child HTML.');
|
||||
|
|
|
@ -2,7 +2,6 @@
|
|||
|
||||
namespace Drupal\Tests\system\Kernel\Theme;
|
||||
|
||||
use Drupal\Component\Render\FormattableMarkup;
|
||||
use Drupal\KernelTests\KernelTestBase;
|
||||
use Drupal\Component\Render\MarkupInterface;
|
||||
|
||||
|
@ -58,7 +57,7 @@ class ThemeTest extends KernelTestBase {
|
|||
$types = ['null' => NULL, 'false' => FALSE, 'integer' => 1, 'string' => 'foo', 'empty_string' => ''];
|
||||
foreach ($types as $type => $example) {
|
||||
$output = \Drupal::theme()->render('theme_test_foo', ['foo' => $example]);
|
||||
$this->assertTrue($output instanceof MarkupInterface || is_string($output), new FormattableMarkup('\Drupal::theme() returns an object that implements MarkupInterface or a string for data type @type.', ['@type' => $type]));
|
||||
$this->assertTrue($output instanceof MarkupInterface || is_string($output), "\Drupal::theme() returns an object that implements MarkupInterface or a string for data type $type.");
|
||||
if ($output instanceof MarkupInterface) {
|
||||
$this->assertSame((string) $example, $output->__toString());
|
||||
}
|
||||
|
|
|
@ -3,7 +3,6 @@
|
|||
namespace Drupal\Tests\system\Kernel\Token;
|
||||
|
||||
use Drupal\Core\Url;
|
||||
use Drupal\Component\Render\FormattableMarkup;
|
||||
use Drupal\Component\Utility\Html;
|
||||
use Drupal\Component\Utility\Xss;
|
||||
use Drupal\Core\Render\BubbleableMetadata;
|
||||
|
@ -48,7 +47,7 @@ class TokenReplaceKernelTest extends TokenReplaceKernelTestBase {
|
|||
$input = $test['prefix'] . '[site:name]' . $test['suffix'];
|
||||
$expected = $test['prefix'] . 'Drupal' . $test['suffix'];
|
||||
$output = $this->tokenService->replace($input, [], ['langcode' => $this->interfaceLanguage->getId()]);
|
||||
$this->assertSame($expected, $output, new FormattableMarkup('Token recognized in string %string', ['%string' => $input]));
|
||||
$this->assertSame($expected, $output, "Token recognized in string $input");
|
||||
}
|
||||
|
||||
// Test token replacement when the string contains no tokens.
|
||||
|
@ -125,7 +124,7 @@ class TokenReplaceKernelTest extends TokenReplaceKernelTestBase {
|
|||
foreach ($tests as $input => $expected) {
|
||||
$bubbleable_metadata = new BubbleableMetadata();
|
||||
$output = $this->tokenService->replace($input, [], ['langcode' => $this->interfaceLanguage->getId()], $bubbleable_metadata);
|
||||
$this->assertEquals($expected, $output, new FormattableMarkup('System site information token %token replaced.', ['%token' => $input]));
|
||||
$this->assertEquals($expected, $output, "System site information token $input replaced.");
|
||||
$this->assertEquals($metadata_tests[$input], $bubbleable_metadata);
|
||||
}
|
||||
|
||||
|
@ -171,7 +170,7 @@ class TokenReplaceKernelTest extends TokenReplaceKernelTestBase {
|
|||
|
||||
foreach ($tests as $input => $expected) {
|
||||
$output = $this->tokenService->replace($input, ['date' => $date], ['langcode' => $this->interfaceLanguage->getId()]);
|
||||
$this->assertEquals($expected, $output, new FormattableMarkup('Date token %token replaced.', ['%token' => $input]));
|
||||
$this->assertEquals($expected, $output, "Date token $input replaced.");
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -2,7 +2,6 @@
|
|||
|
||||
namespace Drupal\Tests\taxonomy\Kernel;
|
||||
|
||||
use Drupal\Component\Render\FormattableMarkup;
|
||||
use Drupal\KernelTests\KernelTestBase;
|
||||
use Drupal\taxonomy\Entity\Term;
|
||||
use Drupal\Tests\taxonomy\Traits\TaxonomyTestTrait;
|
||||
|
@ -53,7 +52,7 @@ class LoadMultipleTest extends KernelTestBase {
|
|||
$term_storage = \Drupal::entityTypeManager()->getStorage('taxonomy_term');
|
||||
$terms = $term_storage->loadByProperties(['vid' => $vocabulary->id()]);
|
||||
$count = count($terms);
|
||||
$this->assertEquals(5, $count, new FormattableMarkup('Correct number of terms were loaded. @count terms.', ['@count' => $count]));
|
||||
$this->assertEquals(5, $count, "Correct number of terms were loaded. $count terms.");
|
||||
|
||||
// Load the same terms again by tid.
|
||||
$terms2 = Term::loadMultiple(array_keys($terms));
|
||||
|
|
|
@ -2,7 +2,6 @@
|
|||
|
||||
namespace Drupal\Tests\text\Kernel;
|
||||
|
||||
use Drupal\Component\Render\FormattableMarkup;
|
||||
use Drupal\field\Entity\FieldConfig;
|
||||
use Drupal\filter\Entity\FilterFormat;
|
||||
use Drupal\KernelTests\Core\Entity\EntityKernelTestBase;
|
||||
|
@ -92,7 +91,7 @@ class TextFormatterTest extends EntityKernelTestBase {
|
|||
$build = $entity->get('formatted_text')->view(['type' => $formatter]);
|
||||
\Drupal::service('renderer')->renderRoot($build[0]);
|
||||
$this->assertSame("<p>Hello, world!</p>\n", (string) $build[0]['#markup']);
|
||||
$this->assertEquals(FilterFormat::load('my_text_format')->getCacheTags(), $build[0]['#cache']['tags'], new FormattableMarkup('The @formatter formatter has the expected cache tags when formatting a formatted text field.', ['@formatter' => $formatter]));
|
||||
$this->assertEquals(FilterFormat::load('my_text_format')->getCacheTags(), $build[0]['#cache']['tags'], "The $formatter formatter has the expected cache tags when formatting a formatted text field.");
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -2,7 +2,6 @@
|
|||
|
||||
namespace Drupal\Tests\text\Kernel;
|
||||
|
||||
use Drupal\Component\Render\FormattableMarkup;
|
||||
use Drupal\Core\Entity\Entity\EntityFormDisplay;
|
||||
use Drupal\entity_test\Entity\EntityTest;
|
||||
use Drupal\field\Entity\FieldConfig;
|
||||
|
@ -245,7 +244,7 @@ class TextSummaryTest extends KernelTestBase {
|
|||
*/
|
||||
public function assertTextSummary(string $text, string $expected, ?string $format = NULL, int $size = NULL): void {
|
||||
$summary = text_summary($text, $format, $size);
|
||||
$this->assertSame($expected, $summary, new FormattableMarkup('<pre style="white-space: pre-wrap">@actual</pre> is identical to <pre style="white-space: pre-wrap">@expected</pre>', ['@actual' => $summary, '@expected' => $expected]));
|
||||
$this->assertSame($expected, $summary, '<pre style="white-space: pre-wrap">' . $summary . '</pre> is identical to <pre style="white-space: pre-wrap">' . $expected . '</pre>');
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
@ -2,7 +2,6 @@
|
|||
|
||||
namespace Drupal\Tests\views\Kernel\Handler;
|
||||
|
||||
use Drupal\Component\Render\FormattableMarkup;
|
||||
use Drupal\Core\Entity\EntityTypeInterface;
|
||||
use Drupal\Core\Form\FormState;
|
||||
use Drupal\Tests\block\Traits\BlockCreationTrait;
|
||||
|
@ -73,7 +72,7 @@ class AreaEntityTest extends ViewsKernelTestBase {
|
|||
foreach (array_keys($expected_entities) as $entity) {
|
||||
$this->assertNotEmpty($data['entity_' . $entity], "Views entity '$entity' should have a data area.");
|
||||
// Test that entity_type is set correctly in the area data.
|
||||
$this->assertEquals($data['entity_' . $entity]['area']['entity_type'], $entity, new FormattableMarkup('Correct entity_type set for @entity', ['@entity' => $entity]));
|
||||
$this->assertEquals($data['entity_' . $entity]['area']['entity_type'], $entity, "Correct entity_type set for $entity");
|
||||
}
|
||||
|
||||
$expected_entities = array_filter($entity_types, function (EntityTypeInterface $type) {
|
||||
|
|
|
@ -2,7 +2,6 @@
|
|||
|
||||
namespace Drupal\Tests\views\Kernel\Handler;
|
||||
|
||||
use Drupal\Component\Render\FormattableMarkup;
|
||||
use Drupal\Tests\views\Kernel\ViewsKernelTestBase;
|
||||
use Drupal\views\Views;
|
||||
|
||||
|
@ -47,11 +46,11 @@ class FieldCounterTest extends ViewsKernelTestBase {
|
|||
$view->preview();
|
||||
|
||||
$counter = $view->style_plugin->getField(0, 'counter');
|
||||
$this->assertEquals('1', $counter, new FormattableMarkup('Make sure the expected number (@expected) patches with the rendered number (@counter)', ['@expected' => 1, '@counter' => $counter]));
|
||||
$this->assertEquals('1', $counter, "Make sure the expected number (1) patches with the rendered number ($counter)");
|
||||
$counter = $view->style_plugin->getField(1, 'counter');
|
||||
$this->assertEquals('2', $counter, new FormattableMarkup('Make sure the expected number (@expected) patches with the rendered number (@counter)', ['@expected' => 2, '@counter' => $counter]));
|
||||
$this->assertEquals('2', $counter, "Make sure the expected number (2) patches with the rendered number ($counter)");
|
||||
$counter = $view->style_plugin->getField(2, 'counter');
|
||||
$this->assertEquals('3', $counter, new FormattableMarkup('Make sure the expected number (@expected) patches with the rendered number (@counter)', ['@expected' => 3, '@counter' => $counter]));
|
||||
$this->assertEquals('3', $counter, "Make sure the expected number (3) patches with the rendered number ($counter)");
|
||||
$view->destroy();
|
||||
$view->storage->invalidateCaches();
|
||||
|
||||
|
@ -76,13 +75,13 @@ class FieldCounterTest extends ViewsKernelTestBase {
|
|||
|
||||
$counter = $view->style_plugin->getField(0, 'counter');
|
||||
$expected_number = 0 + $rand_start;
|
||||
$this->assertEquals((string) $expected_number, $counter, new FormattableMarkup('Make sure the expected number (@expected) patches with the rendered number (@counter)', ['@expected' => $expected_number, '@counter' => $counter]));
|
||||
$this->assertEquals((string) $expected_number, $counter, "Make sure the expected number ($expected_number) patches with the rendered number ($counter)");
|
||||
$counter = $view->style_plugin->getField(1, 'counter');
|
||||
$expected_number = 1 + $rand_start;
|
||||
$this->assertEquals((string) $expected_number, $counter, new FormattableMarkup('Make sure the expected number (@expected) patches with the rendered number (@counter)', ['@expected' => $expected_number, '@counter' => $counter]));
|
||||
$this->assertEquals((string) $expected_number, $counter, "Make sure the expected number ($expected_number) patches with the rendered number ($counter)");
|
||||
$counter = $view->style_plugin->getField(2, 'counter');
|
||||
$expected_number = 2 + $rand_start;
|
||||
$this->assertEquals((string) $expected_number, $counter, new FormattableMarkup('Make sure the expected number (@expected) patches with the rendered number (@counter)', ['@expected' => $expected_number, '@counter' => $counter]));
|
||||
$this->assertEquals((string) $expected_number, $counter, "Make sure the expected number ($expected_number) patches with the rendered number ($counter)");
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
@ -233,7 +233,7 @@ class ModuleTest extends ViewsKernelTestBase {
|
|||
[$plugin_type, $plugin_id] = explode(':', $key);
|
||||
$plugin_def = $this->container->get("plugin.manager.views.$plugin_type")->getDefinition($plugin_id);
|
||||
|
||||
$this->assertTrue(isset($plugin_list[$key]), new FormattableMarkup('The expected @key plugin list key was found.', ['@key' => $key]));
|
||||
$this->assertTrue(isset($plugin_list[$key]), "The expected $key plugin list key was found.");
|
||||
$plugin_details = $plugin_list[$key];
|
||||
|
||||
$this->assertEquals($plugin_type, $plugin_details['type'], 'The expected plugin type was found.');
|
||||
|
|
|
@ -2,7 +2,6 @@
|
|||
|
||||
namespace Drupal\Tests\views\Kernel\Plugin;
|
||||
|
||||
use Drupal\Component\Render\FormattableMarkup;
|
||||
use Drupal\Tests\views\Kernel\ViewsKernelTestBase;
|
||||
use Drupal\views_test_data\Plugin\views\display_extender\DisplayExtenderTest as DisplayExtenderTestData;
|
||||
use Drupal\views\Views;
|
||||
|
@ -54,7 +53,7 @@ class DisplayExtenderTest extends ViewsKernelTestBase {
|
|||
|
||||
foreach ($view->displayHandlers as $id => $display) {
|
||||
$this->assertArrayHasKey($id, $errors);
|
||||
$this->assertContains('Display extender test error.', $errors[$id], new FormattableMarkup('Error message found for @id display', ['@id' => $id]));
|
||||
$this->assertContains('Display extender test error.', $errors[$id], "Error message found for $id display");
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -2,7 +2,6 @@
|
|||
|
||||
namespace Drupal\Tests\views\Kernel\Plugin;
|
||||
|
||||
use Drupal\Component\Render\FormattableMarkup;
|
||||
use Drupal\views\Views;
|
||||
use Drupal\views\ViewExecutable;
|
||||
|
||||
|
@ -70,7 +69,7 @@ class StyleMappingTest extends StyleTestBase {
|
|||
// separated by ':'.
|
||||
$expected_result = $name . ':' . $data_set[$count][$field_id];
|
||||
$actual_result = (string) $field;
|
||||
$this->assertSame($expected_result, $actual_result, new FormattableMarkup('The fields were mapped successfully: %name => %field_id', ['%name' => $name, '%field_id' => $field_id]));
|
||||
$this->assertSame($expected_result, $actual_result, "The fields were mapped successfully: $name => $field_id");
|
||||
}
|
||||
|
||||
$count++;
|
||||
|
|
|
@ -2,7 +2,6 @@
|
|||
|
||||
namespace Drupal\Tests\views\Kernel;
|
||||
|
||||
use Drupal\Component\Render\FormattableMarkup;
|
||||
use Drupal\entity_test\Entity\EntityTestMul;
|
||||
use Drupal\field\Entity\FieldConfig;
|
||||
use Drupal\field\Entity\FieldStorageConfig;
|
||||
|
@ -132,8 +131,9 @@ class QueryGroupByTest extends ViewsKernelTestBase {
|
|||
foreach ($view->result as $item) {
|
||||
$results[$item->entity_test_name] = $item->id;
|
||||
}
|
||||
$this->assertEquals($values[0], $results['name1'], new FormattableMarkup('Aggregation with @aggregation_function and groupby name: name1 returned the expected amount of results', ['@aggregation_function' => $aggregation_function ?? 'NULL']));
|
||||
$this->assertEquals($values[1], $results['name2'], new FormattableMarkup('Aggregation with @aggregation_function and groupby name: name2 returned the expected amount of results', ['@aggregation_function' => $aggregation_function ?? 'NULL']));
|
||||
$aggregation_function ??= 'NULL';
|
||||
$this->assertEquals($values[0], $results['name1'], "Aggregation with $aggregation_function and groupby name: name1 returned the expected amount of results");
|
||||
$this->assertEquals($values[1], $results['name2'], "Aggregation with $aggregation_function and groupby name: name2 returned the expected amount of results");
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
@ -2,7 +2,6 @@
|
|||
|
||||
namespace Drupal\Tests\views\Kernel;
|
||||
|
||||
use Drupal\Component\Render\FormattableMarkup;
|
||||
use Drupal\Core\Render\BubbleableMetadata;
|
||||
use Drupal\views\Tests\ViewTestData;
|
||||
use Drupal\views\Views;
|
||||
|
@ -65,7 +64,7 @@ class TokenReplaceTest extends ViewsKernelTestBase {
|
|||
foreach ($expected as $token => $expected_output) {
|
||||
$bubbleable_metadata = new BubbleableMetadata();
|
||||
$output = $token_handler->replace($token, ['view' => $view], [], $bubbleable_metadata);
|
||||
$this->assertSame($expected_output, $output, new FormattableMarkup('Token %token replaced correctly.', ['%token' => $token]));
|
||||
$this->assertSame($expected_output, $output, "Token $token replaced correctly.");
|
||||
$this->assertEquals($metadata_tests[$token], $bubbleable_metadata);
|
||||
}
|
||||
}
|
||||
|
@ -156,7 +155,7 @@ class TokenReplaceTest extends ViewsKernelTestBase {
|
|||
|
||||
foreach ($expected as $token => $expected_output) {
|
||||
$output = $token_handler->replace($token, ['view' => $view]);
|
||||
$this->assertSame($expected_output, $output, new FormattableMarkup('Token %token replaced correctly.', ['%token' => $token]));
|
||||
$this->assertSame($expected_output, $output, "Token $token replaced correctly.");
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -175,7 +174,7 @@ class TokenReplaceTest extends ViewsKernelTestBase {
|
|||
|
||||
foreach ($expected as $token => $expected_output) {
|
||||
$output = $token_handler->replace($token, ['view' => $view]);
|
||||
$this->assertSame($expected_output, $output, new FormattableMarkup('Token %token replaced correctly.', ['%token' => $token]));
|
||||
$this->assertSame($expected_output, $output, "Token $token replaced correctly.");
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -2,7 +2,6 @@
|
|||
|
||||
namespace Drupal\Tests\views\Kernel;
|
||||
|
||||
use Drupal\Component\Render\FormattableMarkup;
|
||||
use Drupal\comment\Tests\CommentTestTrait;
|
||||
use Drupal\Component\Utility\Xss;
|
||||
use Drupal\node\Entity\NodeType;
|
||||
|
@ -134,7 +133,7 @@ class ViewExecutableTest extends ViewsKernelTestBase {
|
|||
if ($type == 'relationship') {
|
||||
continue;
|
||||
}
|
||||
$this->assertGreaterThan(0, count($view->$type), new FormattableMarkup('Make sure a %type instance got instantiated.', ['%type' => $type]));
|
||||
$this->assertGreaterThan(0, count($view->$type), "Make sure a $type instance got instantiated.");
|
||||
}
|
||||
|
||||
// initHandlers() should create display handlers automatically as well.
|
||||
|
@ -448,7 +447,7 @@ class ViewExecutableTest extends ViewsKernelTestBase {
|
|||
$match = function ($value) use ($display) {
|
||||
return str_contains($value, $display->display['display_title']);
|
||||
};
|
||||
$this->assertNotEmpty(array_filter($validate[$id], $match), new FormattableMarkup('Error message found for @id display', ['@id' => $id]));
|
||||
$this->assertNotEmpty(array_filter($validate[$id], $match), "Error message found for $id display");
|
||||
$count++;
|
||||
}
|
||||
|
||||
|
|
|
@ -2,7 +2,6 @@
|
|||
|
||||
namespace Drupal\Tests\views\Kernel;
|
||||
|
||||
use Drupal\Component\Render\FormattableMarkup;
|
||||
use Drupal\Core\Entity\EntityTypeInterface;
|
||||
use Drupal\views\Entity\View;
|
||||
use Drupal\views\Plugin\views\display\Page;
|
||||
|
@ -85,7 +84,7 @@ class ViewStorageTest extends ViewsKernelTestBase {
|
|||
// expected properties.
|
||||
$this->assertInstanceOf(View::class, $view);
|
||||
foreach ($this->configProperties as $property) {
|
||||
$this->assertNotNull($view->get($property), new FormattableMarkup('Property: @property loaded onto View.', ['@property' => $property]));
|
||||
$this->assertNotNull($view->get($property), "Property: $property loaded onto View.");
|
||||
}
|
||||
|
||||
// Check the displays have been loaded correctly from config display data.
|
||||
|
@ -101,7 +100,7 @@ class ViewStorageTest extends ViewsKernelTestBase {
|
|||
// exists.
|
||||
$original_options = $data['display'][$key];
|
||||
foreach ($original_options as $orig_key => $value) {
|
||||
$this->assertSame($display[$orig_key], $value, new FormattableMarkup('@key is identical to saved data', ['@key' => $key]));
|
||||
$this->assertSame($display[$orig_key], $value, "$key is identical to saved data");
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -120,7 +119,7 @@ class ViewStorageTest extends ViewsKernelTestBase {
|
|||
$this->assertInstanceOf(View::class, $created);
|
||||
// Check that the View contains all of the properties.
|
||||
foreach ($this->configProperties as $property) {
|
||||
$this->assertTrue(property_exists($created, $property), new FormattableMarkup('Property: @property created on View.', ['@property' => $property]));
|
||||
$this->assertTrue(property_exists($created, $property), "Property: $property created on View.");
|
||||
}
|
||||
|
||||
// Create a new View instance with config values.
|
||||
|
@ -137,8 +136,8 @@ class ViewStorageTest extends ViewsKernelTestBase {
|
|||
|
||||
// Test all properties except displays.
|
||||
foreach ($properties as $property) {
|
||||
$this->assertNotNull($created->get($property), new FormattableMarkup('Property: @property created on View.', ['@property' => $property]));
|
||||
$this->assertSame($values[$property], $created->get($property), new FormattableMarkup('Property value: @property matches configuration value.', ['@property' => $property]));
|
||||
$this->assertNotNull($created->get($property), "Property: $property created on View.");
|
||||
$this->assertSame($values[$property], $created->get($property), "Property value: $property matches configuration value.");
|
||||
}
|
||||
|
||||
// Check the UUID of the loaded View.
|
||||
|
@ -209,14 +208,14 @@ class ViewStorageTest extends ViewsKernelTestBase {
|
|||
$random_title = $this->randomMachineName();
|
||||
|
||||
$id = $view->addDisplay('page', $random_title);
|
||||
$this->assertEquals('page_1', $id, new FormattableMarkup('Make sure the first display (%id_new) has the expected ID (%id)', ['%id_new' => $id, '%id' => 'page_1']));
|
||||
$this->assertEquals('page_1', $id, "Make sure the first display ($id) has the expected ID (page_1)");
|
||||
$display = $view->get('display');
|
||||
$this->assertEquals($random_title, $display[$id]['display_title']);
|
||||
|
||||
$random_title = $this->randomMachineName();
|
||||
$id = $view->addDisplay('page', $random_title);
|
||||
$display = $view->get('display');
|
||||
$this->assertEquals('page_2', $id, new FormattableMarkup('Make sure the second display (%id_new) has the expected ID (%id)', ['%id_new' => $id, '%id' => 'page_2']));
|
||||
$this->assertEquals('page_2', $id, "Make sure the second display ($id) has the expected ID (page_2)");
|
||||
$this->assertEquals($random_title, $display[$id]['display_title']);
|
||||
|
||||
$id = $view->addDisplay('page');
|
||||
|
@ -325,14 +324,14 @@ class ViewStorageTest extends ViewsKernelTestBase {
|
|||
];
|
||||
|
||||
foreach ($config_properties as $property) {
|
||||
$this->assertSame($view->storage->get($property), $copy->get($property), new FormattableMarkup('@property property is identical.', ['@property' => $property]));
|
||||
$this->assertSame($view->storage->get($property), $copy->get($property), "$property property is identical.");
|
||||
}
|
||||
|
||||
// Check the displays are the same.
|
||||
$copy_display = $copy->get('display');
|
||||
foreach ($view->storage->get('display') as $id => $display) {
|
||||
// assertIdentical will not work here.
|
||||
$this->assertEquals($copy_display[$id], $display, new FormattableMarkup('The @display display has been copied correctly.', ['@display' => $id]));
|
||||
$this->assertEquals($copy_display[$id], $display, "The $id display has been copied correctly.");
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -2,7 +2,6 @@
|
|||
|
||||
namespace Drupal\Tests\views\Kernel;
|
||||
|
||||
use Drupal\Component\Render\FormattableMarkup;
|
||||
use Drupal\Core\Render\RenderContext;
|
||||
use Drupal\views\Form\ViewsFormMainForm;
|
||||
use Drupal\views\Views;
|
||||
|
@ -78,7 +77,7 @@ class ViewsHooksTest extends ViewsKernelTestBase {
|
|||
|
||||
// Test each hook is found in the implementations array and is invoked.
|
||||
foreach (static::$hooks as $hook => $type) {
|
||||
$this->assertTrue($this->moduleHandler->hasImplementations($hook, 'views_test_data'), new FormattableMarkup('The hook @hook was registered.', ['@hook' => $hook]));
|
||||
$this->assertTrue($this->moduleHandler->hasImplementations($hook, 'views_test_data'), "The hook $hook was registered.");
|
||||
|
||||
if ($hook == 'views_post_render') {
|
||||
$this->moduleHandler->invoke('views_test_data', $hook, [$view, &$view->display_handler->output, $view->display_handler->getPlugin('cache')]);
|
||||
|
@ -99,7 +98,7 @@ class ViewsHooksTest extends ViewsKernelTestBase {
|
|||
$this->moduleHandler->invoke('views_test_data', $hook);
|
||||
}
|
||||
|
||||
$this->assertTrue($this->container->get('state')->get('views_hook_test_' . $hook), new FormattableMarkup('The %hook hook was invoked.', ['%hook' => $hook]));
|
||||
$this->assertTrue($this->container->get('state')->get('views_hook_test_' . $hook), "The $hook hook was invoked.");
|
||||
// Reset the module implementations cache, so we ensure that the
|
||||
// .views.inc file is loaded actively.
|
||||
$this->moduleHandler->resetImplementations();
|
||||
|
|
Loading…
Reference in New Issue