Completed
Push — master ( 995cbb...c18ab0 )
by Korotkov
08:09 queued 01:09
created

LazyInitializationTest::getUserService()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 3
Code Lines 1

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
cc 1
eloc 1
nc 1
nop 0
dl 0
loc 3
rs 10
c 0
b 0
f 0
1
<?php
2
3
/**
4
 * @author  : Jagepard <[email protected]>
5
 * @license https://mit-license.org/ MIT
6
 */
7
8
namespace Creational\LazyInitialization\Tests;
9
10
use Creational\LazyInitialization\UserService;
11
use Creational\LazyInitialization\ServiceInterface;
12
use PHPUnit\Framework\TestCase as PHPUnit_Framework_TestCase;
13
14
class LazyInitializationTest extends PHPUnit_Framework_TestCase
15
{
16
    /**
17
     * @var ServiceInterface
18
     */
19
    private $userService;
20
21
    protected function setUp(): void
22
    {
23
        $this->userService = new UserService();
24
    }
25
26
    public function testRegister()
27
    {
28
        $this->assertEquals(sprintf("%s has been registered \n", 'John'), $this->userService->register('John'));
29
        $this->assertEquals(sprintf("%s is authenticated \n", 'John'), $this->userService->register('John'));
30
    }
31
32
    public function testLogin()
33
    {
34
        $this->userService->register('John');
35
        $this->assertEquals(sprintf("%s is authenticated \n", 'John'), $this->userService->login('John'));
36
        $this->assertEquals(sprintf("%s was already authenticated \n", 'John'), $this->userService->login('John'));
37
        $this->assertEquals(sprintf("%s must be registered \n", 'Bill'), $this->userService->login('Bill'));
38
    }
39
}
40