jeudi 20 septembre 2018

Laravel Testing - Write a Mobile Request

This is a simple question, but im not able to test a mobile phone request correctly. I just want to write a test that 'simulates' a mobile/tablet device request, and then allow or deny login depending of it, but I dont know how to write this.

Im using Mobile Detect package to handle mobile detection, using $agent->isMobile() method.

This is my test

    $this->postJson(route('login', [
        'email' => 'mail@mail.com',
        'password' => 'secret',
    ], [
        'MOBILE_HEADER' => true // <-- What header??
    ]))->assertForbidden();

What header (and how) should I send? Are there any 'popular mobile header'?

Thats all, thx!

Aucun commentaire:

Enregistrer un commentaire