commiting uncommited changes on live site
[weblabels.fsf.org.git] / crm.fsf.org / 20131203 / files / sites / all / modules-new / civicrm / tests / phpunit / CRM / Extension / Container / StaticTest.php
1 <?php
2
3 require_once 'CiviTest/CiviUnitTestCase.php';
4
5 /**
6 * Class CRM_Extension_Container_StaticTest
7 */
8 class CRM_Extension_Container_StaticTest extends CiviUnitTestCase {
9 public function setUp() {
10 parent::setUp();
11 }
12
13 public function tearDown() {
14 parent::tearDown();
15 }
16
17 public function testGetKeysEmpty() {
18 $c = new CRM_Extension_Container_Static(array());
19 $this->assertEquals($c->getKeys(), array());
20 }
21
22 public function testGetKeys() {
23 $c = $this->_createContainer();
24 $this->assertEquals($c->getKeys(), array('test.foo', 'test.foo.bar'));
25 }
26
27 public function testGetPath() {
28 $c = $this->_createContainer();
29 try {
30 $c->getPath('un.kno.wn');
31 }
32 catch (CRM_Extension_Exception $e) {
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
41 public function testGetResUrl() {
42 $c = $this->_createContainer();
43 try {
44 $c->getResUrl('un.kno.wn');
45 }
46 catch (CRM_Extension_Exception $e) {
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
55 /**
56 * @return CRM_Extension_Container_Static
57 */
58 public function _createContainer() {
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 }
70
71 }