Permalink
Browse files

add limit ranger to limit to 60 tags.

  • Loading branch information...
1 parent e3d942d commit 7efaba915cf952290c342055414ce5c9d35d848b Bèr Kessels committed Dec 29, 2012
Showing with 21 additions and 1 deletion.
  1. +1 −0 tagadelic_taxonomy.module
  2. +20 −1 tests/tagadelic_taxonomy.test
View
1 tagadelic_taxonomy.module
@@ -48,6 +48,7 @@ function tagadelic_taxonomy_get_tags() {
$query = db_select('taxonomy_term_data', 't');
$result = $query
->fields('t')
+ ->range(0, 60)
->execute();
foreach ($result as $term) {
View
21 tests/tagadelic_taxonomy.test
@@ -42,20 +42,34 @@ class TagadelicTaxonomyTestCase extends DrupalWebTestCase {
public function testHasClickableLink() {
$this->createVocAndTags(1);
$this->drupalGet("tagadelic_taxonomy");
- $this->assertHasXpath("//ul[@class='tag-cloud']/li/a", "Link with class tag in UL/LI");
$link = $this->xpath("//ul[@class='tag-cloud']/li/a[1]");
$links_to = (string) $link[0]->attributes()["href"];
$tag = $this->tags[0];
$this->assertEqual("/taxonomy/term/{$tag->tid}", $links_to);
}
+ public function testHasFiveTags() {
+ $this->createVocAndTags(5);
+ $this->drupalGet("tagadelic_taxonomy");
+ $amount = count($this->xpath("//*/ul[@class='tag-cloud']/li"));
+ $this->assertEqual(5, $amount);
+ }
+
+ public function testHasMaxsixtyTags() {
+ $this->createVocAndTags(100);
+ $this->drupalGet("tagadelic_taxonomy");
+ $amount = count($this->xpath("//*/ul[@class='tag-cloud']/li"));
+ $this->assertEqual(60, $amount);
+ }
+
private function createVocAndTags($amount_of_tags) {
$tx_test = new TaxonomyWebTestCase();
$this->vocabulary = $tx_test->createVocabulary();
for ($i = 0; $i < $amount_of_tags; $i++) {
$this->tags[] = $tx_test->createTerm($this->vocabulary);
}
+ return $this;
}
private function createNodesWithTags() {
@@ -72,4 +86,9 @@ class TagadelicTaxonomyTestCase extends DrupalWebTestCase {
$truthiness = count($xpath) > 0;
return $this->assertTrue($truthiness, $message, $group);
}
+
+ private function assertHasTag($name, $message = '', $group = 'Other') {
+ $xpath = "//ul[@class='tag-cloud']/li/a";
+ return $this->assertHasXpath($xpath, $message, $group);
+ }
}

0 comments on commit 7efaba9

Please sign in to comment.