Completed
Push — master ( a52d30...b030ea )
by Korotkov
03:48
created

LazyInitializationTest   A

Complexity

Total Complexity 3

Size/Duplication

Total Lines 24
Duplicated Lines 0 %

Importance

Changes 0
Metric Value
dl 0
loc 24
rs 10
c 0
b 0
f 0
wmc 3

3 Methods

Rating   Name   Duplication   Size   Complexity  
A setUp() 0 3 1
A testLogin() 0 5 1
A testRegister() 0 4 1
1
<?php
2
3
declare(strict_types=1);
4
5
/**
6
 * @author    : Korotkov Danila <[email protected]>
7
 * @license   https://mit-license.org/ MIT
8
 */
9
10
namespace Creational\LazyInitialization\Tests;
11
12
use Creational\LazyInitialization\UserService;
13
use PHPUnit\Framework\TestCase as PHPUnit_Framework_TestCase;
14
15
/**
16
 * Class LazyInitializationTest
17
 */
18
class LazyInitializationTest extends PHPUnit_Framework_TestCase
19
{
20
21
    /**
22
     * @var UserService
23
     */
24
    protected $userService;
25
26
    protected function setUp(): void
27
    {
28
        $this->userService = new UserService();
29
    }
30
31
    public function testRegister()
32
    {
33
        $this->assertEquals(sprintf("%s has been registered \n", 'John'), $this->userService->register('John'));
34
        $this->assertEquals(sprintf("%s was already registered \n", 'John'), $this->userService->register('John'));
35
    }
36
37
    public function testLogin()
38
    {
39
        $this->userService->register('John');
40
        $this->assertEquals(sprintf("%s is authenticated \n", 'John'), $this->userService->login('John'));
41
        $this->assertEquals(sprintf("%s must be registered \n", 'Bill'), $this->userService->login('Bill'));
42
    }
43
}
44