public function CacheFlushAdvancedTest::testAddInterfaceAddRemoveElements in CacheFlush 7.3
Test add remove ellement on form.
File
- modules/
cacheflush_advanced/ cacheflush_advanced.test, line 119 - Contains test suite for cacheflush module.
Class
- CacheFlushAdvancedTest
- Defines a test for cacheflush module.
Code
public function testAddInterfaceAddRemoveElements() {
$this
->drupalGet('admin/structure/cacheflush/add');
// Check if row 2 added.
$this
->drupalPost(NULL, array(
'title' => 'Test1',
), t('Add another row'));
$this
->assertFieldByName('advanced_remove_0');
$this
->assertFieldByName('advanced_remove_1');
// Check if row 3 added.
$this
->drupalPost(NULL, array(), t('Add another row'));
$this
->assertFieldByName('advanced_remove_0');
$this
->assertFieldByName('advanced_remove_1');
$this
->assertFieldByName('advanced_remove_2');
// Remove element 2.
$this
->drupalPostAJAX(NULL, array(), 'advanced_remove_1');
$this
->assertFieldByName('advanced_remove_0');
$this
->assertNoFieldByName('advanced_remove_1');
$this
->assertFieldByName('advanced_remove_2');
// Remove element 1.
$this
->drupalPostAJAX(NULL, array(), 'advanced_remove_0');
$this
->assertNoFieldByName('advanced_remove_0');
$this
->assertNoFieldByName('advanced_remove_1');
$this
->assertFieldByName('advanced_remove_2');
// Remove element 3.
$this
->drupalPostAJAX(NULL, array(), 'advanced_remove_2');
$this
->assertNoFieldByName('advanced_remove_0');
$this
->assertNoFieldByName('advanced_remove_1');
$this
->assertNoFieldByName('advanced_remove_2');
// Add new row and save the entity.
$this
->drupalPost(NULL, array(), t('Add another row'));
$this
->assertRaw(t('Remove'));
$edit = array(
'title' => 'AdvancedCIDTest',
'vertical_tabs_advance[cacheflush_advanced_table][1][wildcard]' => TRUE,
'vertical_tabs_advance[cacheflush_advanced_table][1][cid]' => 'AdvancedTestCID',
'vertical_tabs_advance[cacheflush_advanced_table][1][table]' => 'cache',
);
$this
->drupalPost(NULL, $edit, t('Save'));
$entities = array_values(cacheflush_load_multiple(FALSE, array(
'title' => 'AdvancedCIDTest',
)));
$this
->assertEqual($entities[0]->title, 'AdvancedCIDTest', 'Entity successfully created.');
// Check if entity create on interface.
$this
->drupalGet('cacheflush/' . $entities[0]->id . '/edit');
$this
->assertFieldByName('vertical_tabs_advance[cacheflush_advanced_table][1][cid]', 'AdvancedTestCID');
$this
->assertFieldByName('vertical_tabs_advance[cacheflush_advanced_table][1][table]', 'cache');
$this
->assertFieldByName('vertical_tabs_advance[cacheflush_advanced_table][1][wildcard]', TRUE);
}