Commit | Line | Data |
---|---|---|
6a488035 TO |
1 | <?php |
2 | ||
3 | require_once 'CiviTest/CiviUnitTestCase.php'; | |
4 | ||
aba1cd8b EM |
5 | /** |
6 | * Class CRM_Extension_BrowserTest | |
7 | */ | |
6a488035 | 8 | class CRM_Extension_BrowserTest extends CiviUnitTestCase { |
00be9182 | 9 | public function setUp() { |
6a488035 TO |
10 | parent::setUp(); |
11 | } | |
12 | ||
00be9182 | 13 | public function tearDown() { |
6a488035 TO |
14 | parent::tearDown(); |
15 | } | |
16 | ||
00be9182 | 17 | public function testDisabled() { |
72b14f38 | 18 | $browser = new CRM_Extension_Browser(FALSE, '/index.html', 'file:///itd/oesn/tmat/ter'); |
6a488035 TO |
19 | $this->assertEquals(FALSE, $browser->isEnabled()); |
20 | $this->assertEquals(array(), $browser->checkRequirements()); | |
21 | $this->assertEquals(array(), $browser->getExtensions()); | |
22 | } | |
23 | ||
00be9182 | 24 | public function testCheckRequirements_BadCachedir_false() { |
86bfa4f6 | 25 | $browser = new CRM_Extension_Browser('file://' . dirname(__FILE__) . '/dataset/good-repository', '/index.html', FALSE); |
6a488035 TO |
26 | $this->assertEquals(TRUE, $browser->isEnabled()); |
27 | $reqs = $browser->checkRequirements(); | |
28 | $this->assertEquals(1, count($reqs)); | |
29 | } | |
30 | ||
00be9182 | 31 | public function testCheckRequirements_BadCachedir_nonexistent() { |
86bfa4f6 | 32 | $browser = new CRM_Extension_Browser('file://' . dirname(__FILE__) . '/dataset/good-repository', '/index.html', '/tot/all/yin/v/alid'); |
6a488035 TO |
33 | $this->assertEquals(TRUE, $browser->isEnabled()); |
34 | $reqs = $browser->checkRequirements(); | |
35 | $this->assertEquals(1, count($reqs)); | |
36 | } | |
37 | ||
00be9182 | 38 | public function testGetExtensions_good() { |
86bfa4f6 | 39 | $browser = new CRM_Extension_Browser('file://' . dirname(__FILE__) . '/dataset/good-repository', '/index.html', $this->createTempDir('ext-cache-')); |
6a488035 TO |
40 | $this->assertEquals(TRUE, $browser->isEnabled()); |
41 | $this->assertEquals(array(), $browser->checkRequirements()); | |
42 | $exts = $browser->getExtensions(); | |
43 | $keys = array_keys($exts); | |
44 | sort($keys); | |
45 | $this->assertEquals(array('test.crm.extension.browsertest.a', 'test.crm.extension.browsertest.b'), $keys); | |
46 | $this->assertEquals('report', $exts['test.crm.extension.browsertest.a']->type); | |
47 | $this->assertEquals('module', $exts['test.crm.extension.browsertest.b']->type); | |
48 | $this->assertEquals('http://example.com/test.crm.extension.browsertest.a-0.1.zip', $exts['test.crm.extension.browsertest.a']->downloadUrl); | |
49 | $this->assertEquals('http://example.com/test.crm.extension.browsertest.b-1.2.zip', $exts['test.crm.extension.browsertest.b']->downloadUrl); | |
50 | } | |
51 | ||
00be9182 | 52 | public function testGetExtension_good() { |
86bfa4f6 | 53 | $browser = new CRM_Extension_Browser('file://' . dirname(__FILE__) . '/dataset/good-repository', '/index.html', $this->createTempDir('ext-cache-')); |
6a488035 TO |
54 | $this->assertEquals(TRUE, $browser->isEnabled()); |
55 | $this->assertEquals(array(), $browser->checkRequirements()); | |
56 | ||
57 | $info = $browser->getExtension('test.crm.extension.browsertest.b'); | |
58 | $this->assertEquals('module', $info->type); | |
59 | $this->assertEquals('http://example.com/test.crm.extension.browsertest.b-1.2.zip', $info->downloadUrl); | |
60 | } | |
61 | ||
00be9182 | 62 | public function testGetExtension_nonexistent() { |
86bfa4f6 | 63 | $browser = new CRM_Extension_Browser('file://' . dirname(__FILE__) . '/dataset/good-repository', '/index.html', $this->createTempDir('ext-cache-')); |
6a488035 TO |
64 | $this->assertEquals(TRUE, $browser->isEnabled()); |
65 | $this->assertEquals(array(), $browser->checkRequirements()); | |
66 | ||
67 | $info = $browser->getExtension('test.crm.extension.browsertest.nonexistent'); | |
68 | $this->assertEquals(NULL, $info); | |
69 | } | |
96025800 | 70 | |
6a488035 | 71 | } |