Public Member Functions | |
setUp () | |
Implementation of setUp(). | |
testBox () | |
Test creating custom block (i.e. | |
testBlock () | |
Test configuring and moving a module-define block to specific regions. | |
Static Public Member Functions | |
static | getInfo () |
Implementation of getInfo(). |
Definition at line 10 of file block.test.
static BlockTestCase::getInfo | ( | ) | [static] |
Implementation of getInfo().
Definition at line 14 of file block.test.
00014 { 00015 return array( 00016 'name' => t('Block functionality'), 00017 'description' => t('Add, edit and delete custom block. Configure and move a module-defined block.'), 00018 'group' => t('Block'), 00019 ); 00020 }
BlockTestCase::setUp | ( | ) |
Implementation of setUp().
Reimplemented from DrupalWebTestCase.
Definition at line 25 of file block.test.
References DrupalWebTestCase::drupalCreateUser(), and DrupalWebTestCase::drupalLogin().
00025 { 00026 parent::setUp(); 00027 00028 // Create and login user 00029 $admin_user = $this->drupalCreateUser(array('administer blocks')); 00030 $this->drupalLogin($admin_user); 00031 }
BlockTestCase::testBlock | ( | ) |
Test configuring and moving a module-define block to specific regions.
Definition at line 72 of file block.test.
References DrupalWebTestCase::assertNoText(), DrupalWebTestCase::assertNotNull(), DrupalWebTestCase::assertText(), DrupalWebTestCase::drupalPost(), and DrupalWebTestCase::randomName().
00072 { 00073 // Select the Navigation block to be configured and moved. 00074 $block = array(); 00075 $block['module'] = 'user'; 00076 $block['delta'] = 1; 00077 $block['title'] = $this->randomName(8); 00078 00079 // Set block title to confirm that interface works and override any custom titles. 00080 $this->drupalPost('admin/build/block/configure/'. $block['module'] .'/'. $block['delta'], array('title' => $block['title']), t('Save block')); 00081 $this->assertText(t('The block configuration has been saved.'), t('Block title set.')); 00082 $bid = db_result(db_query("SELECT bid FROM {blocks} WHERE module = '%s' AND delta = '%s'", array($block['module'], $block['delta']))); 00083 00084 // Check to see if the block was created by checking that it's in the database. 00085 $this->assertNotNull($bid, t('Block found in database')); 00086 00087 // Set the created block to a specific region. 00088 $edit = array(); 00089 $edit[$block['module'] .'_'. $block['delta'] .'[region]'] = 'left'; 00090 $this->drupalPost('admin/build/block', $edit, t('Save blocks')); 00091 00092 // Confirm that the block was moved to the proper region. 00093 // TODO: Implement full region checking. 00094 $this->assertText(t('The block settings have been updated.'), t('Block successfully moved to left region.')); 00095 00096 // Confirm that the block is being displayed. 00097 $this->assertText(t($block['title']), t('Block successfully being displayed on the page.')); 00098 00099 // Set the block to the disabled region. 00100 $edit = array(); 00101 $edit[$block['module'] .'_'. $block['delta'] .'[region]'] = '-1'; 00102 $this->drupalPost('admin/build/block', $edit, t('Save blocks')); 00103 00104 // Confirm that the block was moved to the proper region. 00105 $this->assertText(t('The block settings have been updated.'), t('Block successfully move to disabled region.')); 00106 $this->assertNoText(t($block['title']), t('Block no longer appears on page.')); 00107 00108 // For convenience of developers, put the navigation block back. 00109 $edit = array(); 00110 $edit[$block['module'] .'_'. $block['delta'] .'[region]'] = 'left'; 00111 $this->drupalPost('admin/build/block', $edit, t('Save blocks')); 00112 $this->assertText(t('The block settings have been updated.'), t('Block successfully move to disabled region.')); 00113 00114 $this->drupalPost('admin/build/block/configure/'. $block['module'] .'/'. $block['delta'], array('title' => 'Navigation'), t('Save block')); 00115 $this->assertText(t('The block configuration has been saved.'), t('Block title set.')); 00116 }
BlockTestCase::testBox | ( | ) |
Test creating custom block (i.e.
box), moving it to a specific region and then deleting it.
Definition at line 36 of file block.test.
References DrupalWebTestCase::assertNoText(), DrupalWebTestCase::assertNotNull(), DrupalWebTestCase::assertRaw(), DrupalWebTestCase::assertText(), DrupalWebTestCase::drupalPost(), and DrupalWebTestCase::randomName().
00036 { 00037 // Add a new box by filling out the input form on the admin/build/block/add page. 00038 $box = array(); 00039 $box['info'] = $this->randomName(8); 00040 $box['title'] = $this->randomName(8); 00041 $box['body'] = $this->randomName(32); 00042 $this->drupalPost('admin/build/block/add', $box, t('Save block')); 00043 00044 // Confirm that the box has been created, and then query the created bid. 00045 $this->assertText(t('The block has been created.'), t('Box successfully created.')); 00046 $bid = db_result(db_query("SELECT bid FROM {boxes} WHERE info = '%s'", array($box['info']))); 00047 00048 // Check to see if the box was created by checking that it's in the database.. 00049 $this->assertNotNull($bid, t('Box found in database')); 00050 00051 // Set the created box to a specific region. 00052 // TODO: Implement full region checking. 00053 $edit = array(); 00054 $edit['block_'. $bid .'[region]'] = 'left'; 00055 $this->drupalPost('admin/build/block', $edit, t('Save blocks')); 00056 00057 // Confirm that the box was moved to the proper region. 00058 $this->assertText(t('The block settings have been updated.'), t('Box successfully moved to left region.')); 00059 00060 // Confirm that the box is being displayed. 00061 $this->assertText(t($box['title']), t('Box successfully being displayed on the page.')); 00062 00063 // Delete the created box & verify that it's been deleted and no longer appearing on the page. 00064 $this->drupalPost('admin/build/block/delete/'. $bid, array(), t('Delete')); 00065 $this->assertRaw(t('The block %title has been removed.', array('%title' => $box['info'])), t('Box successfully deleted.')); 00066 $this->assertNoText(t($box['title']), t('Box no longer appears on page.')); 00067 }