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
<?php
namespace yiiunit\extensions\authclient;
use yii\authclient\AuthAction;
class AuthActionTest extends TestCase
{
protected function setUp()
{
$config = [
'components' => [
'user' => [
'identityClass' => '\yii\web\IdentityInterface'
],
'request' => [
'hostInfo' => 'http://testdomain.com',
'scriptUrl' => '/index.php',
],
]
];
$this->mockApplication($config, '\yii\web\Application');
}
public function testSetGet()
{
$action = new AuthAction(null, null);
$successUrl = 'http://test.success.url';
$action->setSuccessUrl($successUrl);
$this->assertEquals($successUrl, $action->getSuccessUrl(), 'Unable to setup success URL!');
$cancelUrl = 'http://test.cancel.url';
$action->setCancelUrl($cancelUrl);
$this->assertEquals($cancelUrl, $action->getCancelUrl(), 'Unable to setup cancel URL!');
}
/**
* @depends testSetGet
*/
public function testGetDefaultSuccessUrl()
{
$action = new AuthAction(null, null);
$this->assertNotEmpty($action->getSuccessUrl(), 'Unable to get default success URL!');
}
/**
* @depends testSetGet
*/
public function testGetDefaultCancelUrl()
{
$action = new AuthAction(null, null);
$this->assertNotEmpty($action->getSuccessUrl(), 'Unable to get default cancel URL!');
}
public function testRedirect()
{
$action = new AuthAction(null, null);
$url = 'http://test.url';
$response = $action->redirect($url, true);
$this->assertContains($url, $response->content);
}
}