You are here

private function PatternsTaxonomyTestCase::testCMDTerm in Patterns 7.2

Same name and namespace in other branches
  1. 7 tests/taxonomy/taxonomy.test \PatternsTaxonomyTestCase::testCMDTerm()

Test the:

  • Creation
  • Modification of name and description
  • Deletion

of a term with name 'Patatina'.

1 call to PatternsTaxonomyTestCase::testCMDTerm()
PatternsTaxonomyTestCase::testCMDVocabulary in tests/taxonomy/taxonomy.test
Test the:

File

tests/taxonomy/taxonomy.test, line 110
SimpleTests for the Taxonomy component of Patterns.

Class

PatternsTaxonomyTestCase
@file SimpleTests for the Taxonomy component of Patterns.

Code

private function testCMDTerm() {

  // Make sure that 'anothervoc' matches the name in the pattern file
  $term = 'Patatina';

  // CREATE Term pattern.
  parent::runFile('taxonomy_term_add.yaml', 'Taxonomy_Term_ADD', $this->taxo_tests_dir);
  $terms = taxonomy_get_term_by_name($term);

  //$this->assertNotNull($terms, t('Terms found.'));
  $this
    ->assertEqual(count($terms), 1, 'Term found');
  $t = $terms[1];
  $this
    ->assertEqual($t->name, $term, t('Term created with name \'Patatina\'.'));

  // MODIFY Term pattern
  $vid = $t->vid;
  $tid = $t->tid;
  $name = $t->name;
  $descr = $t->description;
  $t = NULL;
  parent::runFile('taxonomy_term_modify.yaml', 'Taxonomy_Term_MODIFY', $this->taxo_tests_dir);
  $terms = db_select('taxonomy_term_data', 'ttd')
    ->fields('ttd', array(
    'vid',
    'tid',
    'name',
    'description',
  ))
    ->condition('ttd.tid', $tid)
    ->execute()
    ->fetchAll();

  // return array of Std objs
  $this
    ->assertEqual(count($terms), 1, t('One term found'));
  $t = $terms[0];
  $this
    ->assertEqual($t->vid, $vid, t('Modify Term pattern did no alter vid.'));
  $this
    ->assertEqual($t->tid, $tid, t('Modify Term pattern did no alter tid.'));
  $this
    ->assertNotEqual($t->name, $name, t('Modify Term pattern changed name correctly.'));
  $this
    ->assertNotEqual($t->description, $descr, t('Modify Term pattern changed description correctly.'));

  // DELETE Term pattern
  parent::runFile('taxonomy_term_delete.yaml', 'Taxonomy_Term_DELETE', $this->taxo_tests_dir);
  $terms = db_select('taxonomy_term_data', 'ttd')
    ->fields('ttd', array(
    'vid',
    'tid',
    'name',
    'description',
  ))
    ->condition('ttd.name', $term)
    ->execute()
    ->fetchAll();

  // return array of Std objs
  $this
    ->assertEqual(count($terms), 0, t('Term \'Patatina\' deleted.'));

  //$this->verbose('Vocabulary modified: ' . var_export($taxo, TRUE));
}