joomla-platform /tests/suite/joomla/JVersionTest.php

Language PHP Lines 196
MD5 Hash 05bef046b2b2808cb8203dff14f0dab4 Estimated Cost $2,916 (why?)
Repository https://bitbucket.org/ankursaxena_2/joomla-platform View Raw File View Project SPDX
  1
  2
  3
  4
  5
  6
  7
  8
  9
 10
 11
 12
 13
 14
 15
 16
 17
 18
 19
 20
 21
 22
 23
 24
 25
 26
 27
 28
 29
 30
 31
 32
 33
 34
 35
 36
 37
 38
 39
 40
 41
 42
 43
 44
 45
 46
 47
 48
 49
 50
 51
 52
 53
 54
 55
 56
 57
 58
 59
 60
 61
 62
 63
 64
 65
 66
 67
 68
 69
 70
 71
 72
 73
 74
 75
 76
 77
 78
 79
 80
 81
 82
 83
 84
 85
 86
 87
 88
 89
 90
 91
 92
 93
 94
 95
 96
 97
 98
 99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
<?php
/**
 * @package     Joomla.UnitTest
 *
 * @copyright   Copyright (C) 2005 - 2011 Open Source Matters, Inc. All rights reserved.
 * @license     GNU General Public License version 2 or later; see LICENSE
 */

defined('JPATH_PLATFORM') or die;

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')
			);
		}
	}
}
Back to Top