VoteCheckerTest   A
last analyzed

Complexity

Total Complexity 3

Size/Duplication

Total Lines 29
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 2

Importance

Changes 0
Metric Value
wmc 3
c 0
b 0
f 0
lcom 1
cbo 2
dl 0
loc 29
rs 10

3 Methods

Rating   Name   Duplication   Size   Complexity  
A testCheckGoodCodeReturnTrue() 0 5 1
A testCheckCodeAlreadyUsedThrowException() 0 8 1
A testCheckCodeInvalidUsedThrowException() 0 10 1
1
<?php
2
3
namespace Tests\TopMcFrance\Api;
4
5
use PHPUnit\Framework\TestCase;
6
use TopMcFrance\Api\VoteChecker;
7
use TopMcFrance\Api\ApiException;
8
9
/**
10
 * @author Jérôme Desjardins <[email protected]>
11
 */
12
class VoteCheckerTest extends TestCase
13
{
14
    
15
    public function testCheckGoodCodeReturnTrue()
16
    {
17
        $vote = new VoteChecker(0);
18
        $this->assertTrue($vote->checkCode('istrue'));
19
    }
20
    
21
    public function testCheckCodeAlreadyUsedThrowException()
22
    {
23
        $this->expectException(ApiException::class);
24
        $this->expectExceptionMessage('Code alreadyused has already used at 0000-00-00 00:00:00');
25
        
26
        $vote = new VoteChecker(0);
27
        $vote->checkCode('alreadyused');
28
    }
29
    
30
     public function testCheckCodeInvalidUsedThrowException()
31
    {
32
        $this->expectException(ApiException::class);
33
        $this->expectExceptionMessage('Code invalidcode isn\'t valid.');
34
        
35
        $vote = new VoteChecker(0);
36
        $vote->checkCode('invalidcode');
37
        
38
        
39
    } 
40
}
41