forked from CakeDC/users
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathUserValidationTraitTest.php
More file actions
71 lines (66 loc) · 2.09 KB
/
Copy pathUserValidationTraitTest.php
File metadata and controls
71 lines (66 loc) · 2.09 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
69
70
71
<?php
/**
* Copyright 2010 - 2015, Cake Development Corporation (+1 702 425 5085) (http://cakedc.com)
*
* Licensed under The MIT License
* Redistributions of files must retain the above copyright notice.
*
* @copyright Copyright 2010 - 2015, Cake Development Corporation (+1 702 425 5085) (http://cakedc.com)
* @license MIT License (http://www.opensource.org/licenses/mit-license.php)
*/
namespace Users\Test\TestCase\Controller\Traits;
use Cake\Network\Request;
use Cake\TestSuite\TestCase;
class UserValidationTraitTest extends TestCase
{
/**
* setup
*
* @return void
*/
public function setUp()
{
parent::setUp();
$request = new Request();
$this->Trait = $this->getMockBuilder('Users\Controller\Traits\UserValidationTrait')
->setMethods(['dispatchEvent', 'isStopped', 'redirect', 'getUsersTable'])
->getMockForTrait();
$this->Trait->request = $request;
}
/**
* tearDown
*
* @return void
*/
public function tearDown()
{
parent::tearDown();
}
/**
* test
*
* @return void
*/
public function testValidateHappyToken()
{
$usersTableMock = $this->getMockBuilder('Users\Model\Table\UsersTable')
->setMethods(['validate'])
->disableOriginalConstructor()
->getMock();
$usersTableMock->expects($this->once())
->method('validate')
->with('token', 'activateUser')
->will($this->returnValue(true));
$this->Trait->expects($this->once())
->method('getUsersTable')
->will($this->returnValue($usersTableMock));
$this->Trait->Flash = $this->getMockBuilder('Cake\Controller\Component\FlashComponent')
->setMethods(['success'])
->disableOriginalConstructor()
->getMock();
$this->Trait->Flash->expects($this->once())
->method('success')
->with('User account validated successfully');
$this->Trait->validate('email', 'token');
}
}