<?php

namespace Tests\Feature;

use Tests\TestCase;
use PHPUnit\Framework\Assert as PHPUnit;

class AuthControllerTest extends TestCase
{
	const PHONE_CODE = '371';
	const PHONE_NUMBER = '20399776';

	protected $validationCode;

	/**
	 * Before each request
	 */
	public function setUp()
	{
		parent::setUp();

		$this->withHeaders([
			'KEY' => '12345',
			'Accept' => 'application/json',
			'Content-type' => 'application/json',
		]);

		$this->validationCode = $this->sendPhoneCheck();
	}

	/**
	 * @return mixed
	 */
    public function sendPhoneCheck()
    {
		$route = route('auth.send-phone-code');
		$response = $this->json('POST', $route, [
			'phone_number' => static::PHONE_CODE,
			'phone_code' => static::PHONE_NUMBER,
		]);

		$response->assertStatus(200);
		$response->assertJson(['code' => true]);

		return $response->json('code');
	}

	public function testRegister()
	{
		$route = route('auth.register');
		$response = $this->json('POST', $route, [
			'nickname' => 'Test User',
			'code' => $this->validationCode,
		]);

		if ($response->getStatusCode() != 200) {
			dump('Register response unvalid');
			ddd($response->json());
		}

		$this->assertTrue(true);
	}

	public function testLogin()
	{
		$this->assertTrue(true);
	}
}
