eduardoarandah/autohttptests 问题修复 & 功能扩展

解决BUG、新增功能、兼容多环境部署,快速响应你的开发需求

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

eduardoarandah/autohttptests

Composer 安装命令:

composer require eduardoarandah/autohttptests

包简介

Autogenerate http tests for laravel

README 文档

README

Latest Version on Packagist Software License Total Downloads

No more writing tests by hand =D

Just execute the command to record your actions as http tests

php artisan autohttptest:create

imagen

The command will intercept your requests and translate the response as a test.

When finished, your test will be saved in tests/Feature/

Demo in video

autohttptests-gif

What does it test?

  • Request acting as same user
  • Make request using the same verb (GET,PUT,POST) with same arguments
  • Assert http response code
  • Assert errors
  • Assert redirection

Example code

<?php

namespace Tests\Feature;
use Tests\TestCase;

class SomethingTest extends TestCase
{
    public function testAutoHttpTest()
    {
        $this
        ->actingAs(\App\Models\User::find(1))
        ->post('home/something', [
            'name'         => 'a',
            'lastname'     => 'a',
            'city'         => '',
            'hobbies'   => '',
            'twitter_username' => 'a',
        ])
        ->assertStatus(302)
        ->assertSessionHasErrors([
            'name',
            'country_id',
            'twitter_username',
        ]);

        $this
        ->actingAs(\App\Models\User::find(1))
        ->post('home/something', [
            'name'              => 'asdfa',
            'lastname'          => 'asdfa',
            'country_id' => '1',
            'city'              => '',
            'hobbies'        => '',
            'twitter_username'      => 'asdfa',
        ])
            ->assertStatus(302)
            ->assertRedirect('home/something');
    }
}

Note

Here we capture an unsuccessful post, with errors. Then, a successful post with redirection

Install

Via Composer

$ composer require eduardoarandah/autohttptests

If you are using laravel < 5.4 add to providers in config/app.php

EduardoArandaH\AutoHttpTests\AutoHttpTestsServiceProvider::class,

Usage

php artisan autohttptest:create

How does it work?

when you run php artisan autohttptest:create yourtest it intercepts all requests and responses through a middleware.

The request is then analyzed and transformed into a test in a file storage/autohttptests.txt

If you're curious, you can see the building of that file in real time with

tail -f storage/autohttptests.txt

Credits

License

The MIT License (MIT). Please see License File for more information.

统计信息

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

GitHub 信息

  • Stars: 34
  • Watchers: 1
  • Forks: 5
  • 开发语言: PHP

其他信息

  • 授权协议: MIT
  • 更新时间: 2017-10-05

承接程序开发

PHP开发

VUE

Vue开发

前端开发

小程序开发

公众号开发

系统定制

数据库设计

云部署

网站建设

安全加固