<?php

use Laravel\Lumen\Testing\DatabaseMigrations;
use Laravel\Lumen\Testing\DatabaseTransactions;
use App\User;
use App\Http\Controllers\AuthController;
use Illuminate\Http\Request;

class AuthTest extends TestCase
{
    private $email = 'jochec.tomas@gmail.com';
    private $password = '12345';

    public function testLogin()
    {
        $this->post('/auth/login', [
          'email' => $this->email,
          'password' => $this->password
        ]);
        $this->seeStatusCode(200);
        $this->seeJsonStructure([
          'token'
        ]);
    }

    public function testNonExistingUser()
    {
        $this->post('/auth/login', [
          'email' => $this->email.'wrong',
          'password' => $this->password
        ]);
        $this->seeStatusCode(400);
        $this->seeJson([
          'error' => 'Email does not exist.'
        ]);
    }

    public function testWrongPassword()
    {
        $this->post('/auth/login', [
          'email' => $this->email,
          'password' => $this->password.'wrong'
        ]);
        $this->seeStatusCode(400);
        $this->seeJson([
          'error' => 'Email or password is wrong.'
        ]);
    }
}
