InternalTest.php 1.9 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768
  1. <?php defined('SYSPATH') OR die('Kohana bootstrap needs to be included before tests run');
  2. /**
  3. * Unit tests for internal request client
  4. *
  5. * @group kohana
  6. * @group kohana.core
  7. * @group kohana.core.request
  8. * @group kohana.core.request.client
  9. * @group kohana.core.request.client.internal
  10. *
  11. * @package Kohana
  12. * @category Tests
  13. * @author Kohana Team
  14. * @copyright (c) 2008-2012 Kohana Team
  15. * @license http://kohanaframework.org/license
  16. */
  17. class Kohana_Request_Client_InternalTest extends Unittest_TestCase
  18. {
  19. public function provider_response_failure_status()
  20. {
  21. return array(
  22. array('', 'Welcome', 'missing_action', 'Welcome/missing_action', 404),
  23. array('kohana3', 'missing_controller', 'index', 'kohana3/missing_controller/index', 404),
  24. array('', 'Template', 'missing_action', 'kohana3/Template/missing_action', 500),
  25. );
  26. }
  27. /**
  28. * Tests for correct exception messages
  29. *
  30. * @test
  31. * @dataProvider provider_response_failure_status
  32. *
  33. * @return null
  34. */
  35. public function test_response_failure_status($directory, $controller, $action, $uri, $expected)
  36. {
  37. // Mock for request object
  38. $request = $this->getMock('Request', array('directory', 'controller', 'action', 'uri', 'response'), array($uri));
  39. $request->expects($this->any())
  40. ->method('directory')
  41. ->will($this->returnValue($directory));
  42. $request->expects($this->any())
  43. ->method('controller')
  44. ->will($this->returnValue($controller));
  45. $request->expects($this->any())
  46. ->method('action')
  47. ->will($this->returnValue($action));
  48. $request->expects($this->any())
  49. ->method('uri')
  50. ->will($this->returnValue($uri));
  51. $request->expects($this->any())
  52. ->method('response')
  53. ->will($this->returnValue($this->getMock('Response')));
  54. $internal_client = new Request_Client_Internal;
  55. $response = $internal_client->execute($request);
  56. $this->assertSame($expected, $response->status());
  57. }
  58. }