You are here

private function CacheFlushAdvancedTest::interfaceCrud in CacheFlush 8

Test add/remove on ajax form.

1 call to CacheFlushAdvancedTest::interfaceCrud()
CacheFlushAdvancedTest::setUp in modules/cacheflush_advanced/tests/src/Functional/CacheFlushAdvancedTest.php
Sets up the test.

File

modules/cacheflush_advanced/tests/src/Functional/CacheFlushAdvancedTest.php, line 94

Class

CacheFlushAdvancedTest
Test cacheflush advanced functionality.

Namespace

Drupal\Tests\cacheflush_advanced\Functional

Code

private function interfaceCrud() {
  $this
    ->drupalGet('admin/structure/cacheflush/add');
  $this
    ->drupalPostAjaxForm(NULL, [], 'advance_add');
  $this
    ->assertFieldByName('vertical_tabs_advance[cacheflush_advanced_table][1][cid]');
  $this
    ->assertFieldByName('vertical_tabs_advance[cacheflush_advanced_table][1][table]');
  $this
    ->assertFieldByName('advanced_remove_1');
  $this
    ->drupalPostAjaxForm(NULL, [], 'advance_add');
  $this
    ->assertFieldByName('vertical_tabs_advance[cacheflush_advanced_table][2][cid]');
  $this
    ->assertFieldByName('vertical_tabs_advance[cacheflush_advanced_table][2][table]');
  $this
    ->assertFieldByName('advanced_remove_2');
  $this
    ->drupalPostAjaxForm(NULL, [], 'advance_add');
  $this
    ->assertFieldByName('vertical_tabs_advance[cacheflush_advanced_table][3][cid]');
  $this
    ->assertFieldByName('vertical_tabs_advance[cacheflush_advanced_table][3][table]');
  $this
    ->assertFieldByName('advanced_remove_3');
  $this
    ->drupalPostAjaxForm(NULL, [], 'advanced_remove_1');
  $this
    ->assertFieldByName('advanced_remove_0');
  $this
    ->assertNoFieldByName('advanced_remove_1');
  $this
    ->assertFieldByName('advanced_remove_2');
  $this
    ->drupalPostAjaxForm(NULL, [
    'title' => 'Test 1',
  ], 'advanced_remove_0');
  $this
    ->assertNoFieldByName('advanced_remove_0');
  $this
    ->assertNoFieldByName('advanced_remove_1');
  $this
    ->assertFieldByName('advanced_remove_2');
  $this
    ->drupalPostAjaxForm(NULL, [
    'title' => 'Test 1',
  ], 'advanced_remove_2');
  $this
    ->assertNoFieldByName('advanced_remove_0');
  $this
    ->assertNoFieldByName('advanced_remove_1');
  $this
    ->assertNoFieldByName('advanced_remove_2');
  $this
    ->drupalPostAjaxForm(NULL, [], 'advance_add');
  $this
    ->assertFieldByName('advanced_remove_4');
  $this
    ->drupalPostForm(NULL, [
    'title' => 'Test 1',
    'vertical_tabs_advance[cacheflush_advanced_table][4][cid]' => 'TEST',
    'vertical_tabs_advance[cacheflush_advanced_table][4][table]' => 'menu',
  ], t('Save'));
  $entities = array_values(cacheflush_load_multiple_by_properties([
    'title' => 'Test 1',
  ]));
  $this
    ->assertEqual($entities[0]
    ->getTitle(), 'Test 1', 'Entity successfully created.');

  // Check if entity create on interface.
  $this
    ->drupalGet('cacheflush/' . $entities[0]
    ->id() . '/edit');
  $this
    ->assertFieldByName('vertical_tabs_advance[cacheflush_advanced_table][4][cid]', 'TEST');
  $this
    ->assertFieldByName('vertical_tabs_advance[cacheflush_advanced_table][4][table]', 'menu');
}