PageRenderTime 45ms CodeModel.GetById 20ms RepoModel.GetById 0ms app.codeStats 0ms

/tests/ZendTest/Console/RequestTest.php

https://bitbucket.org/gencer/zf2
PHP | 42 lines | 26 code | 6 blank | 10 comment | 2 complexity | 53cfb4a7dab17b6ef156fdb948174823 MD5 | raw file
  1. <?php
  2. /**
  3. * Zend Framework (http://framework.zend.com/)
  4. *
  5. * @link http://github.com/zendframework/zf2 for the canonical source repository
  6. * @copyright Copyright (c) 2005-2014 Zend Technologies USA Inc. (http://www.zend.com)
  7. * @license http://framework.zend.com/license/new-bsd New BSD License
  8. */
  9. namespace ZendTest\Console;
  10. use Zend\Console\Request;
  11. /**
  12. * @group Zend_Console
  13. */
  14. class RequestTest extends \PHPUnit_Framework_TestCase
  15. {
  16. public function setUp()
  17. {
  18. if (ini_get('register_argc_argv') == false) {
  19. $this->markTestSkipped("Cannot Test Zend\\Console\\Getopt without 'register_argc_argv' ini option true.");
  20. }
  21. }
  22. public function testCanConstructRequestAndGetParams()
  23. {
  24. $_SERVER['argv'] = array('foo.php', 'foo' => 'baz', 'bar');
  25. $_ENV["FOO_VAR"] = "bar";
  26. $request = new Request();
  27. $params = $request->getParams();
  28. $this->assertEquals(2, count($params));
  29. $this->assertEquals($params->toArray(), array('foo' => 'baz', 'bar'));
  30. $this->assertEquals($request->getParam('foo'), 'baz');
  31. $this->assertEquals($request->getScriptName(), 'foo.php');
  32. $this->assertEquals(1, count($request->env()));
  33. $this->assertEquals($request->env()->get('FOO_VAR'), 'bar');
  34. $this->assertEquals($request->getEnv('FOO_VAR'), 'bar');
  35. }
  36. }