Skip to content

Commit

Permalink
attribute evals to array exception
Browse files Browse the repository at this point in the history
  • Loading branch information
figdice committed Jul 14, 2015
1 parent 4ab3c23 commit 2c147e8
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 5 deletions.
6 changes: 1 addition & 5 deletions src/figdice/classes/ViewElementTag.php
Original file line number Diff line number Diff line change
Expand Up @@ -196,11 +196,7 @@ function buildXMLAttributesString() {
else {
$message = 'Attribute ' . $attribute . '="' . $value . '" in tag "' . $this->name . '" evaluated to array.';
$message = get_class($this) . ': file: ' . $this->currentFile->getFilename() . '(' . $this->xmlLineNumber . '): ' . $message;
if(! $this->logger) {
$this->logger = LoggerFactory::getLogger(get_class($this));
}
$this->logger->error($message);
throw new Exception($message);
throw new RenderingException($this->getTagName(), $this->getCurrentFilename(), $this->getLineNumber(), $message);
}
}

Expand Down
12 changes: 12 additions & 0 deletions test/FigXmlTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -298,4 +298,16 @@ public function testWalkOnEmptyGivesNothing()
$view->loadString($source);
$this->assertEquals('', $view->render());
}

/**
* @expectedException \figdice\exceptions\RenderingException
*/
public function testAttributeEvalsToArrayException()
{
$source = '<xml attr="{myArray}"></xml>';
$view = new View();
$view->loadString($source);
$view->mount('myArray', array(4, 5, 6));
$this->assertEquals('dummy', $view->render());
}
}

0 comments on commit 2c147e8

Please sign in to comment.