PageRenderTime 719ms CodeModel.GetById 38ms RepoModel.GetById 0ms app.codeStats 0ms

/tests/suite/joomla/JVersionTest.php

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