.../custom_block/Tests/CustomBlockSaveTest.php | 6 ++--- .../custom_block_test/custom_block_test.module | 2 ++ .../system/Tests/Upgrade/BlockUpgradePathTest.php | 26 -------------------- 3 files changed, 5 insertions(+), 29 deletions(-) diff --git a/core/modules/block/custom_block/lib/Drupal/custom_block/Tests/CustomBlockSaveTest.php b/core/modules/block/custom_block/lib/Drupal/custom_block/Tests/CustomBlockSaveTest.php index d4fbb28..405b50c 100644 --- a/core/modules/block/custom_block/lib/Drupal/custom_block/Tests/CustomBlockSaveTest.php +++ b/core/modules/block/custom_block/lib/Drupal/custom_block/Tests/CustomBlockSaveTest.php @@ -75,6 +75,7 @@ public function testImport() { public function testDeterminingChanges() { // Initial creation. $block = $this->createCustomBlock('test_changes'); + $this->assertEqual($block->getChangedTime(), REQUEST_TIME, 'Creating a block sets default "changed" timestamp.'); // Update the block without applying changes. $block->save(); @@ -84,12 +85,11 @@ public function testDeterminingChanges() { $block->info->value = 'updated'; $block->save(); - $this->assertNotEqual($block->getChangedTime(), 0, 'Changed time maintained.'); - // The hook implementations custom_block_test_custom_block_presave() and // custom_block_test_custom_block_update() determine changes and change the - // title. + // title as well as programatically set the 'changed' timestamp. $this->assertEqual($block->label(), 'updated_presave_update', 'Changes have been determined.'); + $this->assertEqual($block->getChangedTime(), 979534800, 'Saving a custom block uses "changed" timestamp set in presave hook.'); // Test the static block load cache to be cleared. $block = custom_block_load($block->id->value); diff --git a/core/modules/block/custom_block/tests/modules/custom_block_test/custom_block_test.module b/core/modules/block/custom_block/tests/modules/custom_block_test/custom_block_test.module index e649f54..277fae3 100644 --- a/core/modules/block/custom_block/tests/modules/custom_block_test/custom_block_test.module +++ b/core/modules/block/custom_block/tests/modules/custom_block_test/custom_block_test.module @@ -47,6 +47,8 @@ function custom_block_test_custom_block_presave(CustomBlock $custom_block) { if (!empty($custom_block->original) && $custom_block->original->info->value == 'test_changes') { if ($custom_block->original->info->value != $custom_block->info->value) { $custom_block->info->value .= '_presave'; + // Drupal 1.0 release. + $custom_block->changed = 979534800; } } } diff --git a/core/modules/system/lib/Drupal/system/Tests/Upgrade/BlockUpgradePathTest.php b/core/modules/system/lib/Drupal/system/Tests/Upgrade/BlockUpgradePathTest.php index 0aca1f7..bde6f60 100644 --- a/core/modules/system/lib/Drupal/system/Tests/Upgrade/BlockUpgradePathTest.php +++ b/core/modules/system/lib/Drupal/system/Tests/Upgrade/BlockUpgradePathTest.php @@ -60,32 +60,6 @@ public function testBlockUpgradeTitleLength() { // Confirm that the custom block cannot be created with title longer than // the maximum number of characters. $this->assertText('Title cannot be longer than 255 characters'); - - $block = $this->createCustomBlock(); - $this->assertNotEqual($block->getChangedTime(), 0, 'Changed time maintained.'); } - /** - * Creates a custom block. - * - * @param string $title - * (optional) Title of block. When no value is given uses a random name. - * Defaults to FALSE. - * @param string $bundle - * (optional) Bundle name. Defaults to 'basic'. - * - * @return Drupal\custom_block\Entity\CustomBlock - * Created custom block. - */ - protected function createCustomBlock($title = FALSE, $bundle = 'basic') { - $title = ($title ? : $this->randomName()); - if ($custom_block = entity_create('custom_block', array( - 'info' => $title, - 'type' => $bundle, - 'langcode' => 'en' - ))) { - $custom_block->save(); - } - return $custom_block; - } }