You are here

public function NatSettingsTest::testNatSettings in Node Auto Term [NAT] 7

Same name and namespace in other branches
  1. 6.2 tests/nat.test \NatSettingsTest::testNatSettings()
  2. 6 tests/nat.test \NatSettingsTest::testNatSettings()
  3. 7.2 tests/nat.test \NatSettingsTest::testNatSettings()

NAT settings test.

File

tests/nat.test, line 102
NAT module functionality tests.

Class

NatSettingsTest
NAT settings test.

Code

public function testNatSettings() {
  $this
    ->drupalLogin($this->nat_admin_user);

  // Change NAT settings
  $edit = array(
    'types[' . $this->nat_type . '][]' => array(
      $this->nat_vocab1->vid,
      $this->nat_vocab2->vid,
    ),
    'body[' . $this->nat_type . ']' => TRUE,
    'delete[' . $this->nat_type . ']' => TRUE,
    'related[' . $this->nat_type . ']' => TRUE,
    'node_links[' . $this->nat_type . ']' => TRUE,
  );
  $this
    ->drupalPost('admin/settings/nat', $edit, t('Save configuration'));

  // Verify settings.
  $nat_config = _nat_variable_get();
  $this
    ->assertTRUE($nat_config['types'][$this->nat_type][$this->nat_vocab1->vid], 'Vid1 found in configuration');
  $this
    ->assertTRUE($nat_config['types'][$this->nat_type][$this->nat_vocab2->vid], 'Vid2 found in configuration');

  // Multiple selectboxes currently can't be checked through an assertion.
  // http://drupal.org/node/699132
  // $this->assertFieldByName('types[story][]', $this->nat_vocab1->vid, 'Vid1 for story was set');
  // $this->assertFieldByName('types[story][]', $this->nat_vocab2->vid, 'Vid2 for story was set');
  $this
    ->assertFieldByName('body[' . $this->nat_type . ']', 1, 'Use Body as terms description was set');
  $this
    ->assertFieldByName('delete[' . $this->nat_type . ']', 1, 'Delete associated terms was set');
  $this
    ->assertFieldByName('related[' . $this->nat_type . ']', 1, 'Delete associated terms was set');
  $this
    ->assertFieldByName('node_links[' . $this->nat_type . ']', 1, 'Delete associated terms was set');

  // Change NAT settings
  $edit = array(
    'types[' . $this->nat_type . '][]' => $this->nat_vocab1->vid,
    'body[' . $this->nat_type . ']' => FALSE,
    'delete[' . $this->nat_type . ']' => FALSE,
    'related[' . $this->nat_type . ']' => FALSE,
    'node_links[' . $this->nat_type . ']' => FALSE,
  );
  $this
    ->drupalPost('admin/settings/nat', $edit, t('Save configuration'));

  // Directly get nat_config because of static caching.
  $nat_config = variable_get('nat_config', array());
  $this
    ->assertTRUE(isset($nat_config['types'][$this->nat_type][$this->nat_vocab1->vid]), 'Vid1 found in configuration');
  $this
    ->assertFALSE(isset($nat_config['types'][$this->nat_type][$this->nat_vocab2->vid]), 'Vid2 not found in configuration');
  $this
    ->assertFieldByName('body[' . $this->nat_type . ']', FALSE, 'Use Body as terms description was not set');
  $this
    ->assertFieldByName('delete[' . $this->nat_type . ']', FALSE, 'Delete associated terms was not set');
  $this
    ->assertFieldByName('related[' . $this->nat_type . ']', FALSE, 'Delete associated terms was not set');
  $this
    ->assertFieldByName('node_links[' . $this->nat_type . ']', FALSE, 'Delete associated terms was  set');
  $this
    ->drupalLogout($this->nat_admin_user);
}