1
|
|
|
<?php |
2
|
|
|
|
3
|
|
|
/* |
4
|
|
|
* The MIT License |
5
|
|
|
* |
6
|
|
|
* Copyright 2016 Alejandro Peña Florentín ([email protected]). |
7
|
|
|
* |
8
|
|
|
* Permission is hereby granted, free of charge, to any person obtaining a copy |
9
|
|
|
* of this software and associated documentation files (the "Software"), to deal |
10
|
|
|
* in the Software without restriction, including without limitation the rights |
11
|
|
|
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell |
12
|
|
|
* copies of the Software, and to permit persons to whom the Software is |
13
|
|
|
* furnished to do so, subject to the following conditions: |
14
|
|
|
* |
15
|
|
|
* The above copyright notice and this permission notice shall be included in |
16
|
|
|
* all copies or substantial portions of the Software. |
17
|
|
|
* |
18
|
|
|
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR |
19
|
|
|
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, |
20
|
|
|
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE |
21
|
|
|
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER |
22
|
|
|
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, |
23
|
|
|
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN |
24
|
|
|
* THE SOFTWARE. |
25
|
|
|
*/ |
26
|
|
|
|
27
|
|
|
namespace Tight\Tests; |
28
|
|
|
|
29
|
|
|
/** |
30
|
|
|
* ApiModuleTest class for Tight\Modules\Api package |
31
|
|
|
* |
32
|
|
|
* @author Alejandro Peña Florentín ([email protected]) |
33
|
|
|
*/ |
34
|
|
|
class ApiModuleTest extends \PHPUnit_Framework_TestCase |
35
|
|
|
{ |
36
|
|
|
|
37
|
|
|
private $response = "Response!"; |
38
|
|
|
private $module; |
39
|
|
|
|
40
|
|
|
public function setUp() { |
41
|
|
|
$this->module = new \Tight\Modules\Api\Api(true, $this->response); |
42
|
|
|
} |
43
|
|
|
|
44
|
|
|
public function tearDown() { |
45
|
|
|
|
46
|
|
|
} |
47
|
|
|
|
48
|
|
|
/** |
49
|
|
|
* @test |
50
|
|
|
*/ |
51
|
|
|
public function testGetError() { |
52
|
|
|
$this->assertTrue($this->module->getError()); |
53
|
|
|
} |
54
|
|
|
|
55
|
|
|
/** |
56
|
|
|
* @test |
57
|
|
|
* @depends testGetError |
58
|
|
|
*/ |
59
|
|
|
public function testSetError() { |
60
|
|
|
$this->module->setError(FALSE); |
61
|
|
|
$this->assertFalse($this->module->getError()); |
62
|
|
|
$this->module->setError(true); |
63
|
|
|
$this->assertTrue($this->module->getError()); |
64
|
|
|
} |
65
|
|
|
|
66
|
|
|
/** |
67
|
|
|
* @test |
68
|
|
|
*/ |
69
|
|
|
public function testGetResponse() { |
70
|
|
|
$this->assertEquals($this->response, $this->module->getResponse()); |
71
|
|
|
} |
72
|
|
|
|
73
|
|
|
/** |
74
|
|
|
* @test |
75
|
|
|
* @depends testGetResponse |
76
|
|
|
*/ |
77
|
|
|
public function testSetResponse() { |
78
|
|
|
$expected = "This is the response message"; |
79
|
|
|
$this->module->setResponse($expected); |
80
|
|
|
$this->assertEquals($expected, $this->module->getResponse()); |
81
|
|
|
} |
82
|
|
|
|
83
|
|
|
/** |
84
|
|
|
* @test |
85
|
|
|
* @runInSeparateProcess |
86
|
|
|
*/ |
87
|
|
|
public function testGet() { |
88
|
|
|
$expected = [ |
89
|
|
|
"error" => true, |
90
|
|
|
"response" => $this->response |
91
|
|
|
]; |
92
|
|
|
$this->assertEquals(json_encode($expected), $this->module->get()); |
93
|
|
|
} |
94
|
|
|
|
95
|
|
|
} |
96
|
|
|
|