diff --git a/core/modules/block_content/tests/src/Functional/BlockContentTestBase.php b/core/modules/block_content/tests/src/Functional/BlockContentTestBase.php index 7990ff47f4c9ad2238516b8451b74d013b114290..41f27a800954ef948d4162dcbcdd9825c38a1456 100644 --- a/core/modules/block_content/tests/src/Functional/BlockContentTestBase.php +++ b/core/modules/block_content/tests/src/Functional/BlockContentTestBase.php @@ -57,7 +57,7 @@ abstract class BlockContentTestBase extends BrowserTestBase { protected function setUp(): void { parent::setUp(); if ($this->autoCreateBasicBlockType) { - $this->createBlockContentType('basic', TRUE); + $this->createBlockContentType(['id' => 'basic'], TRUE); } $this->adminUser = $this->drupalCreateUser($this->permissions); @@ -95,9 +95,11 @@ protected function createBlockContent($title = FALSE, $bundle = 'basic', $save = * Creates a block type (bundle). * * @param array|string $values - * The value to create the block content type. If $values is an array - * it should be like: ['id' => 'foo', 'label' => 'Foo']. If $values - * is a string, it will be considered that it represents the label. + * (deprecated) The variable $values as string is deprecated. Provide as an + * array as parameter. The value to create the block content type. If + * $values is an array it should be like: ['id' => 'foo', 'label' => 'Foo']. + * If $values is a string, it will be considered that it represents the + * label. * @param bool $create_body * Whether or not to create the body field * @@ -105,6 +107,9 @@ protected function createBlockContent($title = FALSE, $bundle = 'basic', $save = * Created block type. */ protected function createBlockContentType($values, $create_body = FALSE) { + if (is_string($values)) { + @trigger_error('Using the variable $values as string is deprecated in drupal:11.1.0 and is removed from drupal:12.0.0. Provide an array as parameter. See https://www.drupal.org/node/3473739', E_USER_DEPRECATED); + } if (is_array($values)) { if (!isset($values['id'])) { do { diff --git a/core/modules/block_content/tests/src/Functional/BlockContentTypeTest.php b/core/modules/block_content/tests/src/Functional/BlockContentTypeTest.php index 274bb1b2a7eae25f5921c137b4a83a2c49368010..b36cc10e0e3e97c35d456d29136f257a78c1582b 100644 --- a/core/modules/block_content/tests/src/Functional/BlockContentTypeTest.php +++ b/core/modules/block_content/tests/src/Functional/BlockContentTypeTest.php @@ -102,11 +102,11 @@ public function testBlockContentTypeCreation(): void { $this->assertEquals($block_type->language()->getId(), $default_langcode); // Create block types programmatically. - $this->createBlockContentType('basic', TRUE); + $this->createBlockContentType(['id' => 'basic'], TRUE); $field_definitions = \Drupal::service('entity_field.manager')->getFieldDefinitions('block_content', 'basic'); $this->assertTrue(isset($field_definitions['body']), "Body field for 'basic' block type created when using the testing API to create block content types."); - $this->createBlockContentType('other'); + $this->createBlockContentType(['id' => 'other']); $field_definitions = \Drupal::service('entity_field.manager')->getFieldDefinitions('block_content', 'other'); $this->assertFalse(isset($field_definitions['body']), "Body field for 'other' block type not created when using the testing API to create block content types."); @@ -123,11 +123,11 @@ public function testBlockContentTypeCreation(): void { public function testBlockContentTypeEditing(): void { $this->drupalPlaceBlock('system_breadcrumb_block'); // Now create an initial block-type. - $this->createBlockContentType('basic', TRUE); + $this->createBlockContentType(['id' => 'basic'], TRUE); $this->drupalLogin($this->adminUser); // We need two block types to prevent /block/add redirecting. - $this->createBlockContentType('other'); + $this->createBlockContentType(['id' => 'other']); $field_definitions = \Drupal::service('entity_field.manager')->getFieldDefinitions('block_content', 'other'); $this->assertFalse(isset($field_definitions['body']), 'Body field was not created when using the API to create block content types.'); @@ -174,10 +174,10 @@ public function testBlockContentTypeEditing(): void { */ public function testBlockContentTypeDeletion(): void { // Now create an initial block-type. - $this->createBlockContentType('basic', TRUE); + $this->createBlockContentType(['id' => 'basic'], TRUE); // Create a block type programmatically. - $type = $this->createBlockContentType('foo'); + $type = $this->createBlockContentType(['id' => 'foo']); $this->drupalLogin($this->adminUser); @@ -201,12 +201,12 @@ public function testBlockContentTypeDeletion(): void { */ public function testsBlockContentAddTypes(): void { // Now create an initial block-type. - $this->createBlockContentType('basic', TRUE); + $this->createBlockContentType(['id' => 'basic'], TRUE); $this->drupalLogin($this->adminUser); // Create two block types programmatically. - $this->createBlockContentType('foo'); - $this->createBlockContentType('bar'); + $this->createBlockContentType(['id' => 'foo']); + $this->createBlockContentType(['id' => 'bar']); // Get the content block storage. $storage = $this->container