jonnybarnes.uk/tests/Unit/IndieAuthServiceTest.php

76 lines
2 KiB
PHP
Raw Normal View History

2017-02-19 00:36:30 +00:00
<?php
namespace Tests\Unit;
use Tests\TestCase;
use App\Services\IndieAuthService;
2017-02-19 00:36:30 +00:00
class IndieAuthServiceTest extends TestCase
{
/**
* Test the getAuthorizationEndpoint method.
*
* @return void
*/
public function test_indieauthservice_getauthorizationendpoint_method()
{
$service = new IndieAuthService();
2017-03-01 20:59:09 +00:00
$result = $service->getAuthorizationEndpoint(config('app.url'));
2017-02-19 00:36:30 +00:00
$this->assertEquals('https://indieauth.com/auth', $result);
}
2017-03-01 20:59:09 +00:00
/**
* Test the getAuthorizationEndpoint method returns null on failure.
*
* @return void
*/
public function test_indieauthservice_getauthorizationendpoint_method_returns_null_on_failure()
{
$service = new IndieAuthService();
2017-03-01 20:59:09 +00:00
$result = $service->getAuthorizationEndpoint('http://example.org');
$this->assertEquals(null, $result);
}
2017-02-19 00:36:30 +00:00
/**
* Test that the Service build the correct redirect URL.
*
* @return void
*/
public function test_indieauthservice_builds_correct_redirect_url()
{
$service = new IndieAuthService();
2017-02-19 00:36:30 +00:00
$result = $service->buildAuthorizationURL(
'https://indieauth.com/auth',
2017-03-01 20:59:09 +00:00
config('app.url')
2017-02-19 00:36:30 +00:00
);
$this->assertEquals(
'https://indieauth.com/auth?me=',
substr($result, 0, 30)
);
}
/**
* Test the getTokenEndpoint method.
*
* @return void
*/
public function test_indieauthservice_gettokenendpoint_method()
{
$service = new IndieAuthService();
2017-03-01 20:59:09 +00:00
$result = $service->getTokenEndpoint(config('app.url'));
2017-02-19 00:36:30 +00:00
$this->assertEquals(config('app.url') . '/api/token', $result);
}
/**
* Test the discoverMicropubEndpoint method.
*
* @return void
*/
public function test_indieauthservice_discovermicropubendpoint_method()
{
$service = new IndieAuthService();
2017-03-01 20:59:09 +00:00
$result = $service->discoverMicropubEndpoint(config('app.url'));
2017-02-19 00:36:30 +00:00
$this->assertEquals(config('app.url') . '/api/post', $result);
}
}