<?php
/**
 * Zend Framework
 *
 * LICENSE
 *
 * This source file is subject to the new BSD license that is bundled
 * with this package in the file LICENSE.txt.
 * It is also available through the world-wide-web at this URL:
 * http://framework.zend.com/license/new-bsd
 * If you did not receive a copy of the license and are unable to
 * obtain it through the world-wide-web, please send an email
 * to license@zend.com so we can send you a copy immediately.
 *
 * @category   Zend
 * @package    Zend_Controller
 * @subpackage UnitTests
 * @copyright  Copyright (c) 2005-2011 Zend Technologies USA Inc. (http://www.zend.com)
 * @license    http://framework.zend.com/license/new-bsd     New BSD License
 * @version    $Id: SimpleTest.php 24373 2011-08-13 21:50:10Z padraic $
 */

// Call Zend_Controller_Request_SimpleTest::main() if this source file is executed directly.
if (!defined("PHPUnit_MAIN_METHOD")) {
    define("PHPUnit_MAIN_METHOD", "Zend_Controller_Request_SimpleTest::main");
}


require_once 'Zend/Controller/Request/Simple.php';

/**
 * Test class for Zend_Controller_Request_Simple.
 *
 * @category   Zend
 * @package    Zend_Controller
 * @subpackage UnitTests
 * @copyright  Copyright (c) 2005-2011 Zend Technologies USA Inc. (http://www.zend.com)
 * @license    http://framework.zend.com/license/new-bsd     New BSD License
 * @group      Zend_Controller
 * @group      Zend_Controller_Request
 */
class Zend_Controller_Request_SimpleTest extends PHPUnit_Framework_TestCase
{
    /**
     * Runs the test methods of this class.
     *
     * @access public
     * @static
     */
    public static function main()
    {

        $suite  = new PHPUnit_Framework_TestSuite("Zend_Controller_Request_SimpleTest");
        $result = PHPUnit_TextUI_TestRunner::run($suite);
    }

    public function testSimpleRequestIsOfAbstractRequestType()
    {
        $request = new Zend_Controller_Request_Simple();
        $this->assertTrue($request instanceof Zend_Controller_Request_Abstract);
    }

    public function testSimpleReqestRetainsValuesPassedFromConstructor()
    {
        $request = new Zend_Controller_Request_Simple('test1', 'test2', 'test3', array('test4' => 'test5'));
        $this->assertEquals($request->getActionName(), 'test1');
        $this->assertEquals($request->getControllerName(), 'test2');
        $this->assertEquals($request->getModuleName(), 'test3');
        $this->assertEquals($request->getParam('test4'), 'test5');
    }

    /**
     * @group ZF-3472
     */
    public function testSettingParamToNullInSetparamsCorrectlyUnsetsValue()
    {
        $request = new Zend_Controller_Request_Simple;
        $request->setParam('key', 'value');
        $request->setParams(array(
            'key' => null
        ));
        $this->assertNull($request->getParam('key'));
    }

}

// Call Zend_Controller_Request_SimpleTest::main() if this source file is executed directly.
if (PHPUnit_MAIN_METHOD == "Zend_Controller_Request_SimpleTest::main") {
    Zend_Controller_Request_SimpleTest::main();
}
