-
Notifications
You must be signed in to change notification settings - Fork 87
Expand file tree
/
Copy pathConfigRelativeUriTest.php
More file actions
68 lines (53 loc) · 1.72 KB
/
ConfigRelativeUriTest.php
File metadata and controls
68 lines (53 loc) · 1.72 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
<?php
namespace SocialiteProviders\Manager\Test;
use Illuminate\Support\Facades\Facade;
use Illuminate\Support\Facades\URL;
use Mockery as m;
use PHPUnit\Framework\TestCase;
use SocialiteProviders\Manager\Config;
class ConfigRelativeUriTest extends TestCase
{
use \Mockery\Adapter\Phpunit\MockeryPHPUnitIntegration;
protected function setUp(): void
{
parent::setUp();
$urlGenerator = m::mock(\Illuminate\Contracts\Routing\UrlGenerator::class);
$this->urlGenerator = $urlGenerator;
// Set up a minimal Facade application container
$app = new \ArrayObject();
$app['url'] = $urlGenerator;
Facade::setFacadeApplication($app);
}
protected function tearDown(): void
{
Facade::clearResolvedInstances();
Facade::setFacadeApplication(null);
parent::tearDown();
}
/** @var \Mockery\MockInterface */
protected $urlGenerator;
/**
* @test
*/
public function it_resolves_relative_uri_using_url_to(): void
{
$this->urlGenerator
->shouldReceive('to')
->with('/callback/oauth')
->once()
->andReturn('http://localhost/callback/oauth');
$config = new Config('key', 'secret', '/callback/oauth');
$result = $config->get();
$this->assertSame('http://localhost/callback/oauth', $result['redirect']);
}
/**
* @test
*/
public function it_does_not_resolve_absolute_uri(): void
{
$this->urlGenerator->shouldNotReceive('to');
$config = new Config('key', 'secret', 'https://example.com/callback');
$result = $config->get();
$this->assertSame('https://example.com/callback', $result['redirect']);
}
}