]> CyberLeo.Net >> Repos - Github/sugarcrm.git/blob - tests/include/MVC/SugarModuleTest.php
Added unit tests.
[Github/sugarcrm.git] / tests / include / MVC / SugarModuleTest.php
1 <?php
2 require_once 'include/MVC/SugarModule.php';
3
4 class SugarModuleTest extends Sugar_PHPUnit_Framework_TestCase
5 {
6     public function setUp()
7     {
8         $beanList = array();
9         $beanFiles = array();
10         require('include/modules.php');
11         $GLOBALS['beanList'] = $beanList;
12         $GLOBALS['beanFiles'] = $beanFiles;
13         $GLOBALS['current_user'] = SugarTestUserUtilities::createAnonymousUser();
14         $GLOBALS['current_user']->is_admin = '1';
15     }
16     
17     public function tearDown()
18     {
19         SugarTestUserUtilities::removeAllCreatedAnonymousUsers();
20         unset($GLOBALS['current_user']);
21         unset($GLOBALS['beanFiles']);
22         unset($GLOBALS['beanList']);
23     }
24     
25     public function testLoadBean()
26     {
27         $this->assertTrue(SugarModule::get('Accounts')->loadBean() instanceOf Account);
28     }
29     
30     public function testLoadBeanInvalidBean()
31     {
32         $this->assertFalse(SugarModule::get('JohnIsACoolGuy')->loadBean());
33     }
34     
35     public function testModuleImpliments()
36     {
37         $this->assertTrue(SugarModule::get('Accounts')->moduleImplements('Company'));
38     }
39     
40     public function testModuleImplimentsInvalidBean()
41     {
42         $this->assertFalse(SugarModule::get('JohnIsACoolGuy')->moduleImplements('Person'));
43     }
44     
45     public function testModuleImplimentsWhenModuleDoesNotImplimentTemplate()
46     {
47         $this->assertFalse(SugarModule::get('Accounts')->moduleImplements('Person'));
48     }
49 }