PageRenderTime 39ms CodeModel.GetById 15ms RepoModel.GetById 0ms app.codeStats 0ms

/tests/suite/joomla/JVersionTest.php

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