Commit | Line | Data |
---|---|---|
6a488035 TO |
1 | <?php |
2 | ||
3 | require_once 'CiviTest/CiviUnitTestCase.php'; | |
4 | ||
5 | class CRM_Extension_BrowserTest extends CiviUnitTestCase { | |
6 | function setUp() { | |
7 | parent::setUp(); | |
8 | } | |
9 | ||
10 | function tearDown() { | |
11 | parent::tearDown(); | |
12 | } | |
13 | ||
14 | function testDisabled() { | |
72b14f38 | 15 | $browser = new CRM_Extension_Browser(FALSE, '/index.html', 'file:///itd/oesn/tmat/ter'); |
6a488035 TO |
16 | $this->assertEquals(FALSE, $browser->isEnabled()); |
17 | $this->assertEquals(array(), $browser->checkRequirements()); | |
18 | $this->assertEquals(array(), $browser->getExtensions()); | |
19 | } | |
20 | ||
21 | function testCheckRequirements_BadCachedir_false() { | |
72b14f38 | 22 | $browser = new CRM_Extension_Browser('file://' . dirname(__FILE__) .'/dataset/good-repository', '/index.html', FALSE); |
6a488035 TO |
23 | $this->assertEquals(TRUE, $browser->isEnabled()); |
24 | $reqs = $browser->checkRequirements(); | |
25 | $this->assertEquals(1, count($reqs)); | |
26 | } | |
27 | ||
28 | function testCheckRequirements_BadCachedir_nonexistent() { | |
72b14f38 | 29 | $browser = new CRM_Extension_Browser('file://' . dirname(__FILE__) .'/dataset/good-repository', '/index.html', '/tot/all/yin/v/alid'); |
6a488035 TO |
30 | $this->assertEquals(TRUE, $browser->isEnabled()); |
31 | $reqs = $browser->checkRequirements(); | |
32 | $this->assertEquals(1, count($reqs)); | |
33 | } | |
34 | ||
35 | function testGetExtensions_good() { | |
72b14f38 | 36 | $browser = new CRM_Extension_Browser('file://' . dirname(__FILE__) .'/dataset/good-repository', '/index.html', $this->createTempDir('ext-cache-')); |
6a488035 TO |
37 | $this->assertEquals(TRUE, $browser->isEnabled()); |
38 | $this->assertEquals(array(), $browser->checkRequirements()); | |
39 | $exts = $browser->getExtensions(); | |
40 | $keys = array_keys($exts); | |
41 | sort($keys); | |
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); | |
47 | } | |
48 | ||
49 | function testGetExtension_good() { | |
72b14f38 | 50 | $browser = new CRM_Extension_Browser('file://' . dirname(__FILE__) .'/dataset/good-repository', '/index.html', $this->createTempDir('ext-cache-')); |
6a488035 TO |
51 | $this->assertEquals(TRUE, $browser->isEnabled()); |
52 | $this->assertEquals(array(), $browser->checkRequirements()); | |
53 | ||
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); | |
57 | } | |
58 | ||
59 | function testGetExtension_nonexistent() { | |
72b14f38 | 60 | $browser = new CRM_Extension_Browser('file://' . dirname(__FILE__) .'/dataset/good-repository', '/index.html', $this->createTempDir('ext-cache-')); |
6a488035 TO |
61 | $this->assertEquals(TRUE, $browser->isEnabled()); |
62 | $this->assertEquals(array(), $browser->checkRequirements()); | |
63 | ||
64 | $info = $browser->getExtension('test.crm.extension.browsertest.nonexistent'); | |
65 | $this->assertEquals(NULL, $info); | |
66 | } | |
67 | } |