Skip to content

Commit

Permalink
Testing attributes are not there when empty.
Browse files Browse the repository at this point in the history
  • Loading branch information
Bèr Kessels committed Dec 31, 2012
1 parent 1fcc271 commit 8fc23b5
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 3 deletions.
6 changes: 4 additions & 2 deletions TagadelicTag.php
Original file line number Diff line number Diff line change
Expand Up @@ -34,8 +34,10 @@ function __construct($id, $name, $count) {
public function __ToString() {
$this->clean();

$attributes = array("title" => $this->description);
if ($this->weight > 0) $attributes["class"] = "weight-3";
$attributes = array();

if (!empty($this->description)) $attributes["title"] = $this->description;
if ($this->weight > 0) $attributes["class"] = "weight-3";

return $this->drupal()->l($this->name, $this->link, $attributes);
}
Expand Down
18 changes: 17 additions & 1 deletion tests/TagadelicTagToStringTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -61,12 +61,28 @@ public function test__ToStringHasTitle() {
$this->object->__tostring();
}

/**
* @covers tagadelictag::__tostring
*/
public function test__ToStringHasNoTitle() {
$this->object->set_description("");

$this->drupal->expects($this->any())
->method('l')
->with(
$this->anything(),
$this->anything(),
$this->equalto(array()))
->will($this->returnvalue(""));

$this->object->__tostring();
}
/**
* @covers tagadelictag::__tostring
*/
public function test__ToStringHasWeight() {
$this->object->set_weight(3);
$expected_attrs = array("title" => "", "class" => "weight-3");
$expected_attrs = array("class" => "weight-3");

$this->drupal->expects($this->any())
->method('l')
Expand Down

0 comments on commit 8fc23b5

Please sign in to comment.