ConfigTest.php 1.1 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344
  1. <?php
  2. /**
  3. * Config test class
  4. *
  5. * @author Christopher Han <xiphux@gmail.com>
  6. * @copyright Copyright (c) 2012 Christopher Han
  7. * @package GitPHP
  8. * @subpackage Test
  9. */
  10. class GitPHP_ConfigTest extends PHPUnit_Framework_TestCase
  11. {
  12. protected $config;
  13. protected function setUp()
  14. {
  15. $this->config = new GitPHP_Config();
  16. }
  17. public function testDefaults()
  18. {
  19. $this->assertTrue($this->config->HasKey('locale'));
  20. $this->assertEquals('en_US', $this->config->GetValue('locale'));
  21. }
  22. public function testGetAndSet()
  23. {
  24. $this->assertFalse($this->config->HasKey('testkey'));
  25. $this->config->SetValue('testkey', 'testvalue');
  26. $this->assertTrue($this->config->HasKey('testkey'));
  27. $this->assertEquals('testvalue', $this->config->GetValue('testkey'));
  28. $this->config->SetValue('testkey', null);
  29. $this->assertFalse($this->config->HasKey('testkey'));
  30. $this->assertNull($this->config->GetValue('testkey'));
  31. }
  32. public function testClear()
  33. {
  34. $this->config->SetValue('testkey2', 'testvalue');
  35. $this->assertTrue($this->config->HasKey('testkey2'));
  36. $this->config->ClearConfig();
  37. $this->assertFalse($this->config->HasKey('testkey2'));
  38. }
  39. }