3 require_once 'CiviTest/CiviUnitTestCase.php';
6 * Class CRM_Extension_Container_StaticTest
8 class CRM_Extension_Container_StaticTest
extends CiviUnitTestCase
{
9 public function setUp() {
13 public function tearDown() {
17 public function testGetKeysEmpty() {
18 $c = new CRM_Extension_Container_Static(array());
19 $this->assertEquals($c->getKeys(), array());
22 public function testGetKeys() {
23 $c = $this->_createContainer();
24 $this->assertEquals($c->getKeys(), array('test.foo', 'test.foo.bar'));
27 public function testGetPath() {
28 $c = $this->_createContainer();
30 $c->getPath('un.kno.wn');
32 catch (CRM_Extension_Exception
$e) {
35 $this->assertTrue(is_object($exc), 'Expected exception');
37 $this->assertEquals("/path/to/foo", $c->getPath('test.foo'));
38 $this->assertEquals("/path/to/bar", $c->getPath('test.foo.bar'));
41 public function testGetResUrl() {
42 $c = $this->_createContainer();
44 $c->getResUrl('un.kno.wn');
46 catch (CRM_Extension_Exception
$e) {
49 $this->assertTrue(is_object($exc), 'Expected exception');
51 $this->assertEquals('http://foo', $c->getResUrl('test.foo'));
52 $this->assertEquals('http://foobar', $c->getResUrl('test.foo.bar'));
56 * @return CRM_Extension_Container_Static
58 public function _createContainer() {
59 return new CRM_Extension_Container_Static(array(
61 'path' => '/path/to/foo',
62 'resUrl' => 'http://foo',
64 'test.foo.bar' => array(
65 'path' => '/path/to/bar',
66 'resUrl' => 'http://foobar',