Skip to content

Commit f4179b2

Browse files
authored
[9.x] Add test for add method in Collection (#43440)
1 parent 7cde02d commit f4179b2

File tree

1 file changed

+12
-0
lines changed

1 file changed

+12
-0
lines changed

tests/Support/SupportCollectionTest.php

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -844,6 +844,18 @@ public function testCountableByWithCallback($collection)
844844
})->all());
845845
}
846846

847+
public function testAdd()
848+
{
849+
$c = new Collection([]);
850+
$this->assertEquals([1], $c->add(1)->values()->all());
851+
$this->assertEquals([1, 2], $c->add(2)->values()->all());
852+
$this->assertEquals([1, 2, ''], $c->add('')->values()->all());
853+
$this->assertEquals([1, 2, '', null], $c->add(null)->values()->all());
854+
$this->assertEquals([1, 2, '', null, false], $c->add(false)->values()->all());
855+
$this->assertEquals([1, 2, '', null, false, []], $c->add([])->values()->all());
856+
$this->assertEquals([1, 2, '', null, false, [], 'name'], $c->add('name')->values()->all());
857+
}
858+
847859
/**
848860
* @dataProvider collectionClassProvider
849861
*/

0 commit comments

Comments
 (0)