承接 dees040/festing 相关项目开发

从需求分析到上线部署,全程专人跟进,保证项目质量与交付效率

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

dees040/festing

Composer 安装命令:

composer require dees040/festing

包简介

Fasten up your unit tests in Laravel by more than 100%

README 文档

README

Latest Stable Version Total Downloads Build status

Festing is a very very great name made by combining the words fast and testing. Because that is what this package is for. Faster tests in Laravel. The package is inspired by a great article from Nate Denlinger.

Before 'Festing':

Before fast database tests

After 'Festing':

After fast database tests

Installation

Installation and setup time is estimated to be around 5 minutes in existing Laravel projects and 2 minutes in new projects. Install this package via composer.

composer require --dev dees040/festing

If you're using Laravel >= 5.5 this package will automatically be added to your providers list. If using a lower version, add the service provider to the providers array in config/app.php.

Dees040\Festing\ServiceProvider::class,

You're now ready for setup.

The package comes with a small config file. The default config should be good in most use cases. However, feel free to change it. To publish the config file run the following command

php artisan vendor:publish --provider="Dees040\Festing\ServiceProvider" --tag="config"

Setup

First you should update the database.php config file. We should add a connection specifically for testing. You can use the following array.

'testing' => [
    'driver' => 'sqlite',
    'database' => database_path('testing.sqlite'),
    'prefix'   => '',
],

In the package config you can specify which connection to use while testing. By default it will use the testing connection, which we've just added to the connections array. You should also add or update this in <php> tag located in the phpunit.xml file.

<env name="DB_CONNECTION" value="testing"/>

Because Laravel don't have an option to boot your testing traits like the model traits we need to add a little bit of functionality in our tests/TestCase.php file. If you haven't overwritten the setUpTraits() method yet, you can add this to the TestCase.php.

use Dees040\Festing\FestTheDatabase;
use Illuminate\Foundation\Testing\TestCase as BaseTestCase;

abstract class TestCase extends BaseTestCase
{
    use CreatesApplication, FestTheDatabase;


    /**
     * Boot the testing helper traits.
     *
     * @return array
     */
    protected function setUpTraits()
    {
        $uses = parent::setUpTraits();
    
        if (isset($uses[\Dees040\Festing\ShouldFest::class])) {
            $this->runFester();
        }
    
        return $uses;
    }

If you already have overwritten the setUpTraits() method just add the if statement to the method body. Also your TestCase.php should use the FestTheDatabase trait. In the examples directory you can see an example TestCase.php and unit test.

In test cases

To actually execute the database refresher you need to use ShouldFest trait in your test cases. This traits is used like the ShouldQueue interface, it only executes the code if it's detected. It also replaces the RefreshDatabase trait from Laravel.

<?php

namespace Tests\Unit;

use Tests\TestCase;
use Dees040\Festing\ShouldFest;

class ExampleTest extends TestCase
{
    use ShouldFest;
    
    /**
     * A basic test example.
     *
     * @return void
     */
    public function testBasicTest()
    {
        $this->assertTrue(true);
    }
}

Command

The package come with a command (make:fest) which is the same as php artisan make:test. The only difference is that it uses the ShouldFest trait instead of the default RefreshDatabase trait provided by Laravel.

Config

Check the config file for descriptions about all the config.

Cached data

Before we cache the data to make the tests significantly faster we run a list of artisan commands. Be default we run php artisan migrate. But if you'd like to change this or want to run more commands (i.e. php artisan db:seed) you can change the commands array config value.

dees040/festing 适用场景与选型建议

dees040/festing 是一款 基于 PHP 开发的 Composer 扩展包,目前已累计 4.26k 次下载、GitHub Stars 达 36, 最近一次更新时间为 2018 年 03 月 20 日, 在 PHP 生态内属于活跃度较高的组件。

它主要适用于以下技术方向: 「unit」 「tests」 「laravel」 「fast」 等业务场景。在实际项目中,围绕这些方向常见需要落地的问题包括:接口对接、性能调优、并发安全、与既有框架(Laravel / ThinkPHP / Yii / Webman 等)的兼容适配,以及生产环境的日志埋点与稳定性保障。

我们在过去多个企业项目中使用过 dees040/festing 或与其功能相近的方案,如果你在选型或落地过程中遇到问题,例如 版本兼容、二次改造、私有化封装、与内部系统对接、生产 BUG 排查,欢迎联系我们协助评估。

围绕 dees040/festing 我们能提供哪些服务?
定制开发 / 二次开发

基于 dees040/festing 在你已有业务上做功能扩展、字段裁剪、UI 适配、与内部账号 / 权限 / 日志系统的深度对接。

BUG 修复 & 性能优化

线上偶发问题、内存泄漏、慢查询、并发异常等排查修复;针对高流量场景做缓存、队列、索引层面的调优。

项目外包 & 长期维护

承接完整的项目从需求 → 设计 → 开发 → 上线 → 长期运维;也可按月提供技术保姆服务。

yvsm@zunyunkeji.com QQ:316430983 微信:yvsm316 西安尊云信息科技 · 专注 PHP / Go / 分布式系统研发

统计信息

  • 总下载量: 4.26k
  • 月度下载量: 0
  • 日度下载量: 0
  • 收藏数: 36
  • 点击次数: 3
  • 依赖项目数: 0
  • 推荐数: 0

GitHub 信息

  • Stars: 36
  • Watchers: 4
  • Forks: 0
  • 开发语言: PHP

其他信息

  • 授权协议: MIT
  • 更新时间: 2018-03-20