Ian province abbreviation patch - issue 724
[civicrm-core.git] / tests / phpunit / CRM / Extension / Container / StaticTest.php
CommitLineData
6a488035
TO
1<?php
2
3require_once 'CiviTest/CiviUnitTestCase.php';
4
aba1cd8b
EM
5/**
6 * Class CRM_Extension_Container_StaticTest
7 */
6a488035 8class CRM_Extension_Container_StaticTest 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 testGetKeysEmpty() {
6a488035
TO
18 $c = new CRM_Extension_Container_Static(array());
19 $this->assertEquals($c->getKeys(), array());
20 }
21
00be9182 22 public function testGetKeys() {
6a488035
TO
23 $c = $this->_createContainer();
24 $this->assertEquals($c->getKeys(), array('test.foo', 'test.foo.bar'));
25 }
26
00be9182 27 public function testGetPath() {
6a488035
TO
28 $c = $this->_createContainer();
29 try {
30 $c->getPath('un.kno.wn');
0db6c3e1
TO
31 }
32 catch (CRM_Extension_Exception $e) {
6a488035
TO
33 $exc = $e;
34 }
35 $this->assertTrue(is_object($exc), 'Expected exception');
36
37 $this->assertEquals("/path/to/foo", $c->getPath('test.foo'));
38 $this->assertEquals("/path/to/bar", $c->getPath('test.foo.bar'));
39 }
40
00be9182 41 public function testGetResUrl() {
6a488035
TO
42 $c = $this->_createContainer();
43 try {
44 $c->getResUrl('un.kno.wn');
0db6c3e1
TO
45 }
46 catch (CRM_Extension_Exception $e) {
6a488035
TO
47 $exc = $e;
48 }
49 $this->assertTrue(is_object($exc), 'Expected exception');
50
51 $this->assertEquals('http://foo', $c->getResUrl('test.foo'));
52 $this->assertEquals('http://foobar', $c->getResUrl('test.foo.bar'));
53 }
54
4cbe18b8
EM
55 /**
56 * @return CRM_Extension_Container_Static
57 */
00be9182 58 public function _createContainer() {
6a488035
TO
59 return new CRM_Extension_Container_Static(array(
60 'test.foo' => array(
61 'path' => '/path/to/foo',
62 'resUrl' => 'http://foo',
63 ),
64 'test.foo.bar' => array(
65 'path' => '/path/to/bar',
66 'resUrl' => 'http://foobar',
67 ),
68 ));
69 }
96025800 70
6a488035 71}