PluginProbe
StockPack – Stock photos and AI images from Unsplash, Adobe Stock, Freepik and more / 2.4.1
StockPack – Stock photos and AI images from Unsplash, Adobe Stock, Freepik and more v2.4.1
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 / guzzle / tests / Handler / ProxyTest.php

ProxyTest.php in StockPack – Stock photos and AI images from Unsplash, Adobe Stock, Freepik and more 2.4.1, at vendor/guzzlehttp/guzzle/tests/Handler/ProxyTest.php

75 lines 2.0 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 <?php
2 namespace GuzzleHttp\Test\Handler;
3
4 use GuzzleHttp\Handler\MockHandler;
5 use GuzzleHttp\Handler\Proxy;
6 use GuzzleHttp\Psr7\Request;
7 use GuzzleHttp\RequestOptions;
8 use PHPUnit\Framework\TestCase;
9
10 /**
11 * @covers \GuzzleHttp\Handler\Proxy
12 */
13 class ProxyTest extends TestCase
14 {
15 public function testSendsToNonSync()
16 {
17 $a = $b = null;
18 $m1 = new MockHandler([function ($v) use (&$a) {
19 $a = $v;
20 }]);
21 $m2 = new MockHandler([function ($v) use (&$b) {
22 $b = $v;
23 }]);
24 $h = Proxy::wrapSync($m1, $m2);
25 $h(new Request('GET', 'http://foo.com'), []);
26 self::assertNotNull($a);
27 self::assertNull($b);
28 }
29
30 public function testSendsToSync()
31 {
32 $a = $b = null;
33 $m1 = new MockHandler([function ($v) use (&$a) {
34 $a = $v;
35 }]);
36 $m2 = new MockHandler([function ($v) use (&$b) {
37 $b = $v;
38 }]);
39 $h = Proxy::wrapSync($m1, $m2);
40 $h(new Request('GET', 'http://foo.com'), [RequestOptions::SYNCHRONOUS => true]);
41 self::assertNull($a);
42 self::assertNotNull($b);
43 }
44
45 public function testSendsToStreaming()
46 {
47 $a = $b = null;
48 $m1 = new MockHandler([function ($v) use (&$a) {
49 $a = $v;
50 }]);
51 $m2 = new MockHandler([function ($v) use (&$b) {
52 $b = $v;
53 }]);
54 $h = Proxy::wrapStreaming($m1, $m2);
55 $h(new Request('GET', 'http://foo.com'), []);
56 self::assertNotNull($a);
57 self::assertNull($b);
58 }
59
60 public function testSendsToNonStreaming()
61 {
62 $a = $b = null;
63 $m1 = new MockHandler([function ($v) use (&$a) {
64 $a = $v;
65 }]);
66 $m2 = new MockHandler([function ($v) use (&$b) {
67 $b = $v;
68 }]);
69 $h = Proxy::wrapStreaming($m1, $m2);
70 $h(new Request('GET', 'http://foo.com'), ['stream' => true]);
71 self::assertNull($a);
72 self::assertNotNull($b);
73 }
74 }
75