1
0

V2ResponseTest.php 1.1 KB

1234567891011121314151617181920212223242526272829303132333435363738
  1. <?php
  2. declare(strict_types=1);
  3. /**
  4. * SPDX-FileCopyrightText: 2020 Nextcloud GmbH and Nextcloud contributors
  5. * SPDX-License-Identifier: AGPL-3.0-or-later
  6. */
  7. namespace Test\AppFramework\OCS;
  8. use OC\AppFramework\OCS\V2Response;
  9. use OCP\AppFramework\Http;
  10. use OCP\AppFramework\Http\DataResponse;
  11. use OCP\AppFramework\OCSController;
  12. class V2ResponseTest extends \Test\TestCase {
  13. /**
  14. * @dataProvider providesStatusCodes
  15. */
  16. public function testStatusCodeMapper(int $expected, int $sc): void {
  17. $response = new V2Response(new DataResponse([], $sc));
  18. $this->assertEquals($expected, $response->getStatus());
  19. }
  20. public function providesStatusCodes(): array {
  21. return [
  22. [Http::STATUS_OK, 200],
  23. [Http::STATUS_BAD_REQUEST, 104],
  24. [Http::STATUS_BAD_REQUEST, 1000],
  25. [201, 201],
  26. [Http::STATUS_UNAUTHORIZED, OCSController::RESPOND_UNAUTHORISED],
  27. [Http::STATUS_INTERNAL_SERVER_ERROR, OCSController::RESPOND_SERVER_ERROR],
  28. [Http::STATUS_NOT_FOUND, OCSController::RESPOND_NOT_FOUND],
  29. [Http::STATUS_INTERNAL_SERVER_ERROR, OCSController::RESPOND_UNKNOWN_ERROR],
  30. ];
  31. }
  32. }