vendredi 19 octobre 2018

Laravel 5.6. PHPUnit. Order-insensetive assertJson() method

In my business logic I don't care about the order of elements.

Here is my example of a test

$this->getJson('/api/order-attempts')
     ->assertJson([
         'data' => [
             ['status' => 'error'],
             ['status' => 'error'],
             ['status' => 'confirmed'],
             ['status' => 'confirmed'],
             ['status' => 'confirmed'],
         ],
     ])->isOk();

It's fails from time to time only because of the order. I do NOT want to put sorting to the api, cause I don't need it.

Is it possible to assertJsonIgnoringOrder() somehow?



via Chebli Mohamed

Aucun commentaire:

Enregistrer un commentaire