-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathActivateServiceTest.php
More file actions
62 lines (57 loc) · 1.93 KB
/
ActivateServiceTest.php
File metadata and controls
62 lines (57 loc) · 1.93 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
<?php
/**
* Definition of ActivateServiceTest
*
* @copyright 2015-today Justso GmbH
* @author j.schirrmacher@justso.de
*/
namespace justso\justauth;
use justso\justapi\Bootstrap;
use justso\justapi\NotFoundException;
use justso\justapi\testutil\ServiceTestBase;
/**
* Class ActivateServiceTest
*/
class ActivateServiceTest extends ServiceTestBase
{
public function testActivation()
{
$env = $this->createTestEnvironment(['c' => '12345']);
$conf = ['environments' => ['test' => [
'approot' => '/approot',
'appurl' => 'http://example.com'
]]];
$env->getBootstrap()->setTestConfiguration('/approot', $conf);
$auth = $this->createMock('\justso\justauth\Authenticator');
$auth->expects($this->once())->method('activate')->with('12345')->willReturn('dest');
$env->setDICEntry('Authenticator', $auth);
$service = new Activate($env);
$service->getAction();
$this->assertTrue(in_array('Location: http://example.com/dest', $env->getResponseHeader()));
}
/**
* @expectedException \justso\justapi\InvalidParameterException
*/
public function testWithoutActivationCode()
{
$env = $this->createTestEnvironment();
$service = new Activate($env);
$service->getAction();
// @codeCoverageIgnoreStart
}
// @codeCoverageIgnoreEnd
/**
* @expectedException \justso\justapi\DenyException
*/
public function testWrongActivationCode()
{
$env = $this->createTestEnvironment(['c' => '12345']);
$auth = $this->createMock('\justso\justauth\Authenticator');
$auth->expects($this->once())->method('activate')->with('12345')->willThrowException(new NotFoundException());
$env->setDICEntry('Authenticator', $auth);
$service = new Activate($env);
$service->getAction();
// @codeCoverageIgnoreStart
}
// @codeCoverageIgnoreEnd
}