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.

56 lines
1.4 KiB

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. class ConfigTest extends PHPUnit_Framework_TestCase
  14. {
  15. private $_instance = null;
  16. public function setUp()
  17. {
  18. $this->_instance = Config::getInstance();
  19. }
  20. public function testGetInstance()
  21. {
  22. $this->assertSame($this->_instance, Config::getInstance());
  23. /**
  24. * @TODO: Config - class does not instanciate, Registry instead!!! Use late static binding
  25. */
  26. $this->assertNotEquals('Config', get_class(Config::getInstance()));
  27. }
  28. /**
  29. * @expectedException Exception
  30. */
  31. public function testArrayAsParam()
  32. {
  33. $arr = array(
  34. 'one' => 1,
  35. 'two' => 2,
  36. 'three' => 3,
  37. 4 => 'four'
  38. );
  39. Config::set(0, $arr);
  40. $new_arr = Config::get(0);
  41. $this->assertEquals('ConfigArray', get_class($new_arr));
  42. $this->assertEquals('four', $new_arr->offsetGet(4));
  43. $this->assertEquals(1, $new_arr->offsetGet('one'));
  44. $this->assertNotEquals(1, $new_arr->offsetGet('two'));
  45. $new_arr->offsetGet(24);
  46. }
  47. }