@@ -6,106 +6,106 @@ |
||
6 | 6 | |
7 | 7 | class main_test extends \phpbb_test_case { |
8 | 8 | |
9 | - /** |
|
10 | - * @var \florinp\messenger\controller\main |
|
11 | - */ |
|
12 | - protected $controller; |
|
13 | - |
|
14 | - public function setUp() { |
|
15 | - parent::setUp(); |
|
16 | - /** |
|
17 | - * @var \phpbb\user $user Mock the user class |
|
18 | - */ |
|
19 | - $user = $this->getMock('\phpbb\user', array(), array('\phpbb\datetime')); |
|
20 | - |
|
21 | - /** |
|
22 | - * @var \phpbb\request\request $request |
|
23 | - */ |
|
24 | - $request = $this->getMockBuilder('\phpbb\request\request') |
|
25 | - ->disableOriginalConstructor() |
|
26 | - ->getMock(); |
|
27 | - |
|
28 | - /** |
|
29 | - * @var \florinp\messenger\models\main_model $model |
|
30 | - */ |
|
31 | - $model = $this->getMockBuilder('\florinp\messenger\models\main_model') |
|
32 | - ->disableOriginalConstructor() |
|
33 | - ->getMock(); |
|
34 | - |
|
35 | - /** |
|
36 | - * @var \phpbb\notification\manager $notification_manager |
|
37 | - */ |
|
38 | - $notification_manager = $this->getMockBuilder('\phpbb\notification\manager') |
|
39 | - ->disableOriginalConstructor() |
|
40 | - ->getMock(); |
|
41 | - |
|
42 | - /** |
|
43 | - * @var \florinp\messenger\libs\upload $upload |
|
44 | - */ |
|
45 | - $upload = $this->getMockBuilder('\florinp\messenger\libs\upload') |
|
46 | - ->disableOriginalConstructor() |
|
47 | - ->getMock(); |
|
48 | - |
|
49 | - /** |
|
50 | - * @var \florinp\messenger\libs\download $download |
|
51 | - */ |
|
52 | - $download = $this->getMockBuilder('\florinp\messenger\libs\download') |
|
53 | - ->disableOriginalConstructor() |
|
54 | - ->getMock(); |
|
55 | - |
|
56 | - $this->controller = new \florinp\messenger\controller\main( |
|
57 | - $request, |
|
58 | - $user, |
|
59 | - $model, |
|
60 | - $notification_manager, |
|
61 | - $upload, |
|
62 | - $download |
|
63 | - ); |
|
64 | - } |
|
65 | - |
|
66 | - public function tearDown() { |
|
67 | - $this->controller = null; |
|
68 | - parent::tearDown(); |
|
69 | - } |
|
70 | - |
|
71 | - public function publish_data() { |
|
72 | - return array( |
|
73 | - array(200, json_encode(array())) |
|
74 | - ); |
|
75 | - } |
|
76 | - /** |
|
77 | - * @dataProvider publish_data |
|
78 | - */ |
|
79 | - public function test_publish($status_code, $page_content) { |
|
80 | - $response = $this->controller->publish(); |
|
81 | - $this->assertInstanceOf('\Symfony\Component\HttpFoundation\Response', $response); |
|
82 | - $this->assertEquals($status_code, $response->getStatusCode()); |
|
83 | - $this->assertEquals($page_content, $response->getContent()); |
|
84 | - } |
|
85 | - |
|
86 | - |
|
87 | - public function load_data() { |
|
88 | - return array( |
|
89 | - array(200, json_encode(array( |
|
90 | - 'success' => false, |
|
91 | - 'error' => 'The request is invalid' |
|
92 | - ))) |
|
93 | - ); |
|
94 | - } |
|
95 | - /** |
|
96 | - * @dataProvider load_data |
|
97 | - */ |
|
98 | - public function test_load($status_code, $page_content) { |
|
99 | - $response = $this->controller->load(); |
|
100 | - $this->assertInstanceOf('\Symfony\Component\HttpFoundation\Response', $response); |
|
101 | - $this->assertEquals($status_code, $response->getStatusCode()); |
|
102 | - $this->assertEquals($page_content, $response->getContent()); |
|
103 | - } |
|
104 | - |
|
105 | - |
|
106 | - public function updateMessages_data() { |
|
107 | - return array( |
|
108 | - array(200, json_encode(array('success' => false))) |
|
109 | - ); |
|
110 | - } |
|
9 | + /** |
|
10 | + * @var \florinp\messenger\controller\main |
|
11 | + */ |
|
12 | + protected $controller; |
|
13 | + |
|
14 | + public function setUp() { |
|
15 | + parent::setUp(); |
|
16 | + /** |
|
17 | + * @var \phpbb\user $user Mock the user class |
|
18 | + */ |
|
19 | + $user = $this->getMock('\phpbb\user', array(), array('\phpbb\datetime')); |
|
20 | + |
|
21 | + /** |
|
22 | + * @var \phpbb\request\request $request |
|
23 | + */ |
|
24 | + $request = $this->getMockBuilder('\phpbb\request\request') |
|
25 | + ->disableOriginalConstructor() |
|
26 | + ->getMock(); |
|
27 | + |
|
28 | + /** |
|
29 | + * @var \florinp\messenger\models\main_model $model |
|
30 | + */ |
|
31 | + $model = $this->getMockBuilder('\florinp\messenger\models\main_model') |
|
32 | + ->disableOriginalConstructor() |
|
33 | + ->getMock(); |
|
34 | + |
|
35 | + /** |
|
36 | + * @var \phpbb\notification\manager $notification_manager |
|
37 | + */ |
|
38 | + $notification_manager = $this->getMockBuilder('\phpbb\notification\manager') |
|
39 | + ->disableOriginalConstructor() |
|
40 | + ->getMock(); |
|
41 | + |
|
42 | + /** |
|
43 | + * @var \florinp\messenger\libs\upload $upload |
|
44 | + */ |
|
45 | + $upload = $this->getMockBuilder('\florinp\messenger\libs\upload') |
|
46 | + ->disableOriginalConstructor() |
|
47 | + ->getMock(); |
|
48 | + |
|
49 | + /** |
|
50 | + * @var \florinp\messenger\libs\download $download |
|
51 | + */ |
|
52 | + $download = $this->getMockBuilder('\florinp\messenger\libs\download') |
|
53 | + ->disableOriginalConstructor() |
|
54 | + ->getMock(); |
|
55 | + |
|
56 | + $this->controller = new \florinp\messenger\controller\main( |
|
57 | + $request, |
|
58 | + $user, |
|
59 | + $model, |
|
60 | + $notification_manager, |
|
61 | + $upload, |
|
62 | + $download |
|
63 | + ); |
|
64 | + } |
|
65 | + |
|
66 | + public function tearDown() { |
|
67 | + $this->controller = null; |
|
68 | + parent::tearDown(); |
|
69 | + } |
|
70 | + |
|
71 | + public function publish_data() { |
|
72 | + return array( |
|
73 | + array(200, json_encode(array())) |
|
74 | + ); |
|
75 | + } |
|
76 | + /** |
|
77 | + * @dataProvider publish_data |
|
78 | + */ |
|
79 | + public function test_publish($status_code, $page_content) { |
|
80 | + $response = $this->controller->publish(); |
|
81 | + $this->assertInstanceOf('\Symfony\Component\HttpFoundation\Response', $response); |
|
82 | + $this->assertEquals($status_code, $response->getStatusCode()); |
|
83 | + $this->assertEquals($page_content, $response->getContent()); |
|
84 | + } |
|
85 | + |
|
86 | + |
|
87 | + public function load_data() { |
|
88 | + return array( |
|
89 | + array(200, json_encode(array( |
|
90 | + 'success' => false, |
|
91 | + 'error' => 'The request is invalid' |
|
92 | + ))) |
|
93 | + ); |
|
94 | + } |
|
95 | + /** |
|
96 | + * @dataProvider load_data |
|
97 | + */ |
|
98 | + public function test_load($status_code, $page_content) { |
|
99 | + $response = $this->controller->load(); |
|
100 | + $this->assertInstanceOf('\Symfony\Component\HttpFoundation\Response', $response); |
|
101 | + $this->assertEquals($status_code, $response->getStatusCode()); |
|
102 | + $this->assertEquals($page_content, $response->getContent()); |
|
103 | + } |
|
104 | + |
|
105 | + |
|
106 | + public function updateMessages_data() { |
|
107 | + return array( |
|
108 | + array(200, json_encode(array('success' => false))) |
|
109 | + ); |
|
110 | + } |
|
111 | 111 | } |
112 | 112 | \ No newline at end of file |