You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

55 lines
1.4 KiB

13 years ago
13 years ago
13 years ago
13 years ago
13 years ago
13 years ago
13 years ago
13 years ago
13 years ago
13 years ago
  1. <?php
  2. /*
  3. * @copyright NetMonsters <team@netmonsters.ru>
  4. * @link http://netmonsters.ru
  5. * @package Majestic
  6. * @subpackage UnitTests
  7. * @since 2011-10-06
  8. *
  9. * Unit tests for Config class
  10. */
  11. require_once dirname(__FILE__) . '/../Registry.php';
  12. require_once dirname(__FILE__) . '/../Config.php';
  13. require_once dirname(__FILE__) . '/../exception/GeneralException.php';
  14. class ConfigTest extends PHPUnit_Framework_TestCase
  15. {
  16. private $_instance = null;
  17. public function setUp()
  18. {
  19. $this->_instance = Config::getInstance();
  20. }
  21. public function testGetInstance()
  22. {
  23. $this->assertSame($this->_instance, Config::getInstance());
  24. /**
  25. * @TODO: Config - class does not instanciate, Registry instead!!! Use late static binding
  26. */
  27. $this->assertNotEquals('Config', get_class(Config::getInstance()));
  28. }
  29. public function testArrayAsParam()
  30. {
  31. $arr = array(
  32. 'one' => 1,
  33. 'two' => 2,
  34. 'three' => 3,
  35. 4 => 'four'
  36. );
  37. Config::set(0, $arr);
  38. $new_arr = Config::get(0);
  39. $this->assertEquals('ConfigArray', get_class($new_arr));
  40. $this->assertEquals('four', $new_arr->offsetGet(4));
  41. $this->assertEquals(1, $new_arr->one);
  42. $this->assertNotEquals(1, $new_arr->offsetGet('two'));
  43. $this->setExpectedException('GeneralException', 'Configuration variable');
  44. $new_arr->some;
  45. }
  46. }