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 / guzzle / tests / functionsTest.php

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

145 lines 3.4 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 <?php
2 namespace GuzzleHttp\Test;
3
4 use GuzzleHttp;
5 use PHPUnit\Framework\TestCase;
6
7 class FunctionsTest extends TestCase
8 {
9 public function testExpandsTemplate()
10 {
11 self::assertSame(
12 'foo/123',
13 GuzzleHttp\uri_template('foo/{bar}', ['bar' => '123'])
14 );
15 }
16 public function noBodyProvider()
17 {
18 return [['get'], ['head'], ['delete']];
19 }
20
21 public function testProvidesDefaultUserAgent()
22 {
23 $ua = GuzzleHttp\default_user_agent();
24 self::assertRegExp('#^GuzzleHttp/.+ curl/.+ PHP/.+$#', $ua);
25 }
26
27 public function typeProvider()
28 {
29 return [
30 ['foo', 'string(3) "foo"'],
31 [true, 'bool(true)'],
32 [false, 'bool(false)'],
33 [10, 'int(10)'],
34 [1.0, 'float(1)'],
35 [new StrClass(), 'object(GuzzleHttp\Test\StrClass)'],
36 [['foo'], 'array(1)']
37 ];
38 }
39 /**
40 * @dataProvider typeProvider
41 */
42 public function testDescribesType($input, $output)
43 {
44 self::assertSame($output, GuzzleHttp\describe_type($input));
45 }
46
47 public function testParsesHeadersFromLines()
48 {
49 $lines = ['Foo: bar', 'Foo: baz', 'Abc: 123', 'Def: a, b'];
50 self::assertSame([
51 'Foo' => ['bar', 'baz'],
52 'Abc' => ['123'],
53 'Def' => ['a, b'],
54 ], GuzzleHttp\headers_from_lines($lines));
55 }
56
57 public function testParsesHeadersFromLinesWithMultipleLines()
58 {
59 $lines = ['Foo: bar', 'Foo: baz', 'Foo: 123'];
60 self::assertSame([
61 'Foo' => ['bar', 'baz', '123'],
62 ], GuzzleHttp\headers_from_lines($lines));
63 }
64
65 public function testReturnsDebugResource()
66 {
67 self::assertInternalType('resource', GuzzleHttp\debug_resource());
68 }
69
70 public function testProvidesDefaultCaBundler()
71 {
72 self::assertFileExists(GuzzleHttp\default_ca_bundle());
73 }
74
75 public function noProxyProvider()
76 {
77 return [
78 ['mit.edu', ['.mit.edu'], false],
79 ['foo.mit.edu', ['.mit.edu'], true],
80 ['mit.edu', ['mit.edu'], true],
81 ['mit.edu', ['baz', 'mit.edu'], true],
82 ['mit.edu', ['', '', 'mit.edu'], true],
83 ['mit.edu', ['baz', '*'], true],
84 ];
85 }
86
87 /**
88 * @dataProvider noproxyProvider
89 */
90 public function testChecksNoProxyList($host, $list, $result)
91 {
92 self::assertSame(
93 $result,
94 \GuzzleHttp\is_host_in_noproxy($host, $list)
95 );
96 }
97
98 /**
99 * @expectedException \InvalidArgumentException
100 */
101 public function testEnsuresNoProxyCheckHostIsSet()
102 {
103 \GuzzleHttp\is_host_in_noproxy('', []);
104 }
105
106 public function testEncodesJson()
107 {
108 self::assertSame('true', \GuzzleHttp\json_encode(true));
109 }
110
111 /**
112 * @expectedException \InvalidArgumentException
113 */
114 public function testEncodesJsonAndThrowsOnError()
115 {
116 \GuzzleHttp\json_encode("\x99");
117 }
118
119 public function testDecodesJson()
120 {
121 self::assertTrue(\GuzzleHttp\json_decode('true'));
122 }
123
124 /**
125 * @expectedException \InvalidArgumentException
126 */
127 public function testDecodesJsonAndThrowsOnError()
128 {
129 \GuzzleHttp\json_decode('{{]]');
130 }
131
132 public function testCurrentTime()
133 {
134 self::assertGreaterThan(0, GuzzleHttp\_current_time());
135 }
136 }
137
138 final class StrClass
139 {
140 public function __toString()
141 {
142 return 'foo';
143 }
144 }
145