4 * Class CRM_Extension_BrowserTest
7 class CRM_Extension_BrowserTest
extends CiviUnitTestCase
{
8 public function setUp() {
12 public function tearDown() {
16 public function testDisabled() {
17 $browser = new CRM_Extension_Browser(FALSE, '/index.html', 'file:///itd/oesn/tmat/ter');
18 $this->assertEquals(FALSE, $browser->isEnabled());
19 $this->assertEquals(array(), $browser->checkRequirements());
20 $this->assertEquals(array(), $browser->getExtensions());
23 public function testCheckRequirements_BadCachedir_false() {
24 $browser = new CRM_Extension_Browser('file://' . dirname(__FILE__
) . '/dataset/good-repository', NULL, FALSE);
25 $this->assertEquals(TRUE, $browser->isEnabled());
26 $reqs = $browser->checkRequirements();
27 $this->assertEquals(1, count($reqs));
30 public function testCheckRequirements_BadCachedir_nonexistent() {
31 $browser = new CRM_Extension_Browser('file://' . dirname(__FILE__
) . '/dataset/good-repository', NULL, '/tot/all/yin/v/alid');
32 $this->assertEquals(TRUE, $browser->isEnabled());
33 $reqs = $browser->checkRequirements();
34 $this->assertEquals(1, count($reqs));
37 public function testGetExtensions_good() {
38 $browser = new CRM_Extension_Browser('file://' . dirname(__FILE__
) . '/dataset/good-repository', NULL, $this->createTempDir('ext-cache-'));
39 $this->assertEquals(TRUE, $browser->isEnabled());
40 $this->assertEquals(array(), $browser->checkRequirements());
41 $exts = $browser->getExtensions();
42 $keys = array_keys($exts);
44 $this->assertEquals(array('test.crm.extension.browsertest.a', 'test.crm.extension.browsertest.b'), $keys);
45 $this->assertEquals('report', $exts['test.crm.extension.browsertest.a']->type
);
46 $this->assertEquals('module', $exts['test.crm.extension.browsertest.b']->type
);
47 $this->assertEquals('http://example.com/test.crm.extension.browsertest.a-0.1.zip', $exts['test.crm.extension.browsertest.a']->downloadUrl
);
48 $this->assertEquals('http://example.com/test.crm.extension.browsertest.b-1.2.zip', $exts['test.crm.extension.browsertest.b']->downloadUrl
);
51 public function testGetExtension_good() {
52 $browser = new CRM_Extension_Browser('file://' . dirname(__FILE__
) . '/dataset/good-repository', NULL, $this->createTempDir('ext-cache-'));
53 $this->assertEquals(TRUE, $browser->isEnabled());
54 $this->assertEquals(array(), $browser->checkRequirements());
56 $info = $browser->getExtension('test.crm.extension.browsertest.b');
57 $this->assertEquals('module', $info->type
);
58 $this->assertEquals('http://example.com/test.crm.extension.browsertest.b-1.2.zip', $info->downloadUrl
);
61 public function testGetExtension_nonexistent() {
62 $browser = new CRM_Extension_Browser('file://' . dirname(__FILE__
) . '/dataset/good-repository', NULL, $this->createTempDir('ext-cache-'));
63 $this->assertEquals(TRUE, $browser->isEnabled());
64 $this->assertEquals(array(), $browser->checkRequirements());
66 $info = $browser->getExtension('test.crm.extension.browsertest.nonexistent');
67 $this->assertEquals(NULL, $info);