You are here

public function CoffeeTest::testCoffeeConfiguration in Coffee 8

Tests coffee configuration form.

File

tests/src/Functional/CoffeeTest.php, line 59

Class

CoffeeTest
Tests Coffee module functionality.

Namespace

Drupal\Tests\coffee\Functional

Code

public function testCoffeeConfiguration() {
  $this
    ->drupalGet('admin/config/user-interface/coffee');
  $this
    ->assertSession()
    ->statusCodeEquals(403);
  $this
    ->drupalLogin($this->coffeeAdmin);
  $this
    ->drupalGet('admin/config/user-interface/coffee');
  $this
    ->assertSession()
    ->statusCodeEquals(200);
  $this
    ->assertSession()
    ->checkboxChecked('edit-coffee-menus-admin');
  $this
    ->assertSession()
    ->fieldValueEquals('edit-max-results', 7);
  $edit = [
    'coffee_menus[tools]' => 'tools',
    'coffee_menus[account]' => 'account',
    'max_results' => 15,
  ];
  $this
    ->drupalPostForm('admin/config/user-interface/coffee', $edit, t('Save configuration'));
  $this
    ->assertSession()
    ->pageTextContains(t('The configuration options have been saved.'));
  $expected = [
    'admin' => 'admin',
    'tools' => 'tools',
    'account' => 'account',
  ];
  $config = \Drupal::config('coffee.configuration')
    ->get('coffee_menus');
  $this
    ->assertEquals($expected, $config, 'The configuration options have been properly saved');
  $config = \Drupal::config('coffee.configuration')
    ->get('max_results');
  $this
    ->assertEquals(15, $config, 'The configuration options have been properly saved');
}