1
|
|
|
<?php |
2
|
|
|
|
3
|
|
|
namespace Firebase; |
4
|
|
|
|
5
|
|
|
use PHPUnit\Framework\TestCase; |
6
|
|
|
|
7
|
|
|
class FirebaseStubTest extends TestCase |
8
|
|
|
{ |
9
|
|
|
protected $firebaseStub; |
10
|
|
|
|
11
|
|
|
const DEFAULT_URL = 'https://firebaseStub.firebaseio.com/'; |
12
|
|
|
const DEFAULT_TOKEN = 'MqL0c8tKCtheLSYcygBrIanhU8Z2hULOFs9OKPdEp'; |
13
|
|
|
const DEFAULT_TIMEOUT = 10; |
14
|
|
|
const DEFAULT_PATH = 'example/path'; |
15
|
|
|
const DEFAULT_DATA = '{"firstName": "Howdy", "lastName": "Doody"}'; |
16
|
|
|
const DEFAULT_PUSH_DATA = '{"firstName": "1skdSDdksdlisS"}'; |
17
|
|
|
|
18
|
|
|
const UPDATED_URI = 'https://myfirebaseStub.firebaseio.com/'; |
19
|
|
|
const UPDATED_TOKEN = 'MqL0c8tEmBeRLSYcygBrIanhU8Z2hULOFs9OKPdEp'; |
20
|
|
|
const UPDATED_TIMEOUT = 30; |
21
|
|
|
|
22
|
|
|
const INSECURE_URL = 'http://insecure.firebaseio.com'; |
23
|
|
|
const INVALID_DATA = '"firstName" "Howdy", "lastName": "Doody" "": '; |
24
|
|
|
const MISSING_DATA = ''; |
25
|
|
|
const NULL_DATA = null; |
26
|
|
|
|
27
|
|
|
public function setUp(): void |
28
|
|
|
{ |
29
|
|
|
$this->firebaseStub = new FirebaseStub(self::DEFAULT_URL, self::DEFAULT_TOKEN); |
30
|
|
|
} |
31
|
|
|
|
32
|
|
|
public function testBaseURIInitializationOnInstantiation(): void |
33
|
|
|
{ |
34
|
|
|
$this->assertEquals(self::DEFAULT_TOKEN, $this->firebaseStub->getToken()); |
35
|
|
|
} |
36
|
|
|
|
37
|
|
|
public function testSetBaseURI(): void |
38
|
|
|
{ |
39
|
|
|
$this->firebaseStub->setBaseURI(self::UPDATED_URI); |
40
|
|
|
$this->assertEquals(self::UPDATED_URI, $this->firebaseStub->getBaseURI()); |
41
|
|
|
} |
42
|
|
|
|
43
|
|
|
public function testGetSSLConnection(): void |
44
|
|
|
{ |
45
|
|
|
$sslConnection = $this->firebaseStub->getSSLConnection(); |
46
|
|
|
$this->assertEquals(true, $sslConnection); |
47
|
|
|
} |
48
|
|
|
|
49
|
|
|
public function testTokenInitializationOnInstantiation(): void |
50
|
|
|
{ |
51
|
|
|
$this->assertEquals(self::DEFAULT_TOKEN, $this->firebaseStub->getToken()); |
52
|
|
|
} |
53
|
|
|
|
54
|
|
|
public function testSetToken(): void |
55
|
|
|
{ |
56
|
|
|
$this->firebaseStub->setToken(self::UPDATED_TOKEN); |
57
|
|
|
$this->assertEquals(self::UPDATED_TOKEN, $this->firebaseStub->getToken()); |
58
|
|
|
} |
59
|
|
|
|
60
|
|
|
public function testTimeoutInitializationOnInstantiation(): void |
61
|
|
|
{ |
62
|
|
|
$this->assertEquals(self::DEFAULT_TIMEOUT, $this->firebaseStub->getTimeOut()); |
63
|
|
|
} |
64
|
|
|
|
65
|
|
|
public function testSetTimeout(): void |
66
|
|
|
{ |
67
|
|
|
$this->firebaseStub->setTimeout(self::UPDATED_TIMEOUT); |
68
|
|
|
$this->assertEquals(self::UPDATED_TIMEOUT, $this->firebaseStub->getTimeOut()); |
69
|
|
|
} |
70
|
|
|
|
71
|
|
|
public function testSet(): void |
72
|
|
|
{ |
73
|
|
|
$this->firebaseStub->setResponse(self::DEFAULT_DATA); |
74
|
|
|
$actualResponse = $this->firebaseStub->set(self::DEFAULT_PATH, self::DEFAULT_DATA); |
75
|
|
|
$this->assertEquals(self::DEFAULT_DATA, $actualResponse); |
76
|
|
|
} |
77
|
|
|
|
78
|
|
|
public function testPush(): void |
79
|
|
|
{ |
80
|
|
|
$this->firebaseStub->setResponse(self::DEFAULT_PUSH_DATA); |
81
|
|
|
$actualResponse = $this->firebaseStub->push(self::DEFAULT_PATH, self::DEFAULT_DATA); |
82
|
|
|
$this->assertEquals(self::DEFAULT_PUSH_DATA, $actualResponse); |
83
|
|
|
} |
84
|
|
|
|
85
|
|
|
public function testUpdate(): void |
86
|
|
|
{ |
87
|
|
|
$this->firebaseStub->setResponse(self::DEFAULT_DATA); |
88
|
|
|
$actualResponse = $this->firebaseStub->update(self::DEFAULT_PATH, self::DEFAULT_DATA); |
89
|
|
|
$this->assertEquals(self::DEFAULT_DATA, $actualResponse); |
90
|
|
|
} |
91
|
|
|
|
92
|
|
|
public function testDelete(): void |
93
|
|
|
{ |
94
|
|
|
$actualResponse = $this->firebaseStub->delete(self::DEFAULT_PATH); |
|
|
|
|
95
|
|
|
$this->assertEquals(null, $actualResponse); |
96
|
|
|
} |
97
|
|
|
} |
98
|
|
|
|
This check looks for function or method calls that always return null and whose return value is assigned to a variable.
The method
getObject()
can return nothing but null, so it makes no sense to assign that value to a variable.The reason is most likely that a function or method is imcomplete or has been reduced for debug purposes.