PageRenderTime 47ms CodeModel.GetById 19ms RepoModel.GetById 0ms app.codeStats 0ms

/tests/suite/joomla/JPlatformTest.php

http://github.com/joomla/joomla-platform
PHP | 167 lines | 101 code | 11 blank | 55 comment | 1 complexity | 194a4d70c4222739525c7329c83442d8 MD5 | raw file
Possible License(s): GPL-2.0, LGPL-2.1
  1. <?php
  2. /**
  3. * @package Joomla.UnitTest
  4. *
  5. * @copyright Copyright (C) 2005 - 2012 Open Source Matters, Inc. All rights reserved.
  6. * @license GNU General Public License version 2 or later; see LICENSE
  7. */
  8. include_once JPATH_PLATFORM.'/platform.php';
  9. /**
  10. * JPlatformTest
  11. *
  12. * Test class for JPlatform.
  13. * Generated by PHPUnit on 2009-10-08 at 21:36:41.
  14. *
  15. * @package Joomla.UnitTest
  16. * @subpackage Utilities
  17. */
  18. class JPlatformTest extends PHPUnit_Framework_TestCase
  19. {
  20. /**
  21. * @var JPlatform
  22. */
  23. protected $object;
  24. protected $PRODUCT = 'Joomla!';
  25. protected $RELEASE = '12.23';
  26. protected $DEV_STATUS = 'Testing';
  27. protected $DEV_LEVEL = '999';
  28. protected $BUILD = '99999';
  29. protected $CODENAME = 'Desperation';
  30. protected $RELDATE = '22-June-3109';
  31. protected $RELTIME = '13:13';
  32. protected $RELTZ = 'CDT';
  33. protected $COPYRIGHT = 'Copyright (C) 2005 - 3109 Open Source Matters. All rights reserved.';
  34. protected $URL = '<a href="http://www.joomla.org">Joomla!</a> is Free Software released under the GNU General Public License.';
  35. /**
  36. * Sets up the fixture, for example, opens a network connection.
  37. * This method is called before a test is executed.
  38. *
  39. * @return void
  40. */
  41. protected function setUp()
  42. {
  43. }
  44. /**
  45. * Tears down the fixture, for example, closes a network connection.
  46. * This method is called after a test is executed.
  47. *
  48. * @return void
  49. */
  50. protected function tearDown()
  51. {
  52. }
  53. /**
  54. * This checks for the correct Short Version.
  55. *
  56. * @return void
  57. */
  58. public function testGetShortVersion()
  59. {
  60. $this->markTestSkipped('The platform version number is not tested');
  61. }
  62. /**
  63. * Compatibility test cases
  64. *
  65. * @return array
  66. */
  67. function casesCompatibility()
  68. {
  69. return array(
  70. 'wrong' => array(
  71. '0.3',
  72. false,
  73. 'Should not be compatible with 0.3',
  74. ),
  75. 'empty' => array(
  76. '',
  77. false,
  78. 'Should not be compatible with empty string',
  79. ),
  80. 'null' => array(
  81. null,
  82. false,
  83. 'Should not be compatible with null',
  84. ),
  85. 'itself' => array(
  86. JPlatform::RELEASE.'.'.JPlatform::MAINTENANCE,
  87. true,
  88. 'Should be compatible with itself',
  89. ),
  90. 'version 1.5.22' => array(
  91. '1.5.22',
  92. false,
  93. 'Should not be compatible with 1.5.22',
  94. ),
  95. 'version 1.7.0' => array(
  96. '1.7.0',
  97. false,
  98. 'Should not be compatible with 1.7.0',
  99. ),
  100. );
  101. }
  102. /**
  103. * This checks the compatibility testing method.
  104. *
  105. * @param string $input Version
  106. * @param bool $expect expected result of version check
  107. * @param string $message Test failure message
  108. *
  109. * @return void
  110. * @dataProvider casesCompatibility
  111. */
  112. public function testIsCompatible( $input, $expect, $message )
  113. {
  114. $this->assertThat(
  115. $expect,
  116. $this->equalTo(JPlatform::isCompatible($input)),
  117. $message
  118. );
  119. }
  120. /**
  121. * This checks for correct operation of the __set_state() magic function, if it exists.
  122. *
  123. * @return void
  124. */
  125. public function testSetState()
  126. {
  127. if (method_exists('JPlatform', '__set_state'))
  128. {
  129. $testData = array(
  130. 'PRODUCT' => 'Joomla!',
  131. 'RELEASE' => '1.6',
  132. 'DEV_STATUS' => 'Alpha',
  133. 'DEV_LEVEL' => '0',
  134. 'BUILD' => '',
  135. 'CODENAME' => 'Hope',
  136. 'RELDATE' => '22-June-2009',
  137. 'RELTIME' => '23:00',
  138. 'RELTZ' => 'GMT',
  139. 'COPYRIGHT' => 'Copyright (C) 2005 - 2012 Open Source Matters. All rights reserved.',
  140. 'URL' => '<a href="http://www.joomla.org">Joomla!</a> is Free Software released under the GNU General Public License.'
  141. );
  142. $testInstance = $this->object->__set_state($testData);
  143. foreach ($testData as $key => $value)
  144. {
  145. $this->assertThat(
  146. $testInstance->$key,
  147. $this->equalTo($value)
  148. );
  149. }
  150. $this->assertThat(
  151. $testInstance,
  152. $this->isInstanceOf('JPlatform')
  153. );
  154. }
  155. }
  156. }