Skip to content

Commit f3c4f5a

Browse files
authored
[9.x] Imrove test for combine method in Collection (#43380)
1 parent 8a2b817 commit f3c4f5a

File tree

1 file changed

+28
-2
lines changed

1 file changed

+28
-2
lines changed

tests/Support/SupportCollectionTest.php

Lines changed: 28 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4112,14 +4112,40 @@ public function testJsonSerialize($collection)
41124112
*/
41134113
public function testCombineWithArray($collection)
41144114
{
4115+
$c = new $collection([1, 2, 3]);
4116+
$actual = $c->combine([4, 5, 6])->toArray();
41154117
$expected = [
41164118
1 => 4,
41174119
2 => 5,
41184120
3 => 6,
41194121
];
41204122

4121-
$c = new $collection(array_keys($expected));
4122-
$actual = $c->combine(array_values($expected))->toArray();
4123+
$this->assertSame($expected, $actual);
4124+
4125+
$c = new $collection(['name', 'family']);
4126+
$actual = $c->combine([1 => 'taylor', 2 => 'otwell'])->toArray();
4127+
$expected = [
4128+
'name' => 'taylor',
4129+
'family' => 'otwell',
4130+
];
4131+
4132+
$this->assertSame($expected, $actual);
4133+
4134+
$c = new $collection([1 => 'name', 2 => 'family']);
4135+
$actual = $c->combine(['taylor', 'otwell'])->toArray();
4136+
$expected = [
4137+
'name' => 'taylor',
4138+
'family' => 'otwell',
4139+
];
4140+
4141+
$this->assertSame($expected, $actual);
4142+
4143+
$c = new $collection([1 => 'name', 2 => 'family']);
4144+
$actual = $c->combine([2 => 'taylor', 3 => 'otwell'])->toArray();
4145+
$expected = [
4146+
'name' => 'taylor',
4147+
'family' => 'otwell',
4148+
];
41234149

41244150
$this->assertSame($expected, $actual);
41254151
}

0 commit comments

Comments
 (0)