Loading core/modules/block_content/tests/src/Functional/BlockContentSaveTest.php +1 −2 Original line number Diff line number Diff line Loading @@ -3,7 +3,6 @@ namespace Drupal\Tests\block_content\Functional; use Drupal\block_content\Entity\BlockContent; use Drupal\Core\Database\Database; /** * Tests $block_content->save() for saving content. Loading Loading @@ -38,7 +37,7 @@ protected function setUp(): void { */ public function testImport() { // Custom block ID must be a number that is not in the database. $max_id = Database::getConnection()->query('SELECT MAX(id) FROM {block_content}')->fetchField(); $max_id = (int) \Drupal::entityQueryAggregate('block_content')->aggregate('id', 'max')->execute()[0]['id_max']; $test_id = $max_id + mt_rand(1000, 1000000); $info = $this->randomMachineName(8); $block_array = [ Loading core/modules/block_content/tests/src/Functional/BlockContentTranslationUITest.php +0 −49 Original line number Diff line number Diff line Loading @@ -2,9 +2,7 @@ namespace Drupal\Tests\block_content\Functional; use Drupal\block_content\Entity\BlockContent; use Drupal\block_content\Entity\BlockContentType; use Drupal\Core\Database\Database; use Drupal\Tests\content_translation\Functional\ContentTranslationUITestBase; /** Loading Loading @@ -82,31 +80,6 @@ public function getTranslatorPermissions() { ]); } /** * Creates a custom block. * * @param bool|string $title * (optional) Title of block. When no value is given uses a random name. * Defaults to FALSE. * @param bool|string $bundle * (optional) Bundle name. When no value is given, defaults to * $this->bundle. Defaults to FALSE. * * @return \Drupal\block_content\Entity\BlockContent * Created custom block. */ protected function createBlockContent($title = FALSE, $bundle = FALSE) { $title = $title ?: $this->randomMachineName(); $bundle = $bundle ?: $this->bundle; $block_content = BlockContent::create([ 'info' => $title, 'type' => $bundle, 'langcode' => 'en', ]); $block_content->save(); return $block_content; } /** * {@inheritdoc} */ Loading Loading @@ -158,28 +131,6 @@ protected function doTestBasicTranslation() { $this->assertLinkByHref('block/' . $entity->id() . '/translations'); } /** * Test that no metadata is stored for a disabled bundle. */ public function testDisabledBundle() { // Create a bundle that does not have translation enabled. $disabled_bundle = $this->randomMachineName(); $bundle = BlockContentType::create([ 'id' => $disabled_bundle, 'label' => $disabled_bundle, 'revision' => FALSE, ]); $bundle->save(); // Create a block content for each bundle. $enabled_block_content = $this->createBlockContent(); $this->createBlockContent(FALSE, $bundle->id()); // Make sure that only a single row was inserted into the block table. $rows = Database::getConnection()->query('SELECT * FROM {block_content_field_data} WHERE id = :id', [':id' => $enabled_block_content->id()])->fetchAll(); $this->assertEqual(1, count($rows)); } /** * {@inheritdoc} */ Loading Loading
core/modules/block_content/tests/src/Functional/BlockContentSaveTest.php +1 −2 Original line number Diff line number Diff line Loading @@ -3,7 +3,6 @@ namespace Drupal\Tests\block_content\Functional; use Drupal\block_content\Entity\BlockContent; use Drupal\Core\Database\Database; /** * Tests $block_content->save() for saving content. Loading Loading @@ -38,7 +37,7 @@ protected function setUp(): void { */ public function testImport() { // Custom block ID must be a number that is not in the database. $max_id = Database::getConnection()->query('SELECT MAX(id) FROM {block_content}')->fetchField(); $max_id = (int) \Drupal::entityQueryAggregate('block_content')->aggregate('id', 'max')->execute()[0]['id_max']; $test_id = $max_id + mt_rand(1000, 1000000); $info = $this->randomMachineName(8); $block_array = [ Loading
core/modules/block_content/tests/src/Functional/BlockContentTranslationUITest.php +0 −49 Original line number Diff line number Diff line Loading @@ -2,9 +2,7 @@ namespace Drupal\Tests\block_content\Functional; use Drupal\block_content\Entity\BlockContent; use Drupal\block_content\Entity\BlockContentType; use Drupal\Core\Database\Database; use Drupal\Tests\content_translation\Functional\ContentTranslationUITestBase; /** Loading Loading @@ -82,31 +80,6 @@ public function getTranslatorPermissions() { ]); } /** * Creates a custom block. * * @param bool|string $title * (optional) Title of block. When no value is given uses a random name. * Defaults to FALSE. * @param bool|string $bundle * (optional) Bundle name. When no value is given, defaults to * $this->bundle. Defaults to FALSE. * * @return \Drupal\block_content\Entity\BlockContent * Created custom block. */ protected function createBlockContent($title = FALSE, $bundle = FALSE) { $title = $title ?: $this->randomMachineName(); $bundle = $bundle ?: $this->bundle; $block_content = BlockContent::create([ 'info' => $title, 'type' => $bundle, 'langcode' => 'en', ]); $block_content->save(); return $block_content; } /** * {@inheritdoc} */ Loading Loading @@ -158,28 +131,6 @@ protected function doTestBasicTranslation() { $this->assertLinkByHref('block/' . $entity->id() . '/translations'); } /** * Test that no metadata is stored for a disabled bundle. */ public function testDisabledBundle() { // Create a bundle that does not have translation enabled. $disabled_bundle = $this->randomMachineName(); $bundle = BlockContentType::create([ 'id' => $disabled_bundle, 'label' => $disabled_bundle, 'revision' => FALSE, ]); $bundle->save(); // Create a block content for each bundle. $enabled_block_content = $this->createBlockContent(); $this->createBlockContent(FALSE, $bundle->id()); // Make sure that only a single row was inserted into the block table. $rows = Database::getConnection()->query('SELECT * FROM {block_content_field_data} WHERE id = :id', [':id' => $enabled_block_content->id()])->fetchAll(); $this->assertEqual(1, count($rows)); } /** * {@inheritdoc} */ Loading