PluginProbe
StockPack – Stock photos and AI images from Unsplash, Adobe Stock, Freepik and more / 2.4.2
StockPack – Stock photos and AI images from Unsplash, Adobe Stock, Freepik and more v2.4.2
3.7.2 3.7.1 3.7.0 3.6.0 3.6.1 3.5.2 trunk 2.0 2.1 2.2 2.3 2.4 2.4.1 2.4.2 2.4.3 2.5.0 2.5.1 2.5.2 2.5.3 2.5.4 2.5.5 2.5.6 2.5.7 2.6.0 2.6.1 All 73 releases
stockpack / vendor / guzzlehttp / promises / tests / RejectionExceptionTest.php

RejectionExceptionTest.php in StockPack – Stock photos and AI images from Unsplash, Adobe Stock, Freepik and more 2.4.2, at vendor/guzzlehttp/promises/tests/RejectionExceptionTest.php

49 lines 1016 B
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 <?php
2 namespace GuzzleHttp\Promise\Tests;
3
4 use GuzzleHttp\Promise\RejectionException;
5 use PHPUnit\Framework\TestCase;
6
7 class Thing1
8 {
9 public function __construct($message)
10 {
11 $this->message = $message;
12 }
13
14 public function __toString()
15 {
16 return $this->message;
17 }
18 }
19
20 class Thing2 implements \JsonSerializable
21 {
22 public function jsonSerialize()
23 {
24 return '{}';
25 }
26 }
27
28 /**
29 * @covers GuzzleHttp\Promise\RejectionException
30 */
31 class RejectionExceptionTest extends TestCase
32 {
33 public function testCanGetReasonFromException()
34 {
35 $thing = new Thing1('foo');
36 $e = new RejectionException($thing);
37
38 $this->assertSame($thing, $e->getReason());
39 $this->assertEquals('The promise was rejected with reason: foo', $e->getMessage());
40 }
41
42 public function testCanGetReasonMessageFromJson()
43 {
44 $reason = new Thing2();
45 $e = new RejectionException($reason);
46 $this->assertContains("{}", $e->getMessage());
47 }
48 }
49