-
Notifications
You must be signed in to change notification settings - Fork 14
/
module_test.php
60 lines (51 loc) · 1.62 KB
/
module_test.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
<?php
/**
*
* Topic Preview
*
* @copyright (c) 2016 Matt Friedman
* @license GNU General Public License, version 2 (GPL-2.0)
*
*/
namespace vse\topicpreview\tests\acp;
class module_test extends \phpbb_test_case
{
/**
* Test the acp module instance
*/
public function test_module()
{
global $phpbb_container, $phpbb_root_path, $phpEx;
// Test basic module instantiation
$module = new \vse\topicpreview\acp\topic_preview_module();
$this->assertInstanceOf('\vse\topicpreview\acp\topic_preview_module', $module);
// Test calling module->main()
$lang_loader = new \phpbb\language\language_file_loader($phpbb_root_path, $phpEx);
$lang = new \phpbb\language\language($lang_loader);
$user = new \phpbb\user($lang, '\phpbb\datetime');
$mock_acp_controller = $this->getMockBuilder('\vse\topicpreview\controller\acp_controller')
->disableOriginalConstructor()
->setMethods(array('handle'))
->getMock();
$phpbb_container = $this->getMockBuilder('Symfony\Component\DependencyInjection\ContainerInterface')
->getMock();
$phpbb_container
->expects($this->at(0))
->method('get')
->with('user')
->will($this->returnValue($user));
$phpbb_container
->expects($this->at(1))
->method('get')
->with('vse.topicpreview.acp.controller')
->will($this->returnValue($mock_acp_controller));
$module->main();
}
public function test_info()
{
$info_class = new \vse\topicpreview\acp\topic_preview_info();
$info_array = $info_class->module();
$this->assertArrayHasKey('filename', $info_array);
$this->assertEquals('\vse\topicpreview\acp\topic_preview_module', $info_array['filename']);
}
}