Permalink
Browse files

removed conflicts

  • Loading branch information...
1 parent 4e26acf commit dad4ee3c196d9f16fbd904e12b63d4c9c01818f8 @kaviththiranga committed Dec 14, 2012
@@ -1,35 +1,161 @@
<?php
/**
* @package Joomla.UnitTest
- * @subpackage Environment
+ * @subpackage Request
*
* @copyright Copyright (C) 2005 - 2012 Open Source Matters, Inc. All rights reserved.
* @license GNU General Public License version 2 or later; see LICENSE
*/
+require_once __DIR__ . '/JRequest-helper-dataset.php';
+
/**
- * A unit test class for JRequest
+ * Test class for JRequest using $_GET REQUEST_METHOD
+ *
+ * Note:
+ * For tests specific to $_POST, see JRequestPostMethodTest.php
+ *
+ * @package Joomla.UnitTest
+ * @subpackage Request
+ *
+ * @since 12.3
*/
-class JRequestTest_GetMethod extends PHPUnit_Framework_TestCase
+class JRequestTestGetMethod extends TestCase
{
/**
- * Clear the cache
+ * Set up the tests
+ *
+ * @return void
*/
- function setUp() {
- // Make sure the request hash is clean.
- $GLOBALS['_JREQUEST'] = array();
+ protected function setUp()
+ {
+ JRequestTest_DataSet::initSuperGlobals();
+ $_SERVER['REQUEST_METHOD'] = 'GET';
+
+ parent::setUp();
}
/**
- * @covers JRequest::getMethod
+ * Test JRequest::getMethod
+ *
+ * @return void
*/
- function testGetMethod()
+ public function testGetMethod()
{
- $_SERVER['REQUEST_METHOD'] = 'post';
- $this -> assertEquals('POST', JRequest::getMethod());
- $_SERVER['REQUEST_METHOD'] = 'get';
- $this -> assertEquals('GET', JRequest::getMethod());
+ $this->assertEquals('GET', JRequest::getMethod());
}
+ /**
+ * Test JRequest::getVar
+ *
+ * @return void
+ */
+ public function testGetVar()
+ {
+ $this->assertEquals('from _GET', JRequest::getVar('tag', null, 'get'));
+ }
+
+ /**
+ * Test JRequest::getInt
+ *
+ * @return void
+ */
+ public function testGetInt()
+ {
+ $_GET['teststr'] = '2.0';
+ $this->assertTrue(2 === JRequest::getInt('teststr', null, 'get'));
+ }
+
+ /**
+ * Test JRequest::getFloat
+ *
+ * @return void
+ */
+ public function testGetFloat()
+ {
+ $_GET['teststr'] = '1.337';
+ $this->assertTrue(1.337 === JRequest::getFloat('teststr', null, 'get'));
+ }
+
+ /**
+ * Test JRequest::getBool
+ *
+ * @return void
+ */
+ public function testGetBool()
+ {
+ $_GET['teststr'] = 'true';
+ $this->assertTrue(JRequest::getBool('teststr', null, 'get'));
+ }
+
+ /**
+ * Test JRequest::getWord
+ *
+ * @return void
+ */
+ public function testGetWord()
+ {
+ $_GET['teststr'] = 'two2';
+ $this->assertTrue('two' === JRequest::getWord('teststr', null, 'get'));
+ }
+
+ /**
+ * Test JRequest::getCmd
+ *
+ * @return void
+ */
+ public function testGetCmd()
+ {
+ $_GET['teststr'] = 'some_command';
+ $this->assertTrue('some_command' === JRequest::getCmd('teststr', null, 'get'));
+ }
+
+ /**
+ * Test JRequest::getString
+ *
+ * @return void
+ */
+ public function testGetString()
+ {
+ $_GET['teststr'] = 'four';
+ $this->assertTrue('four' === JRequest::getString('teststr', null, 'get'));
+ }
+
+ /**
+ * Test JRequest::setVar
+ *
+ * @return void
+ */
+ public function testSetVar()
+ {
+ JRequest::setVar('foo', 'bar', 'get');
+ $this->assertTrue('bar' === JRequest::getVar('foo', null, 'get'));
+ }
+
+ /**
+ * Test JRequest::get
+ *
+ * @return void
+ */
+ public function testGet()
+ {
+ $expected = array('tag' => 'from _GET');
+ $this->assertSame($expected, JRequest::get('get'));
+ }
+
+ /**
+ * Test JRequest::set
+ *
+ * @return void
+ */
+ public function testSet()
+ {
+ // Empty $_GET var before testing
+ $_GET = array();
+ $get = array('foo' => 'bar', 'key' => 'value');
+ JRequest::set($get, 'get', true);
+
+ $this->assertSame($get, $_GET);
+ }
}
@@ -1,35 +0,0 @@
-<?php
-/**
- * @package Joomla.UnitTest
- * @subpackage Environment
- *
- * @copyright Copyright (C) 2005 - 2012 Open Source Matters, Inc. All rights reserved.
- * @license GNU General Public License version 2 or later; see LICENSE
- */
-
-/**
- * A unit test class for JRequest
- */
-class JRequestTest_GetMethod extends PHPUnit_Framework_TestCase
-{
-
- /**
- * Clear the cache
- */
- function setUp() {
- // Make sure the request hash is clean.
- $GLOBALS['_JREQUEST'] = array();
- }
-
- /**
- * @covers JRequest::getMethod
- */
- function testGetMethod()
- {
- $_SERVER['REQUEST_METHOD'] = 'post';
- $this -> assertEquals('POST', JRequest::getMethod());
- $_SERVER['REQUEST_METHOD'] = 'get';
- $this -> assertEquals('GET', JRequest::getMethod());
- }
-
-}

0 comments on commit dad4ee3

Please sign in to comment.