GitHub Access Token became invalid

It seems like the GitHub access token used for retrieving details about this repository from GitHub became invalid. This might prevent certain types of inspections from being run (in particular, everything related to pull requests).
Please ask an admin of your repository to re-new the access token on this website.
Completed
Push — 3.x ( 52ff30...48a2e9 )
by Jindřich
12s queued 11s
created

UserTest   A

Complexity

Total Complexity 7

Size/Duplication

Total Lines 72
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 4

Importance

Changes 0
Metric Value
dl 0
loc 72
rs 10
c 0
b 0
f 0
wmc 7
lcom 1
cbo 4

7 Methods

Rating   Name   Duplication   Size   Complexity  
A tearDown() 0 4 1
A makeWsdlManager() 0 4 1
A makeUser() 0 4 1
A testSetLoginData() 0 12 1
A testIsLoggedHardCheck() 0 16 1
A testResetLoginData() 0 13 1
A testIsLoggedInWithoutUserId() 0 7 1
1
<?php
2
3
namespace Skaut\Skautis\Test\Unit;
4
5
use PHPUnit\Framework\TestCase;
6
use Skaut\Skautis\User;
7
use Skaut\Skautis\Wsdl\WebService;
8
use Skaut\Skautis\Wsdl\WsdlManager;
9
10
class UserTest extends TestCase
11
{
12
13
    protected function tearDown(): void
14
    {
15
        \Mockery::close();
16
    }
17
18
    protected function makeWsdlManager()
19
    {
20
        return \Mockery::mock(WsdlManager::class);
21
    }
22
23
    protected function makeUser(): User
24
    {
25
        return new User($this->makeWsdlManager());
0 ignored issues
show
Documentation introduced by
$this->makeWsdlManager() is of type object<Mockery\LegacyMockInterface>, but the function expects a object<Skaut\Skautis\Wsdl\WsdlManager>.

It seems like the type of the argument is not accepted by the function/method which you are calling.

In some cases, in particular if PHP’s automatic type-juggling kicks in this might be fine. In other cases, however this might be a bug.

We suggest to add an explicit type cast like in the following example:

function acceptsInteger($int) { }

$x = '123'; // string "123"

// Instead of
acceptsInteger($x);

// we recommend to use
acceptsInteger((integer) $x);
Loading history...
26
    }
27
28
    public function testSetLoginData(): void
29
    {
30
        $dt = new \DateTime;
31
        $user = $this->makeUser();
32
        $this->assertFalse($user->isLoggedIn());
33
34
        $user->setLoginData('token', 33, 100, $dt);
35
        $this->assertEquals('token', $user->getLoginId());
36
        $this->assertEquals(33, $user->getRoleId());
37
        $this->assertEquals(100, $user->getUnitId());
38
        $this->assertEquals($dt->format('Y-m-d H:i:s'), $user->getLogoutDate()->format('Y-m-d H:i:s'));
39
    }
40
41
42
    public function testIsLoggedHardCheck(): void
43
    {
44
        $soapResponse = new \StdClass();
45
        $soapResponse->DateLogout = '2044-02-12T15:19:21.996';
46
47
        $ws = \Mockery::mock(WebService::class);
48
        $ws->shouldReceive('LoginUpdateRefresh')->once()->andReturn($soapResponse);
49
50
        $wsdlManager = $this->makeWsdlManager();
51
        $wsdlManager->shouldReceive('getWebService')->once()->andReturn($ws);
52
53
        $user = new User($wsdlManager);
0 ignored issues
show
Documentation introduced by
$wsdlManager is of type object<Mockery\LegacyMockInterface>, but the function expects a object<Skaut\Skautis\Wsdl\WsdlManager>.

It seems like the type of the argument is not accepted by the function/method which you are calling.

In some cases, in particular if PHP’s automatic type-juggling kicks in this might be fine. In other cases, however this might be a bug.

We suggest to add an explicit type cast like in the following example:

function acceptsInteger($int) { }

$x = '123'; // string "123"

// Instead of
acceptsInteger($x);

// we recommend to use
acceptsInteger((integer) $x);
Loading history...
54
        $user->setLoginData('token', 33, 100, new \DateTime('+1 day'));
55
56
        $this->assertTrue($user->isLoggedIn(true));
57
    }
58
59
    public function testResetLoginData(): void
60
    {
61
        $user = $this->makeUser();
62
63
        $user->setLoginData('token', 33, 100, new \DateTime);
64
        $this->assertEquals(33, $user->getRoleId());
65
66
        $user->resetLoginData();
67
        $this->assertEmpty($user->getLoginId());
68
        $this->assertEmpty($user->getRoleId());
69
        $this->assertEmpty($user->getUnitId());
70
        $this->assertNull($user->getLogoutDate());
71
    }
72
73
    public function testIsLoggedInWithoutUserId(): void
74
    {
75
      $user = $this->makeUser();
76
      $this->assertNull($user->getLoginId());
77
      $this->assertFalse($user->isLoggedIn());
78
      $this->assertFalse($user->isLoggedIn(true));
79
    }
80
81
}
82