Guest User

Untitled

a guest
May 26th, 2018
94
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.80 KB | None | 0 0
  1. <?php
  2. /**
  3. * Tests various static getter and setter methods on {@link Object}
  4. *
  5. * @package sapphire
  6. * @subpackage tests
  7. */
  8. class ObjectStaticTest extends SapphireTest {
  9.  
  10. /**
  11. * Tests {@link Object::get_static()}
  12. */
  13. public function testGetStatic() {
  14. $this->assertEquals(Object::get_static('ObjectStaticTest_First', 'first'), array('test_1'));
  15. $this->assertEquals(Object::get_static('ObjectStaticTest_Second', 'first'), array('test_2'));
  16. $this->assertEquals(Object::get_static('ObjectStaticTest_Third', 'first'), array('test_3'));
  17.  
  18. Object::addStaticVars('ObjectStaticTest_First', array('first' => array('test_1_2')));
  19. Object::addStaticVars('ObjectStaticTest_Third', array('first' => array('test_3_2')));
  20. Object::addStaticVars('ObjectStaticTest_Fourth', array('first' => array('test_4')), true);
  21.  
  22. $this->assertEquals(Object::get_static('ObjectStaticTest_First', 'first', true), array('test_1_2', 'test_1'));
  23. $this->assertEquals(Object::get_static('ObjectStaticTest_Second', 'first', true), array('test_1_2', 'test_2'));
  24. $this->assertEquals(Object::get_static('ObjectStaticTest_Third', 'first', true), array('test_3_2', 'test_1_2', 'test_3'));
  25. }
  26.  
  27. /**
  28. * Test {@link Object::addStaticVar()} correctly replaces static vars
  29. */
  30. public function testAddStaticReplace() {
  31. Object::addStaticVars('ObjectStaticTest_Fourth', array('second' => array('test_4')), true);
  32. Object::addStaticVars('ObjectStaticTest_Third', array('second' => array('test_3_2')));
  33.  
  34. $this->assertEquals(Object::get_static('ObjectStaticTest_Fourth', 'second', true), array('test_4'));
  35. $this->assertEquals(Object::get_static('ObjectStaticTest_Third', 'second', true), array('test_3_2', 'test_3'));
  36.  
  37. Object::addStaticVars('ObjectStaticTest_Third', array('second' => array('test_3_2')), true);
  38.  
  39. $this->assertEquals(Object::get_static('ObjectStaticTest_Third', 'second', true), array('test_3_2'));
  40. }
  41.  
  42. /**
  43. * Tests {@link Object::uninherited_static()}
  44. *
  45. * @todo figure out the $builtIn param
  46. */
  47. public function testUninherited() {
  48. $this->assertEquals(Object::uninherited_static('ObjectStaticTest_First', 'third', true), 'test_1');
  49. $this->assertEquals(Object::uninherited_static('ObjectStaticTest_Fourth', 'third', true), null);
  50. }
  51.  
  52. }
  53.  
  54. /**#@+
  55. * @ignore
  56. */
  57. class ObjectStaticTest_First extends Object {
  58. public static $first = array('test_1');
  59. public static $second = array('test_1');
  60. public static $third = 'test_1';
  61. }
  62.  
  63. class ObjectStaticTest_Second extends ObjectStaticTest_First {
  64. public static $first = array('test_2');
  65. }
  66.  
  67. class ObjectStaticTest_Third extends ObjectStaticTest_Second {
  68. public static $first = array('test_3');
  69. public static $second = array('test_3');
  70. }
  71.  
  72. class ObjectStaticTest_Fourth extends ObjectStaticTest_Third {
  73. }
  74. /**#@-*/
Add Comment
Please, Sign In to add comment