1 | <?php |
||
13 | use Symfony\Component\HttpFoundation\Response; |
||
14 | |||
15 | class SkautisDataCollectorTest extends \PHPUnit_Framework_TestCase |
||
16 | { |
||
17 | |||
18 | protected function makeSkautis() |
||
28 | |||
29 | |||
30 | public function testCollect() |
||
52 | |||
53 | |||
54 | public function testSerialize() |
||
55 | { |
||
56 | $data = [ |
||
57 | 'skautIS_Token' => 'tok_en', |
||
58 | 'skautIS_IDUnit' => 456, |
||
59 | 'skautIS_IDRole' => 789, |
||
60 | 'skautIS_DateLogout' => '2. 12. 2014 23:56:02' |
||
61 | ]; |
||
62 | |||
63 | $skautis = $this->makeSkautis(); |
||
64 | $skautis->setLoginData($data); |
||
65 | |||
66 | $dataCollector = new SkautisDataCollector($skautis); |
||
67 | $request = new Request(); |
||
68 | $response = new Response(); |
||
69 | $dataCollector->collect($request, $response); |
||
70 | |||
71 | // Symfony uklada data do souboru -> vyzaduje serialize |
||
72 | $serialized = serialize($dataCollector); |
||
73 | unset($dataCollector); |
||
74 | unset($skautis); |
||
75 | |||
76 | $unserializedCollector = unserialize($serialized); |
||
77 | $this->assertEquals("id123", $unserializedCollector->app_id()); |
||
78 | $this->assertEquals("tok_en", $unserializedCollector->token()); |
||
79 | $this->assertEquals(false, $unserializedCollector->test_mode()); |
||
80 | $this->assertEquals(789, $unserializedCollector->role_id()); |
||
81 | } |
||
83 |
If you implement
__call
and you know which methods are available, you can improve IDE auto-completion and static analysis by adding a @method annotation to the class.This is often the case, when
__call
is implemented by a parent class and only the child class knows which methods exist: