mercredi 21 septembre 2016

Issue running phpunit tests on laravel5.1

I Am trying to test api with laravel 5.1 and phpunit for a login module which is divided into 2 parts

  • Check email address
  • get password and authenticate

Now in the first part an api is called which sends the response.error as false for which the follow is the test case code written.

class LoginPageTest extends TestCase
{
use WithoutMiddleware;
/**
 * A basic test example.
 *
 * @return void
 */
public function testExample()
{

$response = $this->call('POST', '/check-user', ['email' => 'john@gmail.com']);

    $this->assertEquals(200, $response->status());

    }
}

But on running the test form the terminal(vendor/bin/phpunit), I get the following error.

Time: 947 ms, Memory: 14.75MB

There was 1 failure:

1) LoginPageTest::testExample
Failed asserting that 500 matches expected 200.

project/tests/LoginPageTest.php:32

FAILURES!
Tests: 1, Assertions: 1, Failures: 1.

When i test thru postman i get the desired result in the json format. Is it something to do with my code or phpunit?



via Chebli Mohamed

Aucun commentaire:

Enregistrer un commentaire