From b9757778158c0741d4df590a4e6b7bc51727be7f Mon Sep 17 00:00:00 2001 From: webchick Date: Mon, 30 Apr 2012 21:45:47 -0700 Subject: Issue #277200 by andypost, Damien Tournoud: Add tests for vocabulary hierarchy. --- modules/taxonomy/taxonomy.module | 2 +- modules/taxonomy/taxonomy.test | 4 ++++ 2 files changed, 5 insertions(+), 1 deletion(-) (limited to 'modules/taxonomy') diff --git a/modules/taxonomy/taxonomy.module b/modules/taxonomy/taxonomy.module index 219f360cf..d7e9b2f1c 100644 --- a/modules/taxonomy/taxonomy.module +++ b/modules/taxonomy/taxonomy.module @@ -568,7 +568,7 @@ function taxonomy_check_vocabulary_hierarchy($vocabulary, $changed_term) { $hierarchy = 2; break; } - elseif (count($term->parents) == 1 && 0 !== array_shift($term->parents)) { + elseif (count($term->parents) == 1 && !isset($term->parents[0])) { $hierarchy = 1; } } diff --git a/modules/taxonomy/taxonomy.test b/modules/taxonomy/taxonomy.test index 461f27732..bca75caae 100644 --- a/modules/taxonomy/taxonomy.test +++ b/modules/taxonomy/taxonomy.test @@ -560,6 +560,10 @@ class TaxonomyTermTestCase extends TaxonomyWebTestCase { $term1 = $this->createTerm($this->vocabulary); $term2 = $this->createTerm($this->vocabulary); + // Check that hierarchy is flat. + $vocabulary = taxonomy_vocabulary_load($this->vocabulary->vid); + $this->assertEqual(0, $vocabulary->hierarchy, 'Vocabulary is flat.'); + // Edit $term2, setting $term1 as parent. $edit = array(); $edit['parent[]'] = array($term1->tid); -- cgit v1.2.3