2017 © Pedro Peláez
 

library api-testing

A package which provide all you need for testing apis!

image

laravelfr/api-testing

A package which provide all you need for testing apis!

  • Monday, July 31, 2017
  • by mathieutu
  • Repository
  • 1 Watchers
  • 0 Stars
  • 39 Installations
  • PHP
  • 0 Dependents
  • 0 Suggesters
  • 0 Forks
  • 0 Open issues
  • 2 Versions
  • 5 % Grown

The README.md

Laravel Api Testing

By the LaravelFr Team

This package provide you some methods to fully test your Laravel API., (*1)

The LaravelFr team is a group of french friends who decide to put in common some useful methods for testing API. Whoever you are, feel free to contribute to this package or join the organisation to add yours !, (*2)

Travis Build StyleCI Code Coverage Code Quality, (*3)

Installation

composer require laravelfr/api-testing

Usage

Once Laravel API Testing is installed, you can extend or implement the classes and traits in this package. There are no service providers to register., (*4)

It works both with old testing way (Laravel <5.4 and >5.4 with BrowserKit) and with new testing way (with response object). - Old way: Just use \LaravelFr\ApiTesting\AssertArrays and \LaravelFr\ApiTesting\AssertJsonResponse traits, and use directly the methods from traits. - New way: for AssertJsonResponse, you can add the trait, and directly use the methods on response object., (*5)

See Tests for some examples., (*6)

Available methods:

On this response example :, (*7)

{
   "foo": 134,
   "foobar": {
       "foobar_foo": "foo",
       "foobar_bar": 212
   },
   "bars": [
       {
           "bar": true,
           "foo": 134.212
       },
       {
           "bar": false,
           "foo": 134.212
       },
       {
           "bar": false,
           "foo": 134.212
       }
   ],
   "baz": [
       {
           "foo": "Laravel",
           "bar": {
               "foo": true,
               "bar": 134
           }
       },
       {
           "foo": "France",
           "bar": {
               "foo": false,
               "bar": 212
           }
       }
   ]
}
  • assertJsonStructureEquals: check if it respects the exact structure pattern., (*8)

    $response->assertJsonStructureEquals([
     'foo',
     'baz' => ['*' => ['bar' => ['*'], 'foo']],
     'bars' => ['*' => ['bar', 'foo']],
     'foobar' => ['foobar_foo', 'foobar_bar'],
    ]);
    
  • seeJsonTypedStructure: check if it respects a typed pattern., (*9)

    $response->seeJsonTypedStructure([
     'foo' => 'integer',
     'baz' => ['*' => ['bar' => 'array', 'foo' => 'string']],
     'bars' => ['*' => ['bar' => 'boolean', 'foo' => 'float']],
     'foobar' => ['foobar_foo' => 'string', 'foobar_bar' => 'int'],
    ]);
    
  • seeJsonTypedStructure: retrieve a part of response in array format. php $response->jsonResponse('foobar.foobar_bar')); // 212 ## Credits
  • Maintenance: Mathieu TUDISCO dev@mathieutu.ovh,
  • Methods:, (*10)

    Please feel free to make PRs and add yours!, (*11)

The Versions

31/07 2017

dev-master

9999999-dev

A package which provide all you need for testing apis!

  Sources   Download

GPL-3.0

The Requires

 

The Development Requires

by Mathieu TUDISCO

31/07 2017

1.0.0

1.0.0.0

A package which provide all you need for testing apis!

  Sources   Download

GPL-3.0

The Requires

 

The Development Requires

by Mathieu TUDISCO