You are here

public function CacheFlushTest::clearPresetMenu in CacheFlush 8

Check clear cache.

1 call to CacheFlushTest::clearPresetMenu()
CacheFlushTest::testMenu in tests/src/Functional/CacheFlushTest.php
Run test functions.

File

tests/src/Functional/CacheFlushTest.php, line 89

Class

CacheFlushTest
Test cacheflush API.

Namespace

Drupal\Tests\cacheflush\Functional

Code

public function clearPresetMenu() {
  $this
    ->createTestEntitys();
  $enabled = array_values(cacheflush_load_multiple_by_properties([
    'title' => 'Enabled',
    'status' => 1,
  ]));
  $this
    ->assertEqual($enabled[0]->title->value, 'Enabled', 'Created and loaded entity: enabled.');
  $disabled = array_values(cacheflush_load_multiple_by_properties([
    'title' => 'Disabled',
    'status' => 0,
  ]));
  $this
    ->assertEqual($disabled[0]->title->value, 'Disabled', 'Created and loaded entity: disabled.');
  $this
    ->drupalLogin($this->testUser);

  // Check access of the menus - access TRUE expected.
  $this
    ->drupalGet('admin/cacheflush');
  $this
    ->assertResponse(200);
  $this
    ->drupalGet('admin/cacheflush/clear/all');
  $this
    ->assertResponse(200);
  $this
    ->drupalGet('admin/cacheflush/clear/' . $enabled[0]->id->value);
  $this
    ->assertResponse(200);

  // Check if the disabled entity will be refused.
  $this
    ->drupalGet('admin/cacheflush/clear/' . $disabled[0]->id->value);
  $this
    ->assertResponse(403);
  $this
    ->drupalLogout();
}