/tests/suite/joomla/JVersionTest.php
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
- <?php
- /**
- * JVersionTest
- *
- * @version $Id: JVersionTest.php 20196 2011-01-09 02:40:25Z ian $
- * @package Joomla.UnitTest
- * @copyright Copyright (C) 2005 - 2011 Open Source Matters. All rights reserved.
- * @license GNU General Public License
- */
- include_once JPATH_PLATFORM.'/version.php';
- /**
- * JVersionTest
- *
- * Test class for JVersion.
- * Generated by PHPUnit on 2009-10-08 at 21:36:41.
- *
- * @package Joomla.UnitTest
- * @subpackage Utilities
- */
- class JVersionTest extends PHPUnit_Framework_TestCase
- {
- /**
- * @var JVersion
- */
- protected $object;
- protected $PRODUCT = 'Joomla!';
- protected $RELEASE = '12.23';
- protected $DEV_STATUS = 'Testing';
- protected $DEV_LEVEL = '999';
- protected $BUILD = '99999';
- protected $CODENAME = 'Desperation';
- protected $RELDATE = '22-June-3109';
- protected $RELTIME = '13:13';
- protected $RELTZ = 'CDT';
- protected $COPYRIGHT = 'Copyright (C) 2005 - 3109 Open Source Matters. All rights reserved.';
- protected $URL = '<a href="http://www.joomla.org">Joomla!</a> is Free Software released under the GNU General Public License.';
- /**
- * Sets up the fixture, for example, opens a network connection.
- * This method is called before a test is executed.
- *
- * @return void
- */
- protected function setUp()
- {
- }
- /**
- * Tears down the fixture, for example, closes a network connection.
- * This method is called after a test is executed.
- *
- * @return void
- */
- protected function tearDown()
- {
- }
- /**
- * This checks for the correct Long Version.
- *
- * @return void
- */
- public function testGetLongVersion()
- {
- $expected = 'Joomla Platform 11.1.0 Dev [ Ember ] 15-Apr-2011 00:00 GMT';
- $this->assertEquals(
- $expected,
- JVersion::getLongVersion(),
- 'Should get the correct Long Version'
- );
- }
- /**
- * This checks for the correct Short Version.
- *
- * @return void
- */
- public function testGetShortVersion()
- {
- $expected = '11.1.0';
- $this->assertEquals(
- $expected,
- JVersion::getShortVersion(),
- 'Should get the correct Short Version'
- );
- }
- /**
- * Compatibility test cases
- *
- * @return array
- */
- function casesCompatibility()
- {
- return array(
- 'wrong' => array(
- '0.3',
- false,
- 'Should not be compatible with 0.3',
- ),
- 'empty' => array(
- '',
- false,
- 'Should not be compatible with empty string',
- ),
- 'null' => array(
- null,
- false,
- 'Should not be compatible with null',
- ),
- 'itself' => array(
- JVERSION,
- true,
- 'Should be compatible with itself',
- ),
- 'version 11.1.0' => array(
- '11.1.0',
- true,
- 'Should be compatible with 11.1.0',
- ),
- 'version 1.5.22' => array(
- '1.5.22',
- false,
- 'Should not be compatible with 1.5.22',
- ),
- 'version 1.7.0' => array(
- '1.7.0',
- false,
- 'Should not be compatible with 1.7.0',
- ),
- );
- }
- /**
- * This checks the compatibility testing method.
- *
- * @param string $input Version
- * @param bool $expect expected result of version check
- * @param string $message Test failure message
- *
- * @return void
- * @dataProvider casesCompatibility
- */
- public function testIsCompatible( $input, $expect, $message )
- {
- $this->assertThat(
- $expect,
- $this->equalTo(JVersion::isCompatible($input)),
- $message
- );
- }
- /**
- * This checks for correct operation of the __set_state() magic function, if it exists.
- *
- * @return void
- */
- public function testSetState()
- {
- if (method_exists('JVersion', '__set_state'))
- {
- $testData = array(
- 'PRODUCT' => 'Joomla!',
- 'RELEASE' => '1.6',
- 'DEV_STATUS' => 'Alpha',
- 'DEV_LEVEL' => '0',
- 'BUILD' => '',
- 'CODENAME' => 'Hope',
- 'RELDATE' => '22-June-2009',
- 'RELTIME' => '23:00',
- 'RELTZ' => 'GMT',
- 'COPYRIGHT' => 'Copyright (C) 2005 - 2011 Open Source Matters. All rights reserved.',
- 'URL' => '<a href="http://www.joomla.org">Joomla!</a> is Free Software released under the GNU General Public License.'
- );
- $testInstance = $this->object->__set_state($testData);
- foreach ($testData as $key => $value)
- {
- $this->assertThat(
- $testInstance->$key,
- $this->equalTo($value)
- );
- }
- $this->assertThat(
- $testInstance,
- $this->isInstanceOf('JVersion')
- );
- }
- }
- }