Skip to content
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
Improve the EnumerateValues::value() for returns value from first ite…
…m in negative case
  • Loading branch information
rafaelqueiroz committed Oct 28, 2025
commit e2352adf3f905f471788097b1da2a92b72b327d2
20 changes: 20 additions & 0 deletions tests/Support/SupportCollectionTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -1182,6 +1182,26 @@ public function testValueUsingEnum($collection)
$this->assertEquals(StaffEnum::Joe, $c->where('id', 2)->value('name'));
}

#[DataProvider('collectionClassProvider')]
public function testValueWithNegativeValue($collection)
{
$c = new $collection([['id' => 1, 'balance' => 0], ['id' => 2, 'balance' => 200]]);

$this->assertEquals(0, $c->value('balance'));

$c = new $collection([['id' => 1, 'balance' => ''], ['id' => 2, 'balance' => 200]]);

$this->assertEquals('', $c->value('balance'));

$c = new $collection([['id' => 1, 'balance' => null], ['id' => 2, 'balance' => 200]]);

$this->assertEquals(null, $c->value('balance'));

$c = new $collection([['id' => 1], ['id' => 2, 'balance' => 200]]);

$this->assertEquals(200, $c->value('balance'));
}

#[DataProvider('collectionClassProvider')]
public function testBetween($collection)
{
Expand Down