<?php namespace Illuminate\Tests\Support; use stdClass; use ArrayAccess; use Mockery as m; use ReflectionClass; use JsonSerializable; use PHPUnit\Framework\TestCase; use Illuminate\Support\Collection; use Illuminate\Contracts\Support\Jsonable; use Illuminate\Contracts\Support\Arrayable; class SupportCollectionTest extends TestCase { public function testFirstReturnsFirstItemInCollection() { $c = new Collection(['foo', 'bar']); $this->assertEquals('foo', $c->first()); } public function testFirstWithCallback() { $data = new Collection(['foo', 'bar', 'baz']); $result = $data->first(function ($value) { return $value === 'bar'; }); $this->assertEquals('bar', $result); }
PHP's Laravel collection library is a library for obtaining a collection. A collection is equivalent to a table.
All resources on this site are contributed by netizens or reprinted by major download sites. Please check the integrity of the software yourself! All resources on this site are for learning reference only. Please do not use them for commercial purposes. Otherwise, you will be responsible for all consequences! If there is any infringement, please contact us to delete it. Contact information: admin@php.cn
Related Article
06 Jul 2016
I have seen many open source projects in the form of class.classname.php, but I have also seen many frameworks in the form of classname.class.php. Where should I place this class? I personally prefer the .class.php form, because in some frameworks, after importing third-party class libraries and specifying class libraries...
05 Jan 2025
PHP ORM Library RecommendationsWhen it comes to object-relational mapping (ORM) for PHP, there are several libraries that stand out. To address...
18 Oct 2024
PhpMailer vs. SwiftMailer: Comparing Email LibrariesWhen crafting a PHP script that requires email functionality, developers often face a choice between PhpMailer and SwiftMailer libraries. Navigating this decision can be crucial in finding the best
13 Dec 2024
Linking Static Libraries to Other Static Libraries: A Comprehensive ApproachStatic libraries provide a convenient mechanism to package reusable...
17 Oct 2024
Easiest Form Validation Library for PHPPHP boasts a plethora of validation libraries, each with its own strengths and weaknesses. To identify the ideal choice for your project, it's essential to consider factors such as simplicity, flexibility, and e
30 Nov 2024
I started learning pure PHP in the middle of 2015. Then, I got familiar with CodeIgniter 3 and Laravel 5.1. Through the years, Laravel is my framework of choice, and I'm still sticking with it. Such as other popular PHP projects, I see PHPUnit is the
Hot Tools
PHP library for dependency injection containers
PHP library for dependency injection containers
A collection of 50 excellent classic PHP algorithms
Classic PHP algorithm, learn excellent ideas and expand your thinking
Small PHP library for optimizing images
Small PHP library for optimizing images