SimpleIniTest.php 1.6 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273
  1. <?php
  2. /**
  3. * Test helper
  4. */
  5. require_once dirname(__FILE__) . '/../../../TestHelper.php';
  6. /**
  7. * Zend_Config
  8. */
  9. require_once 'Zend/Config.php';
  10. /**
  11. * Zend_Config_Ini
  12. */
  13. require_once 'Zend/Config/Ini.php';
  14. /**
  15. * Zend_Config_Writer_Ini
  16. */
  17. require_once 'Zend/Config/Writer/Ini.php';
  18. require_once "Zend/Config/Writer/SimpleIni.php";
  19. class Zend_Config_Writer_SimpleIniTest extends PHPUnit_Framework_TestCase
  20. {
  21. public function testRender()
  22. {
  23. $config = new Zend_Config(array('test' => 'foo', 'test2' => array('test3' => 'bar')));
  24. $writer = new Zend_Config_Writer_SimpleIni();
  25. $iniString = $writer->setConfig($config)->render();
  26. $expected = <<<ECS
  27. test = "foo"
  28. test2.test3 = "bar"
  29. ECS;
  30. $this->assertEquals($expected, $iniString);
  31. }
  32. public function testRender2()
  33. {
  34. $config = new Zend_Config_Ini(dirname(__FILE__) . '/files/allsections.ini', null, array('skipExtends' => true));
  35. $writer = new Zend_Config_Writer_SimpleIni();
  36. $iniString = $writer->setConfig($config)->render();
  37. $expected = <<<ECS
  38. all.hostname = "all"
  39. all.name = "thisname"
  40. all.db.host = "127.0.0.1"
  41. all.db.user = "username"
  42. all.db.pass = "password"
  43. all.db.name = "live"
  44. all.one.two.three = "multi"
  45. staging.hostname = "staging"
  46. staging.db.name = "dbstaging"
  47. staging.debug = ""
  48. debug.hostname = "debug"
  49. debug.debug = "1"
  50. debug.values.changed = "1"
  51. debug.db.name = "dbdebug"
  52. debug.special.no = ""
  53. debug.special.null = ""
  54. debug.special.false = ""
  55. other_staging.only_in = "otherStaging"
  56. other_staging.db.pass = "anotherpwd"
  57. ECS;
  58. $this->assertEquals($expected, $iniString);
  59. }
  60. }