<?php

#namespace Saireh\Tests;

require_once __DIR__ . "/../../bootstrap.php";

use Saireh\PayRoll\OAuthToken;
use PHPUnit\Framework\TestCase;
use Saireh\Payroll\CurlRequest;



class oauth_tokenTest extends TestCase
{
    private $url = "https://corp.sts.ford.com/";
    private $request;
    private $oauth;

    function setUp(): void
    {
        $env = "test";
        $this->request = new CurlRequest($this->url, curl_init());
        $this->oauth = new OAuthToken("test", $this->request);
    }

    function test_get_baerer_token()
    {


        $env = "dev";
        $mock_curl_request = $this->createStub(CurlRequest::class);

        $expected_token = "<<expected_token>>";

        $mock_curl_request->method("get_baerer_token")->willReturn(
            array(
                "access_token" => $expected_token,
                "token_type" => "bearer",
                "expires_in" => 3600
            )
        );


        $response = $this->oauth->get_baerer_token();
        $this->assertEquals($response["token"], $expected_token);
    }
}
