You are here

public function NatBasicTest::testNatBasic in Node Auto Term [NAT] 7

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

NAT basic function test.

File

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

Class

NatBasicTest
NAT basic function test.

Code

public function testNatBasic() {
  $this
    ->drupalLogin($this->nat_user);

  // Create NAT node
  $settings = array(
    'type' => $this->nat_type,
    'title' => $this->nat_node_title,
    'body' => $this->nat_node_body,
  );
  $node = $this
    ->drupalCreateNode($settings);
  $terms = taxonomy_get_term_by_name($node->title);
  $this
    ->assertTRUE(count($terms) === 2, 'Found 2 terms');

  // Check if the terms are in one of the vocabularies.
  $this
    ->assertTRUE($terms[0]->vid === $this->nat_vocab1->vid || $terms[0]->vid === $this->nat_vocab2->vid, 'Term 1 is in one of the desired vocabularies');
  $this
    ->assertTRUE($terms[1]->vid === $this->nat_vocab1->vid || $terms[1]->vid === $this->nat_vocab2->vid, 'Term 2 is in one of the desired vocabularies');

  // Check description.
  $this
    ->assertTRUE($terms[0]->description === $this->nat_node_body, 'Term 1 description is correct');
  $this
    ->assertTRUE($terms[1]->description === $this->nat_node_body, 'Term 2 description is correct');

  // Delete node.
  node_delete($node->nid);

  // Check that terms are deleted.
  $this
    ->assertFALSE(taxonomy_get_term_by_name($this->nat_node_title), 'No terms with node title found');
  $this
    ->drupalLogout($this->nat_user);
}