-
Notifications
You must be signed in to change notification settings - Fork 499
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Requests: Add tests for requests.failed hook
- Loading branch information
Showing
3 changed files
with
141 additions
and
0 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
<?php | ||
|
||
namespace WpOrg\Requests\Tests\Fixtures; | ||
|
||
use WpOrg\Requests\Exception; | ||
use WpOrg\Requests\Transport; | ||
|
||
final class TransportFailedMock implements Transport { | ||
public function request($url, $headers = [], $data = [], $options = []) { | ||
throw new Exception('Transport failed!', 'transporterror'); | ||
} | ||
public function request_multiple($requests, $options) { | ||
throw new Exception('Transport failed!', 'transporterror'); | ||
} | ||
public static function test($capabilities = []) { | ||
return true; | ||
} | ||
} |
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,18 @@ | ||
<?php | ||
|
||
namespace WpOrg\Requests\Tests\Fixtures; | ||
|
||
use WpOrg\Requests\Exception\InvalidArgument; | ||
use WpOrg\Requests\Transport; | ||
|
||
final class TransportInvalidArgumentMock implements Transport { | ||
public function request($url, $headers = [], $data = [], $options = []) { | ||
throw InvalidArgument::create(1, '$url', 'string|Stringable', gettype($url)); | ||
} | ||
public function request_multiple($requests, $options) { | ||
throw InvalidArgument::create(1, '$requests', 'array|ArrayAccess&Traversable', gettype($requests)); | ||
} | ||
public static function test($capabilities = []) { | ||
return true; | ||
} | ||
} |
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