forked from inetprocess/libsugarcrm
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathSystemTest.php
86 lines (78 loc) · 3.06 KB
/
SystemTest.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
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
<?php
namespace Inet\SugarCRM\Tests;
use Inet\SugarCRM\EntryPoint;
use Inet\SugarCRM\DB;
use Inet\SugarCRM\System;
class SystemTest extends SugarTestCase
{
public function testRightInstanciation()
{
$system = new System($this->getEntryPointInstance());
// Activity
$this->assertTrue($system->isActivityEnabled());
$system->disableActivity();
$this->assertFalse($system->isActivityEnabled());
// Logger
$logger = $system->getLogger();
$this->assertInstanceOf('Psr\Log\NullLogger', $logger);
// EntryPoint
$ep = $system->getEntryPoint();
$this->assertInstanceOf('\Inet\SugarCRM\EntryPoint', $ep);
}
/**
* This test is really slow ( > 1 minute)
* @group sugarcrm-slow
* @group repair
*/
public function testRepairAll()
{
$checkFile = realpath(getenv('SUGARCRM_PATH') . '/cache/class_map.php');
$this->assertFileExists($checkFile, 'That file is used to test my repair');
unlink($checkFile);
$this->assertFileNotExists($checkFile, 'That file is used to test my repair');
$system = new System($this->getEntryPointInstance());
$ret = $system->repair();
$this->assertFileExists($checkFile, 'That file is used to test my repair');
$this->assertNotEmpty($ret);
$this->assertNotEmpty($ret[0]);
}
/**
* @group repair
*/
public function testRebuildExtensions()
{
$sugar_path = realpath(getenv('SUGARCRM_PATH'));
$ext_path = $sugar_path . '/custom/Extension/modules/Accounts/Ext/LogicHooks/test_rebuild_ext.php';
$compiled_ext_path = $sugar_path . '/custom/modules/Accounts/Ext/LogicHooks/logichooks.ext.php';
$token = md5(mt_rand());
if (!is_dir(dirname($ext_path))) {
mkdir(dirname($ext_path), 0750, true);
}
file_put_contents($ext_path, "<?php\n// token: $token");
$sys = new System($this->getEntryPointInstance());
$ret = $sys->rebuildExtensions(array('Accounts'));
$this->assertCount(2, $ret);
$this->assertFileExists($compiled_ext_path);
$compiled_ext = file_get_contents($compiled_ext_path);
$this->assertContains("// token: $token", $compiled_ext);
}
/**
* @group repair
*/
public function testRebuildApplication()
{
$sugar_path = realpath(getenv('SUGARCRM_PATH'));
$ext_path = $sugar_path . '/custom/Extension/application/Ext/Utils/test_rebuild_application.php';
$compiled_ext_path = $sugar_path . '/custom/application/Ext/Utils/custom_utils.ext.php';
$token = md5(mt_rand());
if (!is_dir(dirname($ext_path))) {
mkdir(dirname($ext_path), 0750, true);
}
file_put_contents($ext_path, "<?php\n// token: $token");
$sys = new System($this->getEntryPointInstance());
$sys->rebuildApplication();
$this->assertFileExists($compiled_ext_path);
$compiled_ext = file_get_contents($compiled_ext_path);
$this->assertContains("// token: $token", $compiled_ext);
}
}