Skip to content
This repository has been archived by the owner on Jan 30, 2020. It is now read-only.

Commit

Permalink
Merge pull request zendframework/zendframework#6159 in master
Browse files Browse the repository at this point in the history
  • Loading branch information
Maks3w committed Apr 22, 2014
2 parents 6fca41f + 9277422 commit db2794e
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 4 deletions.
6 changes: 3 additions & 3 deletions src/Filter/Priority.php
Original file line number Diff line number Diff line change
Expand Up @@ -42,14 +42,14 @@ public function __construct($priority, $operator = null)
$operator = isset($priority['operator']) ? $priority['operator'] : null;
$priority = isset($priority['priority']) ? $priority['priority'] : null;
}
if (!is_int($priority)) {
if (!is_int($priority) && !ctype_digit($priority)) {
throw new Exception\InvalidArgumentException(sprintf(
'Priority must be an integer; received "%s"',
'Priority must be a number, received "%s"',
gettype($priority)
));
}

$this->priority = $priority;
$this->priority = (int) $priority;
$this->operator = $operator === null ? '<=' : $operator;
}

Expand Down
13 changes: 12 additions & 1 deletion test/Filter/PriorityTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,18 @@ public function testComparisonOperatorCanBeChanged()

public function testConstructorThrowsOnInvalidPriority()
{
$this->setExpectedException('Zend\Log\Exception\InvalidArgumentException', 'must be an integer');
$this->setExpectedException('Zend\Log\Exception\InvalidArgumentException', 'must be a number');
new Priority('foo');
}

public function testComparisonStringSupport()
{
// accept at or below priority '2'
$filter = new Priority('2');

$this->assertTrue($filter->filter(array('priority' => 2)));
$this->assertTrue($filter->filter(array('priority' => 1)));
$this->assertFalse($filter->filter(array('priority' => 3)));
}

}

0 comments on commit db2794e

Please sign in to comment.