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

Commit

Permalink
Browse files Browse the repository at this point in the history
…endframework#6773-zend-stdlib-priority-list-false-value-support' into develop

Close zendframework/zendframework#6904
Forward port zendframework/zendframework#6904
  • Loading branch information
Ocramius committed Nov 20, 2014
3 parents 1d0a295 + 4ccab4a + 31a5668 commit 7c30b95
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 9 deletions.
2 changes: 1 addition & 1 deletion src/PriorityList.php
Original file line number Diff line number Diff line change
Expand Up @@ -227,7 +227,7 @@ public function next()
*/
public function valid()
{
return $this->current() !== false;
return current($this->items) !== false;
}

/**
Expand Down
26 changes: 18 additions & 8 deletions test/PriorityListTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -222,17 +222,27 @@ public function testToArray()
*/
public function testBooleanValuesAreValid()
{
$this->list->insert('foo', false, null);
$this->list->insert('foo', null, null);
$this->list->insert('bar', 'test', 1);
$this->list->insert('baz', true, -1);
$this->list->insert('null', null, null);
$this->list->insert('false', false, null);
$this->list->insert('string', 'test', 1);
$this->list->insert('true', true, -1);

$orders = array();
$orders1 = array();
$orders2 = array();

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

$this->assertEquals(array('test', false, true), $orders);
$this->assertEquals($orders1, $orders2);
$this->assertEquals(
array(
'null' => null,
'false' => false,
'string' => 'test',
'true' => true,
),
$orders2
);
}
}

0 comments on commit 7c30b95

Please sign in to comment.