2017 © Pedro Peláez
 

library autohttptests

Autogenerate http tests for laravel

image

eduardoarandah/autohttptests

Autogenerate http tests for laravel

  • Friday, April 13, 2018
  • by eduardoarandah
  • Repository
  • 2 Watchers
  • 1 Stars
  • 3 Installations
  • PHP
  • 0 Dependents
  • 0 Suggesters
  • 0 Forks
  • 3 Open issues
  • 6 Versions
  • 0 % Grown

The README.md

Laravel autohttptests

Latest Version on Packagist ![Software License][ico-license] ![Total Downloads][ico-downloads], (*1)

No more writing tests by hand =D, (*2)

Just execute the command to record your actions as http tests, (*3)

``` bash php artisan autohttptest:create, (*4)


![imagen](https://user-images.githubusercontent.com/4065733/31252701-a10f4580-a9e7-11e7-8b83-92cfc4b962f3.png) 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](https://user-images.githubusercontent.com/4065733/88353656-fcf9cc00-cd23-11ea-86b3-6c096378f540.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, (*5)

namespace Tests\Feature; use Tests\TestCase;, (*6)

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', ]);, (*7)

    $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');
}

}, (*8)


**Note** Here we capture an unsuccessful post, with errors. Then, a **successful** post with redirection ## Install Via Composer ``` bash $ composer require eduardoarandah/autohttptests

If you are using laravel < 5.4 add to providers in config/app.php, (*9)

EduardoArandaH\AutoHttpTests\AutoHttpTestsServiceProvider::class,

Usage

``` bash php artisan autohttptest:create, (*10)


## 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 ```, (*11)

Credits

License

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

The Versions

13/04 2018

dev-master

9999999-dev https://github.com/eduardoarandah/autohttptests

Autogenerate http tests for laravel

  Sources   Download

MIT

The Requires

 

The Development Requires

eduardoarandah autohttptests

24/12 2017

1.0.4

1.0.4.0 https://github.com/eduardoarandah/autohttptests

Autogenerate http tests for laravel

  Sources   Download

MIT

The Requires

 

The Development Requires

eduardoarandah autohttptests

09/10 2017

v1.0.3

1.0.3.0 https://github.com/eduardoarandah/autohttptests

Autogenerate http tests for laravel

  Sources   Download

MIT

The Requires

 

The Development Requires

eduardoarandah autohttptests

05/10 2017

1.0.2

1.0.2.0 https://github.com/eduardoarandah/autohttptests

Autogenerate http tests for laravel

  Sources   Download

MIT

The Requires

 

The Development Requires

eduardoarandah autohttptests

05/10 2017

1.0.0

1.0.0.0 https://github.com/eduardoarandah/autohttptests

Autogenerate http tests for laravel

  Sources   Download

MIT

The Requires

 

The Development Requires

eduardoarandah autohttptests

05/10 2017

1.0.1

1.0.1.0 https://github.com/eduardoarandah/autohttptests

Autogenerate http tests for laravel

  Sources   Download

MIT

The Requires

 

The Development Requires

eduardoarandah autohttptests