1
|
|
|
<?php |
2
|
|
|
|
3
|
|
|
namespace Test\Skautis; |
4
|
|
|
|
5
|
|
|
use Skautis\User; |
6
|
|
|
|
7
|
|
|
class UserTest extends \PHPUnit_Framework_TestCase |
8
|
|
|
{ |
9
|
|
|
|
10
|
|
|
protected function tearDown() |
11
|
|
|
{ |
12
|
|
|
\Mockery::close(); |
13
|
|
|
} |
14
|
|
|
|
15
|
|
|
protected function makeWsdlManager() |
16
|
|
|
{ |
17
|
|
|
return \Mockery::mock('\Skautis\Wsdl\WsdlManager'); |
18
|
|
|
} |
19
|
|
|
|
20
|
|
|
protected function makeUser() |
21
|
|
|
{ |
22
|
|
|
return new User($this->makeWsdlManager()); |
|
|
|
|
23
|
|
|
} |
24
|
|
|
|
25
|
|
|
public function testSetLoginData() |
26
|
|
|
{ |
27
|
|
|
$dt = new \DateTime; |
28
|
|
|
$user = $this->makeUser(); |
29
|
|
|
$this->assertFalse($user->isLoggedIn()); |
30
|
|
|
|
31
|
|
|
$user->setLoginData("token", 33, 100, $dt); |
32
|
|
|
$this->assertEquals("token", $user->getLoginId()); |
33
|
|
|
$this->assertEquals(33, $user->getRoleId()); |
34
|
|
|
$this->assertEquals(100, $user->getUnitId()); |
35
|
|
|
$this->assertEquals($dt->format('Y-m-d H:i:s'), $user->getLogoutDate()->format('Y-m-d H:i:s')); |
36
|
|
|
} |
37
|
|
|
|
38
|
|
|
|
39
|
|
|
public function testIsLoggedHardCheck() |
40
|
|
|
{ |
41
|
|
|
$soapResponse = new \StdClass(); |
42
|
|
|
$soapResponse->DateLogout = '2044-02-12T15:19:21.996'; |
43
|
|
|
|
44
|
|
|
$ws = \Mockery::mock("\Skautis\Wsdl\WebService"); |
45
|
|
|
$ws->shouldReceive("LoginUpdateRefresh")->once()->andReturn($soapResponse); |
46
|
|
|
|
47
|
|
|
$wsdlManager = $this->makeWsdlManager(); |
48
|
|
|
$wsdlManager->shouldReceive('getWebService')->once()->andReturn($ws); |
49
|
|
|
|
50
|
|
|
$user = new User($wsdlManager); |
|
|
|
|
51
|
|
|
$user->setLoginData("token", 33, 100, new \DateTime("+1 day")); |
52
|
|
|
|
53
|
|
|
$this->assertTrue($user->isLoggedIn(true)); |
54
|
|
|
} |
55
|
|
|
|
56
|
|
|
public function testResetLoginData() |
57
|
|
|
{ |
58
|
|
|
$user = $this->makeUser(); |
59
|
|
|
|
60
|
|
|
$user->setLoginData("token", 33, 100, new \DateTime); |
61
|
|
|
$this->assertEquals(33, $user->getRoleId()); |
62
|
|
|
|
63
|
|
|
$user->resetLoginData(); |
64
|
|
|
$this->assertEmpty($user->getLoginId()); |
65
|
|
|
$this->assertEmpty($user->getRoleId()); |
66
|
|
|
$this->assertEmpty($user->getUnitId()); |
67
|
|
|
$this->assertNull($user->getLogoutDate()); |
68
|
|
|
} |
69
|
|
|
} |
70
|
|
|
|
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: