Completed
Push — master ( 798ee0...2329f6 )
by Lucas
08:18
created

SecurityAnonymousTest::testUsername()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 16
Code Lines 13

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
c 1
b 0
f 0
dl 0
loc 16
rs 9.4285
cc 1
eloc 13
nc 1
nop 0
1
<?php
2
/**
3
 * test security contract (mainly getters and defaults)
4
 */
5
6
namespace Graviton\SecurityBundle\Entities;
7
8
use Graviton\TestBundle\Test\WebTestCase;
9
10
/**
11
 * Class SecurityContractTest
12
 *
13
 * @author   List of contributors <https://github.com/libgraviton/graviton/graphs/contributors>
14
 * @license  http://opensource.org/licenses/gpl-license.php GNU Public License
15
 * @link     http://swisscom.ch
16
 */
17
class SecurityAnonymousTest extends WebTestCase
18
{
19
    /**
20
     * @param string[] $methods methods to mock
21
     *
22
     * @return \PHPUnit_Framework_MockObject_MockObject|\Graviton\SecurityBundle\Entities\AnonymousUser
23
     */
24
    protected function getUserMock(array $methods = array())
25
    {
26
        return $this->getMockBuilder('\Graviton\SecurityBundle\Entities\AnonymousUser')
27
            ->disableOriginalConstructor()
28
            ->setMethods($methods)
29
            ->getMock();
30
    }
31
32
    /**
33
     * test getting username from contract
34
     *
35
     * @return void
36
     */
37
    public function testUsername()
38
    {
39
        $customerMock = $this->getMockBuilder('\Graviton\SecurityBundle\Entities\SecurityUser')
40
            ->disableOriginalConstructor()
41
            ->setMethods(array('getUsername', 'getId'))
42
            ->getMock();
43
        $customerMock
44
            ->expects($this->never())
45
            ->method('getId')
46
            ->will($this->returnValue(0));
47
        $customerMock
48
            ->expects($this->never())
49
            ->method('getUsername')
50
            ->will($this->returnValue('anonymous'));
51
52
    }
53
}
54