定制 sven/laravel-collection-testing-helpers 二次开发

按需修改功能、优化性能、对接业务系统,提供一站式技术支持

邮箱:yvsm@zunyunkeji.com | QQ:316430983 | 微信:yvsm316

sven/laravel-collection-testing-helpers

Composer 安装命令:

composer require --dev sven/laravel-collection-testing-helpers

包简介

Convenience methods on your Laravel collections for testing

README 文档

README

Laravel Collection Testing Helpers

Laravel Collection Testing Helpers

Latest Version on Packagist Total Downloads Software License Build Status StyleCI

This package adds several convenience methods to your Laravel collections to make assertions against them more fluent and readable.

Installation

You'll have to follow a couple of simple steps to install this package.

Downloading

Via composer:

$ composer require sven/laravel-collection-testing-helpers --dev

Or add the package to your development dependencies in composer.json and run composer update on the command line to download the package:

{
    "require-dev": {
        "sven/laravel-collection-testing-helpers": "^1.0"
    }
}

Usage

To use this package in your tests, you must first call the \Sven\LaravelCollectionTestingHelpers\Helpers::enable() method where you want to use the assertions. You may then use the methods directly on your collections:

<?php

use Sven\LaravelCollectionTestingHelpers\Helpers;
use Illuminate\Foundation\Testing\TestCase;

class ExampleTest extends TestCase
{
    public function test_collections()
    {
        Helpers::enable();
        
        collect(['apple', 'pear', 'banana'])
            ->assertContains('apple')
            ->assertNotContains('orange');
    }

    public function test_callable_filtering()
    {
        Helpers::enable();
        
        collect(['apple', 'pear', 'banana'])
            ->assertContains(fn ($fruit) => $fruit === 'pear')
            ->assertNotContains(fn ($fruit) => $fruit === 'kiwi');
    }

    public function test_keyed_collections()
    {
        Helpers::enable();
        
        collect([['name' => 'apple'], ['name' => 'pear'], ['name' => 'banana']])
            ->assertContains('name', 'apple')
            ->assertNotContains('name', 'grape');
    }
}

Credits

Big thanks to @eduarguz for his original work on this in the now-abandoned sven/laravel-testing-utils package.

Contributing

All contributions (pull requests, issues and feature requests) are welcome. Make sure to read through the CONTRIBUTING.md first, though. See the contributors page for all contributors.

License

sven/laravel-collection-testing-helpers is licensed under the MIT License (MIT). Please see the license file for more information.

统计信息

  • 总下载量: 5
  • 月度下载量: 0
  • 日度下载量: 0
  • 收藏数: 1
  • 点击次数: 0
  • 依赖项目数: 0
  • 推荐数: 0

GitHub 信息

  • Stars: 1
  • Watchers: 1
  • Forks: 0
  • 开发语言: PHP

其他信息

  • 授权协议: MIT
  • 更新时间: 2021-04-19

承接程序开发

PHP开发

VUE

Vue开发

前端开发

小程序开发

公众号开发

系统定制

数据库设计

云部署

网站建设

安全加固