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

Fixes #6768 : boolean false values at priority list should be valid #6773

Closed
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
2 changes: 1 addition & 1 deletion library/Zend/Stdlib/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);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

enough return (current($this->items) !== false);
protected $currentNode = false; is superfluous

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done ;). thank you ;)

}

/**
Expand Down
7 changes: 7 additions & 0 deletions tests/ZendTest/Db/Sql/UpdateTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -232,6 +232,13 @@ public function testGetSqlString()
->where('x = y');

$this->assertEquals('UPDATE "sch"."foo" SET "bar" = \'baz\', "boo" = NOW(), "bam" = NULL WHERE x = y', $this->update->getSqlString(new TrustingSql92Platform()));

// with boolean values
$this->update = new Update;
$this->update->table(new TableIdentifier('foo', 'sch'))
->set(array('bar' => false, 'boo' => 'test', 'bam' => true))
->where('x = y');
$this->assertEquals('UPDATE "sch"."foo" SET "bar" = \'\', "boo" = \'test\', "bam" = \'1\' WHERE x = y', $this->update->getSqlString(new TrustingSql92Platform()));
}

/**
Expand Down
27 changes: 23 additions & 4 deletions tests/ZendTest/Stdlib/PriorityListTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,7 @@ public function testLIFOOnly()
$this->list->insert('foobar', new \stdClass());
$this->list->insert('barbaz', new \stdClass());

$order = array();
$orders = array();

foreach ($this->list as $key => $value) {
$orders[] = $key;
Expand Down Expand Up @@ -129,7 +129,7 @@ public function testFIFOWithPriority()
$this->list->insert('bar', new \stdClass(), 0);
$this->list->insert('baz', new \stdClass(), 1);

$order = array();
$orders = array();

foreach ($this->list as $key => $value) {
$orders[] = $key;
Expand All @@ -147,7 +147,7 @@ public function testFIFOOnly()
$this->list->insert('foobar', new \stdClass());
$this->list->insert('barbaz', new \stdClass());

$order = array();
$orders = array();

foreach ($this->list as $key => $value) {
$orders[] = $key;
Expand All @@ -162,7 +162,7 @@ public function testPriorityWithNegativesAndNull()
$this->list->insert('bar', new \stdClass(), 1);
$this->list->insert('baz', new \stdClass(), -1);

$order = array();
$orders = array();

foreach ($this->list as $key => $value) {
$orders[] = $key;
Expand Down Expand Up @@ -195,4 +195,23 @@ public function testToArray()
$this->list->toArray(PriorityList::EXTR_BOTH)
);
}

/**
* @group ZF2-6768
*/
public function testBooleanValuesAreValid()
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

was meant this:

        $this->list->insert('null', null, null);
        $this->list->insert('false', false, null);
        $this->list->insert('string', 'test', 1);
        $this->list->insert('true', true, -1);

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

        foreach ($this->list as $key => $value) {
            $orders1[$this->list->key()] = $this->list->current();
            $orders2[$key] = $value;
        }
        $this->assertEquals($orders1, $orders2);
        $this->assertEquals(
            array(
                'null'   => null,
                'false'  => false,
                'string' => 'test',
                'true'   => true,
            ),
            $orders2
        );

{
$this->list->insert('foo', false, null);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

please, add $this->list->insert('foo', null, null); here

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done ;)

$this->list->insert('foo', null, null);
$this->list->insert('bar', 'test', 1);
$this->list->insert('baz', true, -1);

$orders = array();

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

$this->assertEquals(array('test', false, true), $orders);
}
}