3 require_once 'CiviTest/CiviUnitTestCase.php';
5 class CRM_Extension_BrowserTest
extends CiviUnitTestCase
{
14 function testDisabled() {
15 $browser = new CRM_Extension_Browser(FALSE, '/index.html', 'file:///itd/oesn/tmat/ter');
16 $this->assertEquals(FALSE, $browser->isEnabled());
17 $this->assertEquals(array(), $browser->checkRequirements());
18 $this->assertEquals(array(), $browser->getExtensions());
21 function testCheckRequirements_BadCachedir_false() {
22 $browser = new CRM_Extension_Browser('file://' . dirname(__FILE__
) .'/dataset/good-repository', '/index.html', FALSE);
23 $this->assertEquals(TRUE, $browser->isEnabled());
24 $reqs = $browser->checkRequirements();
25 $this->assertEquals(1, count($reqs));
28 function testCheckRequirements_BadCachedir_nonexistent() {
29 $browser = new CRM_Extension_Browser('file://' . dirname(__FILE__
) .'/dataset/good-repository', '/index.html', '/tot/all/yin/v/alid');
30 $this->assertEquals(TRUE, $browser->isEnabled());
31 $reqs = $browser->checkRequirements();
32 $this->assertEquals(1, count($reqs));
35 function testGetExtensions_good() {
36 $browser = new CRM_Extension_Browser('file://' . dirname(__FILE__
) .'/dataset/good-repository', '/index.html', $this->createTempDir('ext-cache-'));
37 $this->assertEquals(TRUE, $browser->isEnabled());
38 $this->assertEquals(array(), $browser->checkRequirements());
39 $exts = $browser->getExtensions();
40 $keys = array_keys($exts);
42 $this->assertEquals(array('test.crm.extension.browsertest.a', 'test.crm.extension.browsertest.b'), $keys);
43 $this->assertEquals('report', $exts['test.crm.extension.browsertest.a']->type
);
44 $this->assertEquals('module', $exts['test.crm.extension.browsertest.b']->type
);
45 $this->assertEquals('http://example.com/test.crm.extension.browsertest.a-0.1.zip', $exts['test.crm.extension.browsertest.a']->downloadUrl
);
46 $this->assertEquals('http://example.com/test.crm.extension.browsertest.b-1.2.zip', $exts['test.crm.extension.browsertest.b']->downloadUrl
);
49 function testGetExtension_good() {
50 $browser = new CRM_Extension_Browser('file://' . dirname(__FILE__
) .'/dataset/good-repository', '/index.html', $this->createTempDir('ext-cache-'));
51 $this->assertEquals(TRUE, $browser->isEnabled());
52 $this->assertEquals(array(), $browser->checkRequirements());
54 $info = $browser->getExtension('test.crm.extension.browsertest.b');
55 $this->assertEquals('module', $info->type
);
56 $this->assertEquals('http://example.com/test.crm.extension.browsertest.b-1.2.zip', $info->downloadUrl
);
59 function testGetExtension_nonexistent() {
60 $browser = new CRM_Extension_Browser('file://' . dirname(__FILE__
) .'/dataset/good-repository', '/index.html', $this->createTempDir('ext-cache-'));
61 $this->assertEquals(TRUE, $browser->isEnabled());
62 $this->assertEquals(array(), $browser->checkRequirements());
64 $info = $browser->getExtension('test.crm.extension.browsertest.nonexistent');
65 $this->assertEquals(NULL, $info);