Skip to content

Commit

Permalink
Cast priority to int for correct compare with null priority
Browse files Browse the repository at this point in the history
  • Loading branch information
SocalNick committed Jul 24, 2012
1 parent e1da429 commit 5d0ca28
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 1 deletion.
2 changes: 1 addition & 1 deletion library/Zend/Mvc/Router/PriorityList.php
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@ public function insert($name, RouteInterface $route, $priority)

$this->routes[$name] = array(
'route' => $route,
'priority' => $priority,
'priority' => (int) $priority,
'serial' => $this->serial++,
);
}
Expand Down
15 changes: 15 additions & 0 deletions tests/Zend/Mvc/Router/PriorityListTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -126,4 +126,19 @@ public function testLIFOWithPriority()

$this->assertEquals(array('baz', 'bar', 'foo'), $orders);
}

public function testPriorityWithNegativesAndNull()
{
$this->list->insert('foo', new TestAsset\DummyRoute(), null);
$this->list->insert('bar', new TestAsset\DummyRoute(), 1);
$this->list->insert('baz', new TestAsset\DummyRoute(), -1);

$order = array();

foreach ($this->list as $key => $value) {
$orders[] = $key;
}

$this->assertEquals(array('bar', 'foo', 'baz'), $orders);
}
}

0 comments on commit 5d0ca28

Please sign in to comment.