-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Enforce passing an explicit status code in ApiResponse
- Loading branch information
Showing
7 changed files
with
98 additions
and
9 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,51 @@ | ||
<?php declare(strict_types=1); | ||
|
||
namespace Tests\Torr\Rad\Api; | ||
|
||
use Symfony\Bridge\PhpUnit\ExpectDeprecationTrait; | ||
use Torr\Rad\Api\ApiResponse; | ||
use PHPUnit\Framework\TestCase; | ||
|
||
class ApiResponseTest extends TestCase | ||
{ | ||
use ExpectDeprecationTrait; | ||
|
||
/** | ||
* | ||
*/ | ||
public function testOk () : void | ||
{ | ||
self::assertTrue((new ApiResponse(202))->isOk()); | ||
self::assertFalse((new ApiResponse(418))->isOk()); | ||
} | ||
|
||
|
||
/** | ||
* @group legacy | ||
*/ | ||
public function testLegacyBoolConstructorTrue () : void | ||
{ | ||
$this->expectDeprecation("Since 21torr/rad 3.1.0: Passing a bool as first value to ApiResponse is deprecated. Pass the status code instead."); | ||
new ApiResponse(true); | ||
} | ||
|
||
/** | ||
* @group legacy | ||
*/ | ||
public function testLegacyBoolConstructorFalse () : void | ||
{ | ||
$this->expectDeprecation("Since 21torr/rad 3.1.0: Passing a bool as first value to ApiResponse is deprecated. Pass the status code instead."); | ||
new ApiResponse(false); | ||
} | ||
|
||
/** | ||
* @group legacy | ||
*/ | ||
public function testLegacyResettingStatusCode () : void | ||
{ | ||
$this->expectDeprecation("Since 21torr/rad 3.1.0: Calling ApiResponse::withStatusCode() is deprecated, pass the status code in the constructor instead."); | ||
|
||
(new ApiResponse(201)) | ||
->withStatusCode(418); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters