diff --git a/linkchecker.test b/linkchecker.test
old mode 100644
new mode 100755
index 81ecaff..8870b15
--- a/linkchecker.test
+++ b/linkchecker.test
@@ -640,3 +640,76 @@ class LinkCheckerImpersonatingUserTestCase extends DrupalWebTestCase {
$this->assertTrue(drupal_save_session(), t('Session saving is enabled.'));
}
}
+
+/**
+ * Tests block updates
+ */
+class LinkCheckerBlockTest extends DrupalWebTestCase {
+
+ public static function getInfo() {
+ return array(
+ 'name' => t('Block link checking and update tests'),
+ 'description' => t('Test Link checker module block integration functionality.'),
+ 'group' => 'Link checker',
+ );
+ }
+
+ public function setUp() {
+ parent::setUp('linkchecker');
+
+ $full_html_format = filter_format_load('full_html');
+ $permissions = array(
+ 'administer blocks',
+ filter_permission_name($full_html_format),
+ );
+
+ $user = $this->drupalCreateUser($permissions);
+ $this->drupalLogin($user);
+
+ }
+
+ /**
+ * Tests block updates.
+ */
+ function testBlockUpdates() {
+ // Set the ignore response codes and behaviour.
+ variable_set('linkchecker_check_links_types', 0);
+ variable_set('linkchecker_scan_blocks', 1);
+ // Repair after 1 fail.
+ variable_set('linkchecker_action_status_code_301', 1);
+ // check after 1 day.
+ variable_set('linkchecker_check_links_interval', 86400);
+ variable_set('linkchecker_ignore_response_codes', '200
+206
+302
+304
+401
+403');
+
+ // Create block.
+ $this->drupalGet('admin/structure/block/add');
+ $edit = array(
+ 'info' => 'dummy_block',
+ 'body[value]' => 'something with google which will 301 back to www',
+ 'body[format]' => 'full_html'
+ );
+ $this->drupalPost(NULL, $edit, t('Save block'));
+
+ // Mark the last updated and fails to force an update.
+ db_update('linkchecker_link')
+ // 3 days ago.
+ ->fields(array(
+ 'last_checked' => REQUEST_TIME - (3 * 86400),
+ 'fail_count' => 2,
+ ))
+ ->execute();
+
+ // Run cron.
+ $this->cronRun();
+
+ // Load the block back up.
+ $block = block_custom_block_get(1);
+ // Verify that google.com rewritten to www.google.com.
+ $this->assertEqual($block['body'], 'something with google which will 301 back to www', format_string('Block body @body had link updated', array('@body' => $block['body'])));
+ }
+}