-
Notifications
You must be signed in to change notification settings - Fork 334
Expand file tree
/
Copy pathLoginTest.php
More file actions
64 lines (52 loc) · 1.95 KB
/
LoginTest.php
File metadata and controls
64 lines (52 loc) · 1.95 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
<?php
namespace ZfcUserTest\Form;
use ZfcUser\Form\Login as Form;
class LoginTest extends \PHPUnit_Framework_TestCase
{
/**
* @covers ZfcUser\Form\Login::__construct
* @dataProvider providerTestConstruct
*/
public function testConstruct($authIdentityFields = array())
{
$options = $this->getMock('ZfcUser\Options\AuthenticationOptionsInterface');
$options->expects($this->once())
->method('getAuthIdentityFields')
->will($this->returnValue($authIdentityFields));
$form = new Form(null, $options);
$elements = $form->getElements();
$this->assertArrayHasKey('identity', $elements);
$this->assertArrayHasKey('credential', $elements);
$this->assertArrayHasKey('security', $elements);
$expectedLabel="";
if (count($authIdentityFields) > 0) {
foreach ($authIdentityFields as $field) {
$expectedLabel .= ($expectedLabel=="") ? '' : ' or ';
$expectedLabel .= ucfirst($field);
$this->assertContains(ucfirst($field), $elements['identity']->getLabel());
}
}
$this->assertEquals($expectedLabel, $elements['identity']->getLabel());
}
/**
* @covers ZfcUser\Form\Login::getAuthenticationOptions
* @covers ZfcUser\Form\Login::setAuthenticationOptions
*/
public function testSetGetAuthenticationOptions()
{
$options = $this->getMock('ZfcUser\Options\AuthenticationOptionsInterface');
$options->expects($this->once())
->method('getAuthIdentityFields')
->will($this->returnValue(array()));
$form = new Form(null, $options);
$this->assertSame($options, $form->getAuthenticationOptions());
}
public function providerTestConstruct()
{
return array(
array(array()),
array(array('email')),
array(array('username','email')),
);
}
}