HttpTest.php 1.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263
  1. <?php
  2. /**
  3. * ownCloud - App Framework
  4. *
  5. * @author Bernhard Posselt
  6. * @copyright 2012 Bernhard Posselt <dev@bernhard-posselt.com>
  7. *
  8. * This library is free software; you can redistribute it and/or
  9. * modify it under the terms of the GNU AFFERO GENERAL PUBLIC LICENSE
  10. * License as published by the Free Software Foundation; either
  11. * version 3 of the License, or any later version.
  12. *
  13. * This library is distributed in the hope that it will be useful,
  14. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  15. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  16. * GNU AFFERO GENERAL PUBLIC LICENSE for more details.
  17. *
  18. * You should have received a copy of the GNU Affero General Public
  19. * License along with this library. If not, see <http://www.gnu.org/licenses/>.
  20. *
  21. */
  22. namespace Test\AppFramework\Http;
  23. use OC\AppFramework\Http;
  24. class HttpTest extends \Test\TestCase {
  25. private $server;
  26. /**
  27. * @var Http
  28. */
  29. private $http;
  30. protected function setUp(): void {
  31. parent::setUp();
  32. $this->server = [];
  33. $this->http = new Http($this->server);
  34. }
  35. public function testProtocol() {
  36. $header = $this->http->getStatusHeader(Http::STATUS_TEMPORARY_REDIRECT);
  37. $this->assertEquals('HTTP/1.1 307 Temporary Redirect', $header);
  38. }
  39. public function testProtocol10() {
  40. $this->http = new Http($this->server, 'HTTP/1.0');
  41. $header = $this->http->getStatusHeader(Http::STATUS_OK);
  42. $this->assertEquals('HTTP/1.0 200 OK', $header);
  43. }
  44. public function testTempRedirectBecomesFoundInHttp10() {
  45. $http = new Http([], 'HTTP/1.0');
  46. $header = $http->getStatusHeader(Http::STATUS_TEMPORARY_REDIRECT);
  47. $this->assertEquals('HTTP/1.0 302 Found', $header);
  48. }
  49. // TODO: write unittests for http codes
  50. }