Commit fd5fbe16 authored by catch's avatar catch

Issue #3123120 by mondrake, mrinalini9, ridhimaabrol24, longwave, catch:...

Issue #3123120 by mondrake, mrinalini9, ridhimaabrol24, longwave, catch: [backport] Properly deprecate AssertLegacyTrait::pass
parent 856b81f0
......@@ -186,7 +186,7 @@ public function testBigPipe() {
$this->assertRaw('</body>', 'Closing body tag present.');
$this->pass('Verifying BigPipe assets are present…', 'Debug');
// Verifying BigPipe assets are present.
$this->assertFalse(empty($this->getDrupalSettings()), 'drupalSettings present.');
$this->assertContains('big_pipe/big_pipe', explode(',', $this->getDrupalSettings()['ajaxPageState']['libraries']), 'BigPipe asset library is present.');
......@@ -205,7 +205,8 @@ public function testBigPipe() {
$this->drupalGet(Url::fromUri('base:non-existing-path'));
// Simulate development.
$this->pass('Verifying BigPipe provides useful error output when an error occurs while rendering a placeholder if verbose error logging is enabled.', 'Debug');
// Verifying BigPipe provides useful error output when an error occurs
// while rendering a placeholder if verbose error logging is enabled.
$this->config('system.logging')->set('error_level', ERROR_REPORTING_DISPLAY_VERBOSE)->save();
$this->drupalGet(Url::fromRoute('big_pipe_test'));
// The 'edge_case__html_exception' case throws an exception.
......@@ -259,13 +260,13 @@ public function testBigPipeNoJs() {
$cases['exception__embedded_response']->bigPipePlaceholderId => NULL,
]);
$this->pass('Verifying there are no BigPipe placeholders & replacements…', 'Debug');
// Verifying there are no BigPipe placeholders & replacements.
$this->assertEqual('<none>', $this->drupalGetHeader('BigPipe-Test-Placeholders'));
$this->pass('Verifying BigPipe start/stop signals are absent…', 'Debug');
// Verifying BigPipe start/stop signals are absent.
$this->assertNoRaw(BigPipe::START_SIGNAL, 'BigPipe start signal absent.');
$this->assertNoRaw(BigPipe::STOP_SIGNAL, 'BigPipe stop signal absent.');
$this->pass('Verifying BigPipe assets are absent…', 'Debug');
// Verifying BigPipe assets are absent.
$this->assertTrue(!isset($this->getDrupalSettings()['bigPipePlaceholderIds']) && empty($this->getDrupalSettings()['ajaxPageState']), 'BigPipe drupalSettings and BigPipe asset library absent.');
$this->assertRaw('</body>', 'Closing body tag present.');
......@@ -274,7 +275,8 @@ public function testBigPipeNoJs() {
$this->drupalGet(Url::fromUri('base:non-existing-path'));
// Simulate development.
$this->pass('Verifying BigPipe provides useful error output when an error occurs while rendering a placeholder if verbose error logging is enabled.', 'Debug');
// Verifying BigPipe provides useful error output when an error occurs
// while rendering a placeholder if verbose error logging is enabled.
$this->config('system.logging')->set('error_level', ERROR_REPORTING_DISPLAY_VERBOSE)->save();
$this->drupalGet(Url::fromRoute('big_pipe_test'));
// The 'edge_case__html_exception' case throws an exception.
......@@ -322,7 +324,6 @@ public function testBigPipeMultiOccurrencePlaceholders() {
}
protected function assertBigPipeResponseHeadersPresent() {
$this->pass('Verifying BigPipe response headers…', 'Debug');
// Check that Cache-Control header set to "private".
$this->assertSession()->responseHeaderContains('Cache-Control', 'private');
$this->assertEqual('no-store, content="BigPipe/1.0"', $this->drupalGetHeader('Surrogate-Control'));
......@@ -337,10 +338,10 @@ protected function assertBigPipeResponseHeadersPresent() {
* markup.
*/
protected function assertBigPipeNoJsPlaceholders(array $expected_big_pipe_nojs_placeholders) {
$this->pass('Verifying BigPipe no-JS placeholders & replacements…', 'Debug');
$this->assertSetsEqual(array_keys($expected_big_pipe_nojs_placeholders), array_map('rawurldecode', explode(' ', $this->drupalGetHeader('BigPipe-Test-No-Js-Placeholders'))));
foreach ($expected_big_pipe_nojs_placeholders as $big_pipe_nojs_placeholder => $expected_replacement) {
$this->pass('Checking whether the replacement for the BigPipe no-JS placeholder "' . $big_pipe_nojs_placeholder . '" is present:');
// Checking whether the replacement for the BigPipe no-JS placeholder
// $big_pipe_nojs_placeholder is present.
$this->assertNoRaw($big_pipe_nojs_placeholder);
if ($expected_replacement !== NULL) {
$this->assertRaw($expected_replacement);
......@@ -358,12 +359,10 @@ protected function assertBigPipeNoJsPlaceholders(array $expected_big_pipe_nojs_p
* defined in the order that they are expected to be rendered & streamed.
*/
protected function assertBigPipePlaceholders(array $expected_big_pipe_placeholders, array $expected_big_pipe_placeholder_stream_order) {
$this->pass('Verifying BigPipe placeholders & replacements…', 'Debug');
$this->assertSetsEqual(array_keys($expected_big_pipe_placeholders), explode(' ', $this->drupalGetHeader('BigPipe-Test-Placeholders')));
$placeholder_positions = [];
$placeholder_replacement_positions = [];
foreach ($expected_big_pipe_placeholders as $big_pipe_placeholder_id => $expected_ajax_response) {
$this->pass('BigPipe placeholder: ' . $big_pipe_placeholder_id, 'Debug');
// Verify expected placeholder.
$expected_placeholder_html = '<span data-big-pipe-placeholder-id="' . $big_pipe_placeholder_id . '"></span>';
$this->assertRaw($expected_placeholder_html, 'BigPipe placeholder for placeholder ID "' . $big_pipe_placeholder_id . '" found.');
......@@ -396,14 +395,15 @@ protected function assertBigPipePlaceholders(array $expected_big_pipe_placeholde
$this->assertSetsEqual(array_keys($expected_big_pipe_placeholders_with_replacements), array_values($placeholder_replacement_positions));
$this->assertEqual(count($expected_big_pipe_placeholders_with_replacements), preg_match_all('/' . preg_quote('<script type="application/vnd.drupal-ajax" data-big-pipe-replacement-for-placeholder-with-id="', '/') . '/', $this->getSession()->getPage()->getContent()));
$this->pass('Verifying BigPipe start/stop signals…', 'Debug');
// Verifying BigPipe start/stop signals.
$this->assertRaw(BigPipe::START_SIGNAL, 'BigPipe start signal present.');
$this->assertRaw(BigPipe::STOP_SIGNAL, 'BigPipe stop signal present.');
$start_signal_position = strpos($this->getSession()->getPage()->getContent(), BigPipe::START_SIGNAL);
$stop_signal_position = strpos($this->getSession()->getPage()->getContent(), BigPipe::STOP_SIGNAL);
$this->assertTrue($start_signal_position < $stop_signal_position, 'BigPipe start signal appears before stop signal.');
$this->pass('Verifying BigPipe placeholder replacements and start/stop signals were streamed in the correct order…', 'Debug');
// Verifying BigPipe placeholder replacements and start/stop signals were
// streamed in the correct order.
$expected_stream_order = array_keys($expected_big_pipe_placeholders_with_replacements);
array_unshift($expected_stream_order, BigPipe::START_SIGNAL);
array_push($expected_stream_order, BigPipe::STOP_SIGNAL);
......
......@@ -292,7 +292,6 @@ protected function assertBlockRenderedWithExpectedCacheability(array $expected_k
// Check that the expected cacheability metadata is present in:
// - the built render array;
$this->pass('Built render array');
$build = $this->getBlockRenderArray();
$this->assertIdentical($expected_keys, $build['#cache']['keys']);
$this->assertIdentical($expected_contexts, $build['#cache']['contexts']);
......@@ -300,10 +299,8 @@ protected function assertBlockRenderedWithExpectedCacheability(array $expected_k
$this->assertIdentical($expected_max_age, $build['#cache']['max-age']);
$this->assertFalse(isset($build['#create_placeholder']));
// - the rendered render array;
$this->pass('Rendered render array');
$this->renderer->renderRoot($build);
// - the render cache item.
$this->pass('Render cache item');
$final_cache_contexts = Cache::mergeContexts($expected_contexts, $required_cache_contexts);
$cid = implode(':', $expected_keys) . ':' . implode(':', \Drupal::service('cache_contexts_manager')->convertTokensToKeys($final_cache_contexts)->getKeys());
$cache_item = $this->container->get('cache.render')->get($cid);
......
......@@ -204,7 +204,7 @@ public function testFailedBlockCreation() {
$this->fail('Expected exception has not been thrown.');
}
catch (\Exception $e) {
$this->pass('Expected exception has been thrown.');
// Expected exception; just continue testing.
}
$connection = Database::getConnection();
......
......@@ -118,12 +118,10 @@ protected function doTestBasicTranslation() {
$entity->addTranslation('it', $values);
try {
$message = 'Blocks can have translations with the same "info" value.';
$entity->save();
$this->pass($message);
}
catch (\Exception $e) {
$this->fail($message);
$this->fail('Blocks can have translations with the same "info" value.');
}
// Check that the translate operation link is shown.
......
......@@ -33,15 +33,10 @@ protected function setUp(): void {
* Tests creation of block content stubs with no block_content_type available.
*/
public function testStubFailure() {
$message = 'Expected MigrateException thrown when no bundles exist.';
try {
$this->createEntityStub('block_content');
$this->fail($message);
}
catch (MigrateException $e) {
$this->pass($message);
$this->assertEqual('Stubbing failed, no bundles available for entity type: block_content', $e->getMessage());
}
// Expected MigrateException thrown when no bundles exist.
$this->expectException(MigrateException::class);
$this->expectExceptionMessage('Stubbing failed, no bundles available for entity type: block_content');
$this->createEntityStub('block_content');
}
/**
......
......@@ -429,7 +429,6 @@ protected function clickLinkWithXPath($xpath, $arguments = [], $index = 0) {
$urls = $this->xpath($xpath, $arguments);
if (isset($urls[$index])) {
$url_target = $this->getAbsoluteUrl($urls[$index]->getAttribute('href'));
$this->pass(new FormattableMarkup('Clicked link %label (@url_target) from @url_before', ['%label' => $xpath, '@url_target' => $url_target, '@url_before' => $url_before]), 'Browser');
return $this->drupalGet($url_target);
}
$this->fail(new FormattableMarkup('Link %label does not exist on @url_before', ['%label' => $xpath, '@url_before' => $url_before]), 'Browser');
......
......@@ -186,7 +186,7 @@ public function testCommentTypeDeletion() {
$this->fail('Exception not thrown.');
}
catch (\InvalidArgumentException $e) {
$this->pass('Exception thrown if attempting to re-use comment-type from another entity type.');
// Expected exception; just continue testing.
}
// Delete the comment type.
......
......@@ -40,28 +40,23 @@ protected function setUp(): void {
* Tests that comment fields cannot be added entities with non-integer IDs.
*/
public function testCommentFieldNonStringId() {
try {
$bundle = CommentType::create([
'id' => 'foo',
'label' => 'foo',
'description' => '',
'target_entity_type_id' => 'entity_test_string_id',
]);
$bundle->save();
$field_storage = FieldStorageConfig::create([
'field_name' => 'foo',
'entity_type' => 'entity_test_string_id',
'settings' => [
'comment_type' => 'entity_test_string_id',
],
'type' => 'comment',
]);
$field_storage->save();
$this->fail('Did not throw an exception as expected.');
}
catch (\UnexpectedValueException $e) {
$this->pass('Exception thrown when trying to create comment field on Entity Type with string ID.');
}
$this->expectException(\UnexpectedValueException::class);
$bundle = CommentType::create([
'id' => 'foo',
'label' => 'foo',
'description' => '',
'target_entity_type_id' => 'entity_test_string_id',
]);
$bundle->save();
$field_storage = FieldStorageConfig::create([
'field_name' => 'foo',
'entity_type' => 'entity_test_string_id',
'settings' => [
'comment_type' => 'entity_test_string_id',
],
'type' => 'comment',
]);
$field_storage->save();
}
}
......@@ -69,7 +69,7 @@ public function testCRUD() {
$this->fail('EntityMalformedException was thrown.');
}
catch (EntityMalformedException $e) {
$this->pass('EntityMalformedException was thrown.');
// Expected exception; just continue testing.
}
// Verify that an empty entity cannot be saved.
......@@ -78,7 +78,7 @@ public function testCRUD() {
$this->fail('EntityMalformedException was thrown.');
}
catch (EntityMalformedException $e) {
$this->pass('EntityMalformedException was thrown.');
// Expected exception; just continue testing.
}
// Verify that an entity with an empty ID string is considered empty, too.
......@@ -91,7 +91,7 @@ public function testCRUD() {
$this->fail('EntityMalformedException was thrown.');
}
catch (EntityMalformedException $e) {
$this->pass('EntityMalformedException was thrown.');
// Expected exception; just continue testing.
}
// Verify properties on a newly created entity.
......@@ -116,7 +116,6 @@ public function testCRUD() {
// Verify that the entity can be saved.
try {
$status = $config_test->save();
$this->pass('EntityMalformedException was not thrown.');
}
catch (EntityMalformedException $e) {
$this->fail('EntityMalformedException was not thrown.');
......@@ -151,9 +150,6 @@ public function testCRUD() {
]);
try {
$id_length_config_test->save();
$this->pass(new FormattableMarkup("config_test entity with ID length @length was saved.", [
'@length' => strlen($id_length_config_test->id()),
]));
}
catch (ConfigEntityIdLengthException $e) {
$this->fail($e->getMessage());
......@@ -165,9 +161,6 @@ public function testCRUD() {
]);
try {
$id_length_config_test->save();
$this->pass(new FormattableMarkup("config_test entity with ID length @length was saved.", [
'@length' => strlen($id_length_config_test->id()),
]));
}
catch (ConfigEntityIdLengthException $e) {
$this->fail($e->getMessage());
......@@ -185,10 +178,7 @@ public function testCRUD() {
]));
}
catch (ConfigEntityIdLengthException $e) {
$this->pass(new FormattableMarkup("config_test entity with ID length @length exceeding the maximum allowed length of @max failed to save", [
'@length' => strlen($id_length_config_test->id()),
'@max' => static::MAX_ID_LENGTH,
]));
// Expected exception; just continue testing.
}
// Ensure that creating an entity with the same id as an existing one is not
......@@ -202,7 +192,7 @@ public function testCRUD() {
$this->fail('Not possible to overwrite an entity entity.');
}
catch (EntityStorageException $e) {
$this->pass('Not possible to overwrite an entity entity.');
// Expected exception; just continue testing.
}
// Verify that renaming the ID returns correct status and properties.
......
......@@ -29,38 +29,32 @@ public function testConfigSchemaChecker() {
$this->drupalLogin($this->drupalCreateUser(['administer site configuration']));
// Test a non-existing schema.
$msg = 'Expected SchemaIncompleteException thrown';
try {
$this->config('config_schema_test.schemaless')->set('foo', 'bar')->save();
$this->fail($msg);
$this->fail('Expected SchemaIncompleteException thrown');
}
catch (SchemaIncompleteException $e) {
$this->pass($msg);
$this->assertEquals('No schema for config_schema_test.schemaless', $e->getMessage());
}
// Test a valid schema.
$msg = 'Unexpected SchemaIncompleteException thrown';
$config = $this->config('config_test.types')->set('int', 10);
try {
$config->save();
$this->pass($msg);
}
catch (SchemaIncompleteException $e) {
$this->fail($msg);
$this->fail('Unexpected SchemaIncompleteException thrown');
}
// Test an invalid schema.
$msg = 'Expected SchemaIncompleteException thrown';
$config = $this->config('config_test.types')
->set('foo', 'bar')
->set('array', 1);
try {
$config->save();
$this->fail($msg);
$this->fail('Expected SchemaIncompleteException thrown');
}
catch (SchemaIncompleteException $e) {
$this->pass($msg);
$this->assertEquals('Schema errors for config_test.types with the following errors: config_test.types:array variable type is integer but applied schema class is Drupal\Core\Config\Schema\Sequence, config_test.types:foo missing schema', $e->getMessage());
}
......
......@@ -2,7 +2,6 @@
namespace Drupal\Tests\editor\Functional;
use Drupal\Component\Render\FormattableMarkup;
use Drupal\Component\Serialization\Json;
use Drupal\editor\Entity\Editor;
use Drupal\filter\Entity\FilterFormat;
......@@ -282,10 +281,6 @@ public function testInitialSecurity() {
// Log in as each user that may edit the content, and assert the value.
foreach ($expected as $case) {
foreach ($case['users'] as $account) {
$this->pass(new FormattableMarkup('Scenario: sample %sample_id, %format.', [
'%sample_id' => $case['node_id'],
'%format' => $case['format'],
]));
$this->drupalLogin($account);
$this->drupalGet('node/' . $case['node_id'] . '/edit');
$dom_node = $this->xpath('//textarea[@id="edit-body-0-value"]');
......@@ -407,12 +402,6 @@ public function testSwitchingSecurity() {
// Switch to every other text format/editor and verify the results.
foreach ($case['switch_to'] as $format => $expected_filtered_value) {
$this->pass(new FormattableMarkup('Scenario: sample %sample_id, switch from %original_format to %format.', [
'%sample_id' => $case['node_id'],
'%original_format' => $case['format'],
'%format' => $format,
]));
$post = [
'value' => self::$sampleContent,
'original_format_id' => $case['format'],
......
......@@ -71,44 +71,44 @@ public function testEditorFileReferenceFilter() {
$uuid_2 = $image_2->uuid();
$cache_tag_2 = ['file:' . $id_2];
$this->pass('No data-entity-type and no data-entity-uuid attribute.');
// No data-entity-type and no data-entity-uuid attribute.
$input = '<img src="llama.jpg" />';
$output = $test($input);
$this->assertIdentical($input, $output->getProcessedText());
$this->pass('A non-file data-entity-type attribute value.');
// A non-file data-entity-type attribute value.
$input = '<img src="llama.jpg" data-entity-type="invalid-entity-type-value" data-entity-uuid="' . $uuid . '" />';
$output = $test($input);
$this->assertIdentical($input, $output->getProcessedText());
$this->pass('One data-entity-uuid attribute.');
// One data-entity-uuid attribute.
$input = '<img src="llama.jpg" data-entity-type="file" data-entity-uuid="' . $uuid . '" />';
$expected_output = '<img src="/' . $this->siteDirectory . '/files/llama.jpg" data-entity-type="file" data-entity-uuid="' . $uuid . '" />';
$output = $test($input);
$this->assertIdentical($expected_output, $output->getProcessedText());
$this->assertEqual($cache_tag, $output->getCacheTags());
$this->pass('One data-entity-uuid attribute with odd capitalization.');
// One data-entity-uuid attribute with odd capitalization.
$input = '<img src="llama.jpg" data-entity-type="file" DATA-entity-UUID = "' . $uuid . '" />';
$expected_output = '<img src="/' . $this->siteDirectory . '/files/llama.jpg" data-entity-type="file" data-entity-uuid="' . $uuid . '" />';
$output = $test($input);
$this->assertIdentical($expected_output, $output->getProcessedText());
$this->assertEqual($cache_tag, $output->getCacheTags());
$this->pass('One data-entity-uuid attribute on a non-image tag.');
// One data-entity-uuid attribute on a non-image tag.
$input = '<video src="llama.jpg" data-entity-type="file" data-entity-uuid="' . $uuid . '" />';
$expected_output = '<video src="/' . $this->siteDirectory . '/files/llama.jpg" data-entity-type="file" data-entity-uuid="' . $uuid . '"></video>';
$output = $test($input);
$this->assertIdentical($expected_output, $output->getProcessedText());
$this->assertEqual($cache_tag, $output->getCacheTags());
$this->pass('One data-entity-uuid attribute with an invalid value.');
// One data-entity-uuid attribute with an invalid value.
$input = '<img src="llama.jpg" data-entity-type="file" data-entity-uuid="invalid-' . $uuid . '" />';
$output = $test($input);
$this->assertIdentical($input, $output->getProcessedText());
$this->assertEqual([], $output->getCacheTags());
$this->pass('Two different data-entity-uuid attributes.');
// Two different data-entity-uuid attributes.
$input = '<img src="llama.jpg" data-entity-type="file" data-entity-uuid="' . $uuid . '" />';
$input .= '<img src="alpaca.jpg" data-entity-type="file" data-entity-uuid="' . $uuid_2 . '" />';
$expected_output = '<img src="/' . $this->siteDirectory . '/files/llama.jpg" data-entity-type="file" data-entity-uuid="' . $uuid . '" />';
......@@ -117,7 +117,7 @@ public function testEditorFileReferenceFilter() {
$this->assertIdentical($expected_output, $output->getProcessedText());
$this->assertEqual(Cache::mergeTags($cache_tag, $cache_tag_2), $output->getCacheTags());
$this->pass('Two identical data-entity-uuid attributes.');
// Two identical data-entity-uuid attributes.
$input = '<img src="llama.jpg" data-entity-type="file" data-entity-uuid="' . $uuid . '" />';
$input .= '<img src="llama.jpg" data-entity-type="file" data-entity-uuid="' . $uuid . '" />';
$expected_output = '<img src="/' . $this->siteDirectory . '/files/llama.jpg" data-entity-type="file" data-entity-uuid="' . $uuid . '" />';
......
......@@ -90,15 +90,10 @@ public function testColumnUpdate() {
// Now attempt to run automatic updates. An exception should be thrown
// since there is data in the table.
try {
$entity_definition_update_manager = \Drupal::entityDefinitionUpdateManager();
$field_storage_definition = $entity_definition_update_manager->getFieldStorageDefinition('test', 'entity_test_rev');
$entity_definition_update_manager->updateFieldStorageDefinition($field_storage_definition);
$this->fail('Failed to detect a schema change in a field with data.');
}
catch (FieldStorageDefinitionUpdateForbiddenException $e) {
$this->pass('Detected a schema change in a field with data.');
}
$this->expectException(FieldStorageDefinitionUpdateForbiddenException::class);
$entity_definition_update_manager = \Drupal::entityDefinitionUpdateManager();
$field_storage_definition = $entity_definition_update_manager->getFieldStorageDefinition('test', 'entity_test_rev');
$entity_definition_update_manager->updateFieldStorageDefinition($field_storage_definition);
}
}
......@@ -187,8 +187,8 @@ public function testContentEntityReferenceItem() {
$entity->field_test_taxonomy_term = ['target_id' => 'invalid', 'entity' => $term2];
$this->fail('Assigning an invalid item throws an exception.');
}
catch (\InvalidArgumentException $e) {
$this->pass('Assigning an invalid item throws an exception.');
catch (\Exception $e) {
$this->assertInstanceOf(\InvalidArgumentException::class, $e);
}
// Delete terms so we have nothing to reference and try again
......
......@@ -103,7 +103,7 @@ public function testCreateField() {
$this->fail('Cannot create two fields with the same field / bundle combination.');
}
catch (EntityStorageException $e) {
$this->pass('Cannot create two fields with the same field / bundle combination.');
// Expected exception; just continue testing.
}
// Check that the specified field exists.
......@@ -113,7 +113,7 @@ public function testCreateField() {
$this->fail('Cannot create a field with a non-existing storage.');
}
catch (FieldException $e) {
$this->pass('Cannot create a field with a non-existing storage.');
// Expected exception; just continue testing.
}
// TODO: test other failures.
......
......@@ -65,46 +65,25 @@ public function testFieldPluginDefinitionIntegrity() {
foreach ($field_type_manager->getDefinitions() as $definition) {
// Test default field widgets.
if (isset($definition['default_widget'])) {
if (in_array($definition['default_widget'], $available_field_widget_ids)) {
$this->pass(sprintf('Field type %s uses an existing field widget by default.', $definition['id']));
}
else {
$this->fail(sprintf('Field type %s uses a non-existent field widget by default: %s', $definition['id'], $definition['default_widget']));
}
$this->assertContains($definition['default_widget'], $available_field_widget_ids, sprintf('Field type %s uses a non-existent field widget by default: %s', $definition['id'], $definition['default_widget']));
}
// Test default field formatters.
if (isset($definition['default_formatter'])) {
if (in_array($definition['default_formatter'], $available_field_formatter_ids)) {
$this->pass(sprintf('Field type %s uses an existing field formatter by default.', $definition['id']));
}
else {
$this->fail(sprintf('Field type %s uses a non-existent field formatter by default: %s', $definition['id'], $definition['default_formatter']));
}
$this->assertContains($definition['default_formatter'], $available_field_formatter_ids, sprintf('Field type %s uses a non-existent field formatter by default: %s', $definition['id'], $definition['default_formatter']));
}
}
// Test the field widget plugins.
foreach ($field_widget_manager->getDefinitions() as $definition) {
$missing_field_type_ids = array_diff($definition['field_types'], $available_field_type_ids);
if ($missing_field_type_ids) {
$this->fail(sprintf('Field widget %s integrates with non-existent field types: %s', $definition['id'], implode(', ', $missing_field_type_ids)));
}
else {
$this->pass(sprintf('Field widget %s integrates with existing field types.', $definition['id']));
}
$this->assertEmpty($missing_field_type_ids, sprintf('Field widget %s integrates with non-existent field types: %s', $definition['id'], implode(', ', $missing_field_type_ids)));
}
// Test the field formatter plugins.
foreach ($field_formatter_manager->getDefinitions() as $definition) {
$missing_field_type_ids = array_diff($definition['field_types'], $available_field_type_ids);
if ($missing_field_type_ids) {
$this->fail(sprintf('Field formatter %s integrates with non-existent field types: %s', $definition['id'], implode(', ', $missing_field_type_ids)));
}
else {
$this->pass(sprintf('Field formatter %s integrates with existing field types.', $definition['id']));
}
$this->assertEmpty($missing_field_type_ids, sprintf('Field formatter %s integrates with non-existent field types: %s', $definition['id'], implode(', ', $missing_field_type_ids)));
}
}
......
......@@ -80,8 +80,8 @@ public function testCreate() {
FieldStorageConfig::create($field_storage_definition)->save();
$this->fail('Cannot create two fields with the same name.');
}
catch (EntityStorageException $e) {
$this->pass('Cannot create two fields with the same name.');
catch (\Exception $e) {
$this->assertInstanceOf(EntityStorageException::class, $e);
}
// Check that field type is required.
......@@ -93,8 +93,8 @@ public function testCreate() {
FieldStorageConfig::create($field_storage_definition)->save();
$this->fail('Cannot create a field with no type.');
}
catch (FieldException $e) {
$this->pass('Cannot create a field with no type.');
catch (\Exception $e) {
$this->assertInstanceOf(FieldException::class, $e);
}
// Check that field name is required.
......@@ -106,8 +106,8 @@ public function testCreate() {
FieldStorageConfig::create($field_storage_definition)->save();
$this->fail('Cannot create an unnamed field.');
}
catch (FieldException $e) {
$this->pass('Cannot create an unnamed field.');
catch (\Exception $e) {
$this->assertInstanceOf(FieldException::class, $e);
}
// Check that entity type is required.