Best Atoum code snippet using diff.testMake
CollectionTest.php
Source:CollectionTest.php  
...7{8    /**9     * TODO: РеализоваÑÑ ÑеÑÑ10     */11    public function testMake(): void12    {13        $this->assertSame(1, 1);14    }15    public function test__construct()16    {17        $this->markTestIncomplete();18    }19    /**20     * @depends testMake21     */22    public function testAll(): void23    {24        $collection = Collection::make([1, 2, 3]);25        $this->assertSame([1, 2, 3], $collection->all());26    }27    /**28     * @depends testMake29     */30    public function testAvg(): void31    {32        $collection = Collection::make([1, 1, 2, 4]);33        $this->assertSame(2.0, $collection->avg());34        $collection = Collection::make([35            ['foo' => 10],36            ['foo' => 10],37            ['foo' => 20],38            ['foo' => 40],39        ]);40        $this->assertSame(20.0, $collection->avg('foo'));41        $this->assertSame(20.0, $collection->avg(fn($item) => $item['foo']));42    }43    /**44     * @depends testMake45     */46    public function testAverage(): void47    {48        $collection = Collection::make([1, 1, 2, 4]);49        $this->assertSame(2.0, $collection->average());50        $collection = Collection::make([51            ['foo' => 10],52            ['foo' => 10],53            ['foo' => 20],54            ['foo' => 40],55        ]);56        $this->assertSame(20.0, $collection->average('foo'));57        $this->assertSame(20.0, $collection->average(fn($item) => $item['foo']));58    }59    /**60     * @depends testMake61     * @depends testToArray62     */63    public function testChunk(): void64    {65        $collection = Collection::make([1, 2, 3, 4, 5, 6, 7]);66        $chunks = $collection->chunk(4);67        $this->assertSame(68            [69                [0 => 1, 1 => 2, 2 => 3, 3 => 4],70                [4 => 5, 5 => 6, 6 => 7],71            ],72            $chunks->toArray()73        );74    }75    /**76     * @depends testMake77     * @depends testToArray78     */79    public function testChunkWhile(): void80    {81        $this->markTestIncomplete('ÐÑÑÑÑÑÑвÑÐµÑ ÑеализаÑиÑ');82        $collection = Collection::make(str_split('AABBCCCD'));83        $chunks = $collection->chunkWhile(fn($value, $key, $chunk) => $value === $chunk->last());84        $this->assertSame([['A', 'A'], ['B', 'B'], ['C', 'C', 'C'], ['D']], $chunks->toArray());85    }86    /**87     * @depends testMake88     * @depends testAll89     */90    public function testCollapse(): void91    {92        $collection = Collection::make([93            [1, 2, 3],94            [4, 5, 6],95            [7, 8, 9],96        ]);97        $collapsed = $collection->collapse();98        $this->assertSame([1, 2, 3, 4, 5, 6, 7, 8, 9], $collapsed->all());99    }100    /**101     * @depends testMake102     * @depends testAll103     */104    public function testCollect(): void105    {106        $collectionA = Collection::make([1, 2, 3]);107        $collectionB = $collectionA->collect();108        $this->assertSame([1, 2, 3], $collectionB->all());109    }110    /**111     * @depends testMake112     * @depends testAll113     */114    public function testCombine(): void115    {116        $collection = Collection::make(['name', 'age']);117        $combined = $collection->combine(['George', 29]);118        $this->assertSame(['name' => 'George', 'age' => 29], $combined->all());119    }120    /**121     * @depends testMake122     * @depends testAll123     */124    public function testConcat(): void125    {126        $this->markTestIncomplete('РеализаÑÐ¸Ñ ÑолÑко на PHP 8.1 и вÑÑе + недоделана ÑабоÑа не Ñ Ð¼Ð°ÑÑивом а Ñ ÐºÐ¾Ð»Ð»ÐµÐºÑией');127        $collection = Collection::make(['John Doe']);128        $concatenated = $collection->concat(['Jane Doe'])->concat(['name' => 'Johnny Doe']);129        $this->assertSame(['John Doe', 'Jane Doe', 'Johnny Doe'], $concatenated->all());130    }131    /**132     * @depends testMake133     */134    public function testContains(): void135    {136        $collection = Collection::make([1, 2, 3, 4, 5]);137        $this->assertFalse($collection->contains(value: fn($value) => $value > 5));138        $this->assertTrue($collection->contains(value: 3));139        $this->assertFalse($collection->contains(value: '3', strict: true));140        $this->assertFalse($collection->contains(value: 'New York'));141        $collection = Collection::make([142            ['product' => 'Desk', 'price' => 200],143            ['product' => 'Chair', 'price' => 100],144        ]);145        $this->assertFalse($collection->contains(value: 'Bookcase', key: 'product'));146        $this->assertTrue($collection->contains(value: 'Chair', key: 'product'));147    }148    /**149     * @depends testMake150     */151    public function testContainsStrict(): void152    {153        $collection = Collection::make([1, 2, 3, 4, 5]);154        $this->assertTrue($collection->containsStrict(3));155        $this->assertFalse($collection->containsStrict('3'));156    }157    /**158     * @depends testMake159     * @depends testAll160     */161    public function testCountBy(): void162    {163        $collection = Collection::make([1, 2, 2, 2, 3]);164        $this->assertSame([1 => 1, 2 => 3, 3 => 1], $collection->countBy()->all());165        $collection = Collection::make(['alice@gmail.com', 'bob@yahoo.com', 'carlos@gmail.com']);166        $counted = $collection->countBy(fn($email) => substr(strrchr($email, '@'), 1));167        $this->assertSame(['gmail.com' => 2, 'yahoo.com' => 1], $counted->all());168    }169    /**170     * @depends testMake171     * @depends testAll172     */173    public function testCrossJoin(): void174    {175        $collection = Collection::make([1, 2]);176        $matrix = $collection->crossJoin(['a', 'b']);177        $this->assertSame(178            [179                [1, 'a'],180                [1, 'b'],181                [2, 'a'],182                [2, 'b'],183            ],184            $matrix->all()185        );186        $collection = Collection::make([1, 2]);187        $matrix = $collection->crossJoin(['a', 'b'], ['I', 'II']);;188        $this->assertSame(189            [190                [1, 'a', 'I'],191                [1, 'a', 'II'],192                [1, 'b', 'I'],193                [1, 'b', 'II'],194                [2, 'a', 'I'],195                [2, 'a', 'II'],196                [2, 'b', 'I'],197                [2, 'b', 'II'],198            ],199            $matrix->all()200        );201    }202    /**203     * @depends testMake204     * @depends testAll205     */206    public function testDiff(): void207    {208        $collection = Collection::make([1, 2, 3, 4, 5]);209        $diff = $collection->diff([2, 4, 6, 8]);210        $this->assertSame([0 => 1, 2 => 3, 4 => 5], $diff->all());211    }212    /**213     * @depends testMake214     * @depends testAll215     */216    public function testDiffAssoc(): void217    {218        $collection = Collection::make([219            'color' => 'orange',220            'type' => 'fruit',221            'remain' => 6,222        ]);223        $diff = $collection->diffAssoc([224            'color' => 'yellow',225            'type' => 'fruit',226            'remain' => 3,227            'used' => 6,228        ]);229        $this->assertSame(['color' => 'orange', 'remain' => 6], $diff->all());230    }231    /**232     * @depends testMake233     * @depends testAll234     */235    public function testDiffKeys(): void236    {237        $collection = Collection::make([238            'one' => 10,239            'two' => 20,240            'three' => 30,241            'four' => 40,242            'five' => 50,243        ]);244        $diff = $collection->diffKeys([245            'two' => 2,246            'four' => 4,247            'six' => 6,248            'eight' => 8,249        ]);250        $this->assertSame(['one' => 10, 'three' => 30, 'five' => 50], $diff->all());251    }252    /**253     * @depends testMake254     * @depends testAll255     */256    public function testDuplicates(): void257    {258        $collection = Collection::make(['a', 'b', 'a', 'c', 'b']);259        $this->assertSame([2 => 'a', 4 => 'b'], $collection->duplicates()->all());260        $employees = Collection::make([261            ['email' => 'abigail@example.com', 'position' => 'Developer'],262            ['email' => 'james@example.com', 'position' => 'Designer'],263            ['email' => 'victoria@example.com', 'position' => 'Developer'],264        ]);265        $employees->duplicates('position');266        $this->assertSame([2 => 'Developer'], $employees->duplicates('position')->all());267    }268    public function testDuplicatesStrict(): void269    {270        $this->markTestIncomplete();271    }272    public function testEach(): void273    {274        $this->markTestIncomplete();275    }276    public function testEachSpread(): void277    {278        $this->markTestIncomplete();279    }280    /**281     * @depends testMake282     */283    public function testEvery(): void284    {285        $this->assertFalse(Collection::make([1, 2, 3, 4])->every(fn($value, $key) => $value > 2));286        $this->assertTrue(Collection::make([])->every(fn($value, $key) => $value > 2));287    }288    /**289     * @depends testMake290     * @depends testAll291     */292    public function testExcept(): void293    {294        $collection = Collection::make(['product_id' => 1, 'price' => 100, 'discount' => false]);295        $filtered = $collection->except(['price', 'discount']);296        $this->assertSame(['product_id' => 1], $filtered->all());297    }298    /**299     * @depends testMake300     * @depends testAll301     */302    public function testFilter(): void303    {304        $collection = Collection::make([1, 2, 3, 4]);305        $this->assertSame([2 => 3, 3 => 4], $collection->filter(fn($value, $key) => $value > 2)->all());306        $collection = Collection::make([1, 2, 3, null, false, '', 0, []]);307        $this->assertSame([1, 2, 3], $collection->filter()->all());308    }309    /**310     * @depends testMake311     */312    public function testFirst(): void313    {314        $result = Collection::make([1, 2, 3, 4])->first(fn($value, $key) => $value > 2);315        $this->assertSame(3, $result);316        $this->assertSame(1, Collection::make([1, 2, 3, 4])->first());317    }318    public function testFirstWhere(): void319    {320        $this->markTestIncomplete();321    }322    /**323     * @depends testMake324     * @depends testAll325     */326    public function testFlatMap(): void327    {328        $collection = Collection::make([329            ['name' => 'Sally'],330            ['school' => 'Arkansas'],331            ['age' => 28],332        ]);333        $flattened = $collection->flatMap(fn($values) => array_map('strtoupper', $values));334        $this->assertSame(['name' => 'SALLY', 'school' => 'ARKANSAS', 'age' => '28'], $flattened->all());335    }336    /**337     * @depends testMake338     * @depends testAll339     */340    public function testFlatten(): void341    {342        $collection = Collection::make([343            'name' => 'taylor',344            'languages' => [345                'php', 'javascript',346            ],347        ]);348        $flattened = $collection->flatten();349        $this->assertSame(['taylor', 'php', 'javascript'], $flattened->all());350        $collection = Collection::make([351            'Apple' => [352                [353                    'name' => 'iPhone 6S',354                    'brand' => 'Apple',355                ],356            ],357            'Samsung' => [358                [359                    'name' => 'Galaxy S7',360                    'brand' => 'Samsung',361                ],362            ],363        ]);364        $products = $collection->flatten(1);365        $this->assertSame(366            [367                ['name' => 'iPhone 6S', 'brand' => 'Apple'],368                ['name' => 'Galaxy S7', 'brand' => 'Samsung'],369            ],370            $products->values()->all()371        );372    }373    /**374     * @depends testMake375     * @depends testAll376     */377    public function testFlip(): void378    {379        $collection = Collection::make(['name' => 'taylor', 'framework' => 'laravel']);380        $this->assertSame(['taylor' => 'name', 'laravel' => 'framework'], $collection->flip()->all());381    }382    /**383     * @depends testMake384     * @depends testAll385     */386    public function testForget(): void387    {388        $collection = Collection::make(['name' => 'taylor', 'framework' => 'laravel']);389        $collection->forget('name');390        $this->assertSame(['framework' => 'laravel'], $collection->all());391    }392    /**393     * @depends testMake394     * @depends testAll395     */396    public function testForPage(): void397    {398        $collection = Collection::make([1, 2, 3, 4, 5, 6, 7, 8, 9]);399        $chunk = $collection->forPage(2, 3);400        $this->assertSame([4, 5, 6], $chunk->all());401    }402    /**403     * @depends testMake404     */405    public function testGet(): void406    {407        $collection = Collection::make(['name' => 'taylor', 'framework' => 'laravel']);408        $this->assertSame('taylor', $collection->get('name'));409        $this->assertSame(34, $collection->get('age', 34));410        $this->assertSame('taylor@example.com', $collection->get('email', fn() => 'taylor@example.com'));411    }412    /**413     * @depends testMake414     * @depends testToArray415     */416    public function testGroupBy(): void417    {418        $collection = Collection::make([419            ['account_id' => 'account-x10', 'product' => 'Chair'],420            ['account_id' => 'account-x10', 'product' => 'Bookcase'],421            ['account_id' => 'account-x11', 'product' => 'Desk'],422        ]);423        $grouped = $collection->groupBy('account_id');424        $this->assertEquals(425            [426                'account-x10' => [427                    ['account_id' => 'account-x10', 'product' => 'Chair'],428                    ['account_id' => 'account-x10', 'product' => 'Bookcase'],429                ],430                'account-x11' => [431                    ['account_id' => 'account-x11', 'product' => 'Desk'],432                ],433            ],434            $grouped->toArray()435        );436        $grouped = $collection->groupBy(fn($item, $key) => substr($item['account_id'], -3));437        $this->assertEquals(438            [439                'x10' => [440                    ['account_id' => 'account-x10', 'product' => 'Chair'],441                    ['account_id' => 'account-x10', 'product' => 'Bookcase'],442                ],443                'x11' => [444                    ['account_id' => 'account-x11', 'product' => 'Desk'],445                ],446            ],447            $grouped->toArray()448        );449        $data = new Collection([450            10 => ['user' => 1, 'skill' => 1, 'roles' => ['Role_1', 'Role_3']],451            20 => ['user' => 2, 'skill' => 1, 'roles' => ['Role_1', 'Role_2']],452            30 => ['user' => 3, 'skill' => 2, 'roles' => ['Role_1']],453            40 => ['user' => 4, 'skill' => 2, 'roles' => ['Role_2']],454        ]);455        $result = $data->groupBy(['skill', fn($item) => $item['roles']], true);456        $this->assertEquals(457            [458                1 => [459                    'Role_1' => [460                        10 => ['user' => 1, 'skill' => 1, 'roles' => ['Role_1', 'Role_3']],461                        20 => ['user' => 2, 'skill' => 1, 'roles' => ['Role_1', 'Role_2']],462                    ],463                    'Role_2' => [464                        20 => ['user' => 2, 'skill' => 1, 'roles' => ['Role_1', 'Role_2']],465                    ],466                    'Role_3' => [467                        10 => ['user' => 1, 'skill' => 1, 'roles' => ['Role_1', 'Role_3']],468                    ],469                ],470                2 => [471                    'Role_1' => [472                        30 => ['user' => 3, 'skill' => 2, 'roles' => ['Role_1']],473                    ],474                    'Role_2' => [475                        40 => ['user' => 4, 'skill' => 2, 'roles' => ['Role_2']],476                    ],477                ],478            ],479            $result->toArray()480        );481    }482    /**483     * @depends testMake484     */485    public function testHas(): void486    {487        $collection = Collection::make(['account_id' => 1, 'product' => 'Desk', 'amount' => 5]);488        $this->assertTrue($collection->has('product'));489        $this->assertTrue($collection->has(['product', 'amount']));490        $this->assertFalse($collection->has(['amount', 'price']));491    }492    /**493     * @depends testMake494     */495    public function testImplode(): void496    {497        $collection = Collection::make([498            ['account_id' => 1, 'product' => 'Desk'],499            ['account_id' => 2, 'product' => 'Chair'],500        ]);501        $this->assertSame('Desk, Chair', $collection->implode(', ', 'product'));502        $this->assertSame('1-2-3-4-5', Collection::make([1, 2, 3, 4, 5])->implode('-'));503    }504    /**505     * @depends testMake506     * @depends testAll507     */508    public function testIntersect(): void509    {510        $collection = Collection::make(['Desk', 'Sofa', 'Chair']);511        $intersect = $collection->intersect(['Desk', 'Chair', 'Bookcase']);512        $this->assertSame([0 => 'Desk', 2 => 'Chair'], $intersect->all());513    }514    /**515     * @depends testMake516     * @depends testAll517     */518    public function testIntersectByKeys(): void519    {520        $collection = Collection::make([521            'serial' => 'UX301', 'type' => 'screen', 'year' => 2009,522        ]);523        $intersect = $collection->intersectByKeys([524            'reference' => 'UX404', 'type' => 'tab', 'year' => 2011,525        ]);526        $this->assertSame(['type' => 'screen', 'year' => 2009], $intersect->all());527    }528    /**529     * @depends testMake530     */531    public function testIsEmpty(): void532    {533        $this->assertTrue(Collection::make([])->isEmpty());534        $this->assertFalse(Collection::make([1])->isEmpty());535    }536    /**537     * @depends testMake538     */539    public function testIsNotEmpty(): void540    {541        $this->assertFalse(Collection::make([])->isNotEmpty());542        $this->assertTrue(Collection::make([1])->isNotEmpty());543    }544    /**545     * @depends testMake546     */547    public function testJoin(): void548    {549        $this->assertSame('a, b, c', Collection::make(['a', 'b', 'c'])->join(', '));550        $this->assertSame('a, b, and c', Collection::make(['a', 'b', 'c'])->join(', ', ', and '));551        $this->assertSame('a and b', Collection::make(['a', 'b'])->join(', ', ' and '));552        $this->assertSame('a', Collection::make(['a'])->join(', ', ' and '));553        $this->assertSame('', Collection::make([])->join(', ', ' and '));554    }555    /**556     * @depends testMake557     * @depends testAll558     */559    public function testKeyBy(): void560    {561        $collection = Collection::make([562            ['product_id' => 'prod-100', 'name' => 'Desk'],563            ['product_id' => 'prod-200', 'name' => 'Chair'],564        ]);565        $keyed = $collection->keyBy('product_id');566        $this->assertSame(567            [568                'prod-100' => ['product_id' => 'prod-100', 'name' => 'Desk'],569                'prod-200' => ['product_id' => 'prod-200', 'name' => 'Chair'],570            ],571            $keyed->all()572        );573        $keyed = $collection->keyBy(fn($item) => strtoupper($item['product_id']));574        $this->assertSame(575            [576                'PROD-100' => ['product_id' => 'prod-100', 'name' => 'Desk'],577                'PROD-200' => ['product_id' => 'prod-200', 'name' => 'Chair'],578            ],579            $keyed->all()580        );581    }582    /**583     * @depends testMake584     * @depends testAll585     */586    public function testKeys(): void587    {588        $collection = Collection::make([589            'prod-100' => ['product_id' => 'prod-100', 'name' => 'Desk'],590            'prod-200' => ['product_id' => 'prod-200', 'name' => 'Chair'],591        ]);592        $keys = $collection->keys();593        $this->assertSame(['prod-100', 'prod-200'], $keys->all());594    }595    /**596     * @depends testMake597     */598    public function testLast(): void599    {600        $collection = Collection::make([1, 2, 3, 4]);601        $this->assertSame(2, $collection->last(fn($value, $key) => $value < 3));602        $this->assertSame(4, $collection->last());603    }604    /**605     * @depends testMake606     */607    public function testMap(): void608    {609        $collection = Collection::make([1, 2, 3, 4, 5]);610        $this->assertSame([2, 4, 6, 8, 10], $collection->map(fn($item, $key) => $item * 2)->all());611    }612    public function testMapInto(): void613    {614        $this->markTestIncomplete();615    }616    /**617     * @depends testMake618     * @depends testAll619     */620    public function testMapSpread(): void621    {622        $collection = Collection::make([0, 1, 2, 3, 4, 5, 6, 7, 8, 9]);623        $chunks = $collection->chunk(2);624        $sequence = $chunks->mapSpread(function ($even, $odd) {625            return $even + $odd;626        });627        $this->assertSame([1, 5, 9, 13, 17], $sequence->all());628    }629    /**630     * @depends testMake631     * @depends testToArray632     * @depends testGet633     */634    public function testMapToGroups(): void635    {636        $collection = Collection::make([637            [638                'name' => 'John Doe',639                'department' => 'Sales',640            ],641            [642                'name' => 'Jane Doe',643                'department' => 'Sales',644            ],645            [646                'name' => 'Johnny Doe',647                'department' => 'Marketing',648            ],649        ]);650        $grouped = $collection->mapToGroups(function ($item, $key) {651            return [$item['department'] => $item['name']];652        });653        $this->assertSame(654            [655                'Sales' => ['John Doe', 'Jane Doe'],656                'Marketing' => ['Johnny Doe'],657            ],658            $grouped->toArray()659        );660        $this->assertSame(['John Doe', 'Jane Doe'], $grouped->get('Sales')->toArray());661    }662    public function testMapToDictionary(): void663    {664        $this->markTestIncomplete();665    }666    /**667     * @depends testMake668     * @depends testAll669     */670    public function testMapWithKeys(): void671    {672        $collection = Collection::make([673            [674                'name' => 'John',675                'department' => 'Sales',676                'email' => 'john@example.com',677            ],678            [679                'name' => 'Jane',680                'department' => 'Marketing',681                'email' => 'jane@example.com',682            ],683        ]);684        $keyed = $collection->mapWithKeys(function ($item, $key) {685            return [$item['email'] => $item['name']];686        });687        $this->assertSame(688            [689                'john@example.com' => 'John',690                'jane@example.com' => 'Jane',691            ],692            $keyed->all()693        );694    }695    /**696     * @depends testMake697     */698    public function testMax(): void699    {700        $collection = Collection::make([701            ['foo' => 10],702            ['foo' => 20],703        ]);704        $this->assertSame(20, $collection->max('foo'));705        $this->assertSame(5, Collection::make([1, 2, 3, 4, 5])->max());706    }707    /**708     * @depends testMake709     */710    public function testMedian(): void711    {712        $collection = Collection::make([713            ['foo' => 10],714            ['foo' => 10],715            ['foo' => 20],716            ['foo' => 40],717        ]);718        $this->assertSame(15.0, $collection->median('foo'));719        $this->assertSame(1.5, Collection::make([1, 1, 2, 4])->median());720    }721    /**722     * @depends testMake723     * @depends testAll724     */725    public function testMerge(): void726    {727        $collection = Collection::make(['product_id' => 1, 'price' => 100]);728        $merged = $collection->merge(['price' => 200, 'discount' => false]);729        $this->assertSame(['product_id' => 1, 'price' => 200, 'discount' => false], $merged->all());730        $collection = Collection::make(['Desk', 'Chair']);731        $merged = $collection->merge(['Bookcase', 'Door']);732        $this->assertSame(['Desk', 'Chair', 'Bookcase', 'Door'], $merged->all());733    }734    /**735     * @depends testMake736     * @depends testAll737     */738    public function testMergeRecursive(): void739    {740        $collection = Collection::make(['product_id' => 1, 'price' => 100]);741        $merged = $collection->mergeRecursive([742            'product_id' => 2,743            'price' => 200,744            'discount' => false,745        ]);746        $this->assertSame(['product_id' => [1, 2], 'price' => [100, 200], 'discount' => false], $merged->all());747    }748    /**749     * @depends testMake750     */751    public function testMin(): void752    {753        $this->assertSame(10, Collection::make([['foo' => 10], ['foo' => 20]])->min('foo'));754        $this->assertSame(1, Collection::make([1, 2, 3, 4, 5])->min());755    }756    /**757     * @depends testMake758     */759    public function testMode(): void760    {761        $mode = Collection::make([762            ['foo' => 10],763            ['foo' => 10],764            ['foo' => 20],765            ['foo' => 40],766        ])->mode('foo');767        $this->assertSame([10], $mode);768        $this->assertSame([1], Collection::make([1, 1, 2, 4])->mode());769        $this->assertSame([1, 2], Collection::make([1, 1, 2, 2])->mode());770    }771    /**772     * @depends testMake773     * @depends testAll774     */775    public function testNth(): void776    {777        $collection = Collection::make(['a', 'b', 'c', 'd', 'e', 'f']);778        $this->assertSame(['a', 'e'], $collection->nth(4)->all());779        $this->assertSame(['b', 'f'], $collection->nth(4, 1)->all());780    }781    /**782     * @depends testMake783     * @depends testAll784     */785    public function testOnly(): void786    {787        $collection = Collection::make([788            'product_id' => 1,789            'name' => 'Desk',790            'price' => 100,791            'discount' => false,792        ]);793        $filtered = $collection->only(['product_id', 'name']);794        $this->assertSame(['product_id' => 1, 'name' => 'Desk'], $filtered->all());795    }796    /**797     * @depends testMake798     * @depends testAll799     */800    public function testPad(): void801    {802        $collection = Collection::make(['A', 'B', 'C']);803        $filtered = $collection->pad(5, 0);804        $this->assertSame(['A', 'B', 'C', 0, 0], $filtered->all());805        $filtered = $collection->pad(-5, 0);806        $this->assertSame([0, 0, 'A', 'B', 'C'], $filtered->all());807    }808    /**809     * @depends testMake810     * @depends testAll811     */812    public function testPartition(): void813    {814        $collection = Collection::make([1, 2, 3, 4, 5, 6]);815        [$underThree, $equalOrAboveThree] = $collection->partition(fn($i) => $i < 3);816        $underThree->all();817        $this->assertSame([0 => 1, 1 => 2], $underThree->all());818        $this->assertSame([2 => 3, 3 => 4, 4 => 5, 5 => 6], $equalOrAboveThree->all());819    }820    /**821     * @depends testMake822     * @depends testSum823     */824    public function testPipe(): void825    {826        $collection = Collection::make([1, 2, 3]);827        $this->assertSame(6, $collection->pipe(fn($collection) => $collection->sum()));828    }829    public function testPipeInto(): void830    {831        $this->markTestIncomplete();832    }833    public function testPluck(): void834    {835        $this->markTestIncomplete();836    }837    public function testPop(): void838    {839        $this->markTestIncomplete();840    }841    public function testPrepend(): void842    {843        $this->markTestIncomplete();844    }845    public function testPull(): void846    {847        $this->markTestIncomplete();848    }849    /**850     * @depends testMake851     * @depends testAll852     */853    public function testPush(): void854    {855        $collection = Collection::make([1, 2, 3, 4]);856        $collection->push(5);857        $this->assertSame([1, 2, 3, 4, 5], $collection->all());858    }859    /**860     * @depends testMake861     * @depends testAll862     */863    public function testPut(): void864    {865        $collection = Collection::make(['product_id' => 1, 'name' => 'Desk']);866        $collection->put('price', 100);867        $this->assertSame(['product_id' => 1, 'name' => 'Desk', 'price' => 100], $collection->all());868    }869    public function testRandom(): void870    {871        $this->markTestIncomplete();872    }873    /**874     * @depends testMake875     */876    public function testReduce(): void877    {878        $collection = Collection::make([1, 2, 3]);879        $total = $collection->reduce(fn($carry, $item) => $carry + $item);880        $this->assertSame(6, $total);881        $total = $collection->reduce(fn($carry, $item) => $carry + $item, 4);882        $this->assertSame(10, $total);883        $collection = Collection::make([884            'usd' => 1400,885            'gbp' => 1200,886            'eur' => 1000,887        ]);888        $ratio = [889            'usd' => 1,890            'gbp' => 1.37,891            'eur' => 1.22,892        ];893        $total = $collection->reduce(fn($carry, $value, $key) => $carry + ($value * $ratio[$key]));894        $this->assertSame(4264.0, $total);895    }896    /**897     * @depends testMake898     * @depends testAll899     */900    public function testReject(): void901    {902        $collection = Collection::make([1, 2, 3, 4]);903        $filtered = $collection->reject(fn($value, $key) => $value > 2);904        $this->assertSame([1, 2], $filtered->all());905    }906    /**907     * @depends testMake908     * @depends testAll909     */910    public function testReplace(): void911    {912        $collection = Collection::make(['Taylor', 'Abigail', 'James']);913        $replaced = $collection->replace([1 => 'Victoria', 3 => 'Finn']);914        $this->assertSame(['Taylor', 'Victoria', 'James', 'Finn'], $replaced->all());915    }916    /**917     * @depends testMake918     * @depends testAll919     */920    public function testReplaceRecursive(): void921    {922        $collection = Collection::make([923            'Taylor',924            'Abigail',925            [926                'James',927                'Victoria',928                'Finn',929            ],930        ]);931        $replaced = $collection->replaceRecursive([932            'Charlie',933            2 => [1 => 'King'],934        ]);935        $this->assertSame(['Charlie', 'Abigail', ['James', 'King', 'Finn']], $replaced->all());936    }937    /**938     * @depends testMake939     * @depends testAll940     */941    public function testReverse(): void942    {943        $collection = Collection::make(['a', 'b', 'c', 'd', 'e']);944        $reversed = $collection->reverse();945        $this->assertSame(946            [947                4 => 'e',948                3 => 'd',949                2 => 'c',950                1 => 'b',951                0 => 'a',952            ],953            $reversed->all()954        );955    }956    /**957     * @depends testMake958     * @depends testAll959     */960    public function testSearch(): void961    {962        $collection = Collection::make([2, 4, 6, 8]);963        $this->assertSame(1, $collection->search(4));964        $this->assertFalse(Collection::make([2, 4, 6, 8])->search('4', true));965        $this->assertSame(2, Collection::make([2, 4, 6, 8])->search(fn($item, $key) => $item > 5));966    }967    /**968     * @depends testMake969     * @depends testAll970     */971    public function testShift(): void972    {973        $collection = Collection::make([1, 2, 3, 4, 5]);974        $this->assertSame(1, $collection->shift());975        $this->assertSame([2, 3, 4, 5], $collection->all());976        $collection = Collection::make([1, 2, 3, 4, 5]);977        $shifted = $collection->shift(3);978        $this->assertSame([1, 2, 3], $shifted->all());979        $this->assertSame([4, 5], $collection->all());980    }981    public function testShuffle(): void982    {983        $this->markTestIncomplete();984    }985    public function testSliding(): void986    {987        $this->markTestIncomplete();988    }989    /**990     * @depends testMake991     * @depends testAll992     */993    public function testSkip(): void994    {995        $collection = Collection::make([1, 2, 3, 4, 5, 6, 7, 8, 9, 10]);996        $collection = $collection->skip(4);997        $this->assertSame([5, 6, 7, 8, 9, 10], $collection->all());998    }999    /**1000     * @depends testMake1001     * @depends testAll1002     */1003    public function testSkipUntil(): void1004    {1005        $collection = Collection::make([1, 2, 3, 4]);1006        $subset = $collection->skipUntil(fn($item) => $item >= 3);1007        $this->assertSame([3, 4], $subset->all());1008        $collection = Collection::make([1, 2, 3, 4]);1009        $subset = $collection->skipUntil(3);1010        $this->assertSame([3, 4], $subset->all());1011    }1012    /**1013     * @depends testMake1014     * @depends testAll1015     */1016    public function testSkipWhile(): void1017    {1018        $collection = Collection::make([1, 2, 3, 4]);1019        $subset = $collection->skipWhile(fn($item) => $item <= 3);1020        $this->assertSame([4], $subset->all());1021    }1022    /**1023     * @depends testMake1024     * @depends testAll1025     */1026    public function testSlice(): void1027    {1028        $collection = Collection::make([1, 2, 3, 4, 5, 6, 7, 8, 9, 10]);1029        $slice = $collection->slice(4);1030        $this->assertSame([5, 6, 7, 8, 9, 10], $slice->all());1031        $slice = $collection->slice(4, 2);1032        $this->assertSame([5, 6], $slice->all());1033    }1034    /**1035     * @depends testMake1036     * @depends testAll1037     */1038    public function testSole(): void1039    {1040        $this->assertSame(2, Collection::make([1, 2, 3, 4])->sole(value: fn($value, $key) => $value === 2));1041        $collection = Collection::make([1042            ['product' => 'Desk', 'price' => 200],1043            ['product' => 'Chair', 'price' => 100],1044        ]);1045        $this->assertSame(['product' => 'Chair', 'price' => 100], $collection->sole(key: 'product', value: 'Chair'));1046        $collection = Collection::make([1047            ['product' => 'Desk', 'price' => 200],1048        ]);1049        $this->assertSame(['product' => 'Desk', 'price' => 200], $collection->sole());1050    }1051    public function testSome(): void1052    {1053        $this->markTestIncomplete();1054    }1055    public function testSort(): void1056    {1057        $this->markTestIncomplete();1058    }1059    public function testSortBy(): void1060    {1061        $this->markTestIncomplete();1062    }1063    public function testSortByDesc(): void1064    {1065        $this->markTestIncomplete();1066    }1067    public function testSortDesc(): void1068    {1069        $this->markTestIncomplete();1070    }1071    public function testSortKeys(): void1072    {1073        $this->markTestIncomplete();1074    }1075    public function testSortKeysDesc(): void1076    {1077        $this->markTestIncomplete();1078    }1079    public function testSplice(): void1080    {1081        $this->markTestIncomplete();1082    }1083    public function testSplit(): void1084    {1085        $this->markTestIncomplete();1086    }1087    public function testSplitIn(): void1088    {1089        $this->markTestIncomplete();1090    }1091    /**1092     * @depends testMake1093     */1094    public function testSum(): void1095    {1096        $this->assertSame(15, Collection::make([1, 2, 3, 4, 5])->sum());1097        $collection = Collection::make([1098            ['name' => 'JavaScript: The Good Parts', 'pages' => 176],1099            ['name' => 'JavaScript: The Definitive Guide', 'pages' => 1096],1100        ]);1101        $this->assertSame(1272, $collection->sum('pages'));1102        $collection = Collection::make([1103            ['name' => 'Chair', 'colors' => ['Black']],1104            ['name' => 'Desk', 'colors' => ['Black', 'Mahogany']],1105            ['name' => 'Bookcase', 'colors' => ['Red', 'Beige', 'Brown']],1106        ]);1107        $this->assertSame(6, $collection->sum(fn($product) => count($product['colors'])));1108    }1109    /**1110     * @depends testMake1111     * @depends testAll1112     */1113    public function testTake(): void1114    {1115        $collection = Collection::make([0, 1, 2, 3, 4, 5]);1116        $chunk = $collection->take(3);1117        $this->assertSame([0, 1, 2], $chunk->all());1118        $collection = Collection::make([0, 1, 2, 3, 4, 5]);1119        $chunk = $collection->take(-2);1120        $this->assertSame([4, 5], $chunk->all());1121    }1122    /**1123     * @depends testMake1124     * @depends testAll1125     */1126    public function testTakeUntil(): void1127    {1128        $collection = Collection::make([1, 2, 3, 4]);1129        $subset = $collection->takeUntil(fn($item) => $item >= 3);1130        $this->assertSame([1, 2], $subset->all());1131        $collection = Collection::make([1, 2, 3, 4]);1132        $subset = $collection->takeUntil(3);1133        $this->assertSame([1, 2], $subset->all());1134    }1135    /**1136     * @depends testMake1137     * @depends testAll1138     */1139    public function testTakeWhile(): void1140    {1141        $collection = Collection::make([1, 2, 3, 4]);1142        $subset = $collection->takeWhile(fn($item) => $item < 3);1143        $this->assertSame([1, 2], $subset->all());1144    }1145    public function testTap(): void1146    {1147        $this->markTestIncomplete();1148    }1149    /**1150     * @depends testMake1151     */1152    public function testToArray(): void1153    {1154        $collection = Collection::make(['name' => 'Desk', 'price' => 200]);1155        $this->assertSame(['name' => 'Desk', 'price' => 200], $collection->toArray());1156    }1157    /**1158     * @depends testMake1159     */1160    public function testToJson(): void1161    {1162        $collection = Collection::make(['name' => 'Desk', 'price' => 200]);1163        $this->assertSame('{"name":"Desk","price":200}', $collection->toJson());1164    }1165    /**1166     * @depends testMake1167     * @depends testAll1168     */1169    public function testTransform(): void1170    {1171        $collection = Collection::make([1, 2, 3, 4, 5]);1172        $collection->transform(fn($item, $key) => $item * 2);1173        $this->assertSame([2, 4, 6, 8, 10], $collection->all());1174    }1175    /**1176     * @depends testMake1177     * @depends testAll1178     */1179    public function testUnion(): void1180    {1181        $collection = Collection::make([1 => ['a'], 2 => ['b']]);1182        $union = $collection->union([3 => ['c'], 1 => ['d']]);1183        $this->assertSame([1 => ['a'], 2 => ['b'], 3 => ['c']], $union->all());1184    }1185    /**1186     * @depends testMake1187     * @depends testAll1188     * @depends testValues1189     */1190    public function testUnique(): void1191    {1192        $collection = Collection::make([1, 1, 2, 2, 3, 4, 2]);1193        $unique = $collection->unique();1194        $this->assertSame([1, 2, 3, 4], $unique->values()->all());1195        $collection = Collection::make([1196            ['name' => 'iPhone 6', 'brand' => 'Apple', 'type' => 'phone'],1197            ['name' => 'iPhone 5', 'brand' => 'Apple', 'type' => 'phone'],1198            ['name' => 'Apple Watch', 'brand' => 'Apple', 'type' => 'watch'],1199            ['name' => 'Galaxy S6', 'brand' => 'Samsung', 'type' => 'phone'],1200            ['name' => 'Galaxy Gear', 'brand' => 'Samsung', 'type' => 'watch'],1201        ]);1202        $unique = $collection->unique('brand');1203        $this->assertSame(1204            [1205                ['name' => 'iPhone 6', 'brand' => 'Apple', 'type' => 'phone'],1206                ['name' => 'Galaxy S6', 'brand' => 'Samsung', 'type' => 'phone'],1207            ],1208            $unique->values()->all()1209        );1210        $unique = $collection->unique(fn($item) => $item['brand'] . $item['type']);1211        $this->assertSame(1212            [1213                ['name' => 'iPhone 6', 'brand' => 'Apple', 'type' => 'phone'],1214                ['name' => 'Apple Watch', 'brand' => 'Apple', 'type' => 'watch'],1215                ['name' => 'Galaxy S6', 'brand' => 'Samsung', 'type' => 'phone'],1216                ['name' => 'Galaxy Gear', 'brand' => 'Samsung', 'type' => 'watch'],1217            ],1218            $unique->values()->all()1219        );1220    }1221    public function testUniqueStrict(): void1222    {1223        $this->markTestIncomplete();1224    }1225    /**1226     * @depends testMake1227     * @depends testAll1228     * @depends testPush1229     */1230    public function testUnless(): void1231    {1232        $collection = Collection::make([1, 2, 3]);1233        $collection->unless(true, fn(Collection $collection) => $collection->push(4));1234        $collection->unless(false, fn(Collection $collection) => $collection->push(5));1235        $this->assertSame([1, 2, 3, 5], $collection->all());1236    }1237    public function testUnlessEmpty(): void1238    {1239        $this->markTestIncomplete();1240    }1241    public function testUnlessNotEmpty(): void1242    {1243        $this->markTestIncomplete();1244    }1245    /**1246     * @depends testMake1247     * @depends testAll1248     */1249    public function testValues(): void1250    {1251        $collection = Collection::make([1252            10 => ['product' => 'Desk', 'price' => 200],1253            11 => ['product' => 'Desk', 'price' => 200],1254        ]);1255        $values = $collection->values();1256        $this->assertSame(1257            [1258                0 => ['product' => 'Desk', 'price' => 200],1259                1 => ['product' => 'Desk', 'price' => 200],1260            ],1261            $values->all()1262        );1263    }1264    public function testWhen(): void1265    {1266        $this->markTestIncomplete();1267    }1268    public function testWhenEmpty(): void1269    {1270        $this->markTestIncomplete();1271    }1272    public function testWhenNotEmpty(): void1273    {1274        $this->markTestIncomplete();1275    }1276    public function testWhere(): void1277    {1278        $this->markTestIncomplete();1279    }1280    public function testWhereStrict(): void1281    {1282        $this->markTestIncomplete();1283    }1284    public function testWhereBetween(): void1285    {1286        $this->markTestIncomplete();1287    }1288    public function testWhereIn(): void1289    {1290        $this->markTestIncomplete();1291    }1292    public function testWhereInStrict(): void1293    {1294        $this->markTestIncomplete();1295    }1296    public function testWhereInstanceOf(): void1297    {1298        $this->markTestIncomplete();1299    }1300    public function testWhereNotBetween(): void1301    {1302        $this->markTestIncomplete();1303    }1304    public function testWhereNotIn(): void1305    {1306        $this->markTestIncomplete();1307    }1308    public function testWhereNotInStrict(): void1309    {1310        $this->markTestIncomplete();1311    }1312    public function testWhereNotNull(): void1313    {1314        $this->markTestIncomplete();1315    }1316    public function testWhereNull(): void1317    {1318        $this->markTestIncomplete();1319    }1320    public function testZip(): void1321    {1322        $this->markTestIncomplete();1323    }1324    /**1325     * @depends testMake1326     */1327    public function testCount(): void1328    {1329        $collection = Collection::make([1, 2, 3, 4]);1330        $this->assertSame(4, $collection->count());1331    }1332    public function testOffsetSet(): void1333    {1334        $this->markTestIncomplete();1335    }1336    public function testOffsetExists(): void1337    {1338        $this->markTestIncomplete();1339    }...variable.php
Source:variable.php  
...30			->object($diff->setData($variable = uniqid()))->isIdenticalTo($diff)31			->string($diff->getData())->isEqualTo(self::dumpAsString($variable))32		;33	}34	public function testMake()35	{36		$diff = new tools\diffs\variable();37		$exception = null;38		try39		{40			$diff->make();41		}42		catch (\exception $exception) {}43		$this->assert44			->exception($exception)45				->isInstanceOf('mageekguy\atoum\exceptions\runtime')46				->hasMessage('Reference is undefined')47		;48		$diff->setReference($reference = uniqid());...testMake
Using AI Code Generation
1require_once 'diff.php';2$diff = new diff();3echo $diff->testMake();4require_once 'diff.php';5$diff = new diff();6echo $diff->testMake();testMake
Using AI Code Generation
1$diff = new diff();2$diff->testMake();3$diff = new diff();4$diff->testMake();5$diff = new diff();6$diff->testMake();7$diff = new diff();8$diff->testMake();9$diff = new diff();10$diff->testMake();11$diff = new diff();12$diff->testMake();13$diff = new diff();14$diff->testMake();15$diff = new diff();16$diff->testMake();17$diff = new diff();18$diff->testMake();19$diff = new diff();20$diff->testMake();21$diff = new diff();22$diff->testMake();23$diff = new diff();24$diff->testMake();25$diff = new diff();26$diff->testMake();27$diff = new diff();28$diff->testMake();29$diff = new diff();30$diff->testMake();31$diff = new diff();32$diff->testMake();33$diff = new diff();34$diff->testMake();testMake
Using AI Code Generation
1require_once 'diff.php';2$diff = new Diff();3echo $diff->testMake();4require_once 'diff.php';5$diff = new Diff();6echo $diff->make();7require_once 'diff.php';8$diff = new Diff();9echo $diff->testMake();10require_once 'diff.php';11$diff = new Diff();12echo $diff->make();13require_once 'diff.php';14$diff = new Diff();15echo $diff->testMake();16require_once 'diff.php';17$diff = new Diff();18echo $diff->make();19require_once 'diff.php';20$diff = new Diff();21echo $diff->testMake();22require_once 'diff.php';23$diff = new Diff();24echo $diff->make();25require_once 'diff.php';26$diff = new Diff();27echo $diff->testMake();28require_once 'diff.php';29$diff = new Diff();30echo $diff->make();31require_once 'diff.php';32$diff = new Diff();33echo $diff->testMake();34require_once 'diff.php';35$diff = new Diff();36echo $diff->make();37require_once 'diff.php';38$diff = new Diff();39echo $diff->testMake();40require_once 'diff.php';41$diff = new Diff();42echo $diff->make();testMake
Using AI Code Generation
1require_once('diff.php');2$diff = new Diff();3echo $diff->testMake();4require_once('diff.php');5$diff = new Diff();6echo $diff->testMake();7{8    public function testMake()9    {10        return 'test';11    }12}13require_once('diff.php');14$diff = new Diff();15echo $diff->testMake();16require_once('diff.php');17$diff = new Diff();18echo $diff->testMake();19{20    public function testMake()21    {22        return 'test';23    }24}testMake
Using AI Code Generation
1include("diff.php");2$diff = new diff;3$diff->testMake();4include("diff.php");5$diff = new diff;6$diff->testMake();7include("diff.php");8$diff = new diff;9$diff->testMake();10include("diff.php");11$diff = new diff;12$diff->testMake();13include("diff.php");14$diff = new diff;15$diff->testMake();16include("diff.php");17$diff = new diff;18$diff->testMake();19include("diff.php");20$diff = new diff;21$diff->testMake();22include("diff.php");23$diff = new diff;24$diff->testMake();25include("diff.php");26$diff = new diff;27$diff->testMake();28include("diff.php");29$diff = new diff;30$diff->testMake();31include("diff.php");32$diff = new diff;33$diff->testMake();34include("diff.php");35$diff = new diff;36$diff->testMake();37include("diff.php");38$diff = new diff;39$diff->testMake();40include("diff.php");41$diff = new diff;42$diff->testMake();43include("diff.php");testMake
Using AI Code Generation
1$test = new Diff();2$test->testMake();3$test = new Diff();4$test->testMake();5$test = new Diff();6$test->testMake();7$test = new Diff();8$test->testMake();9$test = new Diff();10$test->testMake();11$test = new Diff();12$test->testMake();13$test = new Diff();14$test->testMake();15$test = new Diff();16$test->testMake();17$test = new Diff();18$test->testMake();19$test = new Diff();20$test->testMake();21$test = new Diff();22$test->testMake();23$test = new Diff();24$test->testMake();25$test = new Diff();26$test->testMake();27$test = new Diff();28$test->testMake();29$test = new Diff();30$test->testMake();31$test = new Diff();32$test->testMake();33$test = new Diff();34$test->testMake();testMake
Using AI Code Generation
1include 'diff.php';2$diff = new diff();3$diff->testMake();4class diff{5    function testMake(){6        echo 'testMake';7    }8}9Fatal error: Call to undefined method diff::testMake() in C:\wamp\www\1.php on line 710$diff = new diff();11$diff->testMake();testMake
Using AI Code Generation
1$diff = new diff;2$diff->testMake();3public function testMake() {4    $a = array('a' => 'apple', 'b' => 'banana', 'c' => 'cranberry');5    $b = array('a' => 'apple', 'b' => 'banana', 'c' => 'cranberry', 'd' => 'durian');6    $c = array('a' => 'apple', 'b' => 'banana', 'c' => 'cranberry', 'd' => 'durian', 'e' => 'eggplant');7    $d = array('a' => 'apple', 'b' => 'banana', 'c' => 'cranberry', 'd' => 'durian', 'e' => 'eggplant', 'f' => 'fig');8    $e = array('a' => 'apple', 'b' => 'banana', 'c' => 'cranberry', 'd' => 'durian', 'e' => 'eggplant', 'f' => 'fig', 'g' => 'grape');9    $f = array('a' => 'apple', 'b' => 'banana', 'c' => 'cranberry', 'd' => 'durian', 'e' => 'eggplant', 'f' => 'fig', 'g' => 'grape', 'h' => 'honeydew');10    $g = array('a' => 'apple', 'b' => 'banana', 'c' => 'cranberry', 'd' => 'durian', 'e' => 'eggplant', 'f' => 'fig', 'g' => 'grape', 'h' => 'honeydew', 'i' => 'ice cream');11    $h = array('a' => 'apple', 'b' => 'banana', 'c' => 'cranberry', 'd' => 'durian', 'e' => 'eggplant', 'f' => 'fig', 'g' => 'grape', 'h' => 'honeydew', 'i' => 'ice cream', 'j' => 'jackfruit');12    $i = array('a' => 'apple',Learn to execute automation testing from scratch with LambdaTest Learning Hub. Right from setting up the prerequisites to run your first automation test, to following best practices and diving deeper into advanced test scenarios. LambdaTest Learning Hubs compile a list of step-by-step guides to help you be proficient with different test automation frameworks i.e. Selenium, Cypress, TestNG etc.
You could also refer to video tutorials over LambdaTest YouTube channel to get step by step demonstration from industry experts.
Execute automation tests with testMake on a cloud-based Grid of 3000+ real browsers and operating systems for both web and mobile applications.
Test now for FreeGet 100 minutes of automation test minutes FREE!!
