PluginProbe ʕ •ᴥ•ʔ
Booking for Appointments and Events Calendar – Amelia / 2.4.6
Booking for Appointments and Events Calendar – Amelia v2.4.6
2.4.7 2.4.6 2.4.5 2.4.4 2.4.3 2.4.2 2.4.1 2.4 trunk 1.2.1 1.2.10 1.2.11 1.2.12 1.2.13 1.2.14 1.2.15 1.2.16 1.2.17 1.2.18 1.2.19 1.2.2 1.2.20 1.2.21 1.2.22 1.2.23 1.2.24 1.2.25 1.2.26 1.2.27 1.2.28 1.2.29 1.2.3 1.2.30 1.2.31 1.2.32 1.2.33 1.2.34 1.2.35 1.2.36 1.2.37 1.2.38 1.2.4 1.2.5 1.2.6 1.2.7 1.2.8 1.2.9 2.0 2.0.1 2.0.2 2.1 2.1.1 2.1.2 2.1.3 2.2 2.2.1 2.3
ameliabooking / vendor / apimatic / unirest-php / tests / BodyTest.php
ameliabooking / vendor / apimatic / unirest-php / tests Last commit date
Mocking 2 years ago BodyTest.php 2 years ago RequestTest.php 2 years ago ResponseTest.php 2 years ago bootstrap.php 2 years ago
BodyTest.php
89 lines
1 <?php
2
3 namespace Unirest\Test;
4
5 use PHPUnit\Framework\TestCase;
6 use Unirest\Request\Body;
7 use Unirest\Request\Request;
8
9 class BodyTest extends TestCase
10 {
11 public function testCURLFile()
12 {
13 $fixture = __DIR__ . '/Mocking/upload.txt';
14
15 $file = Body::File($fixture);
16
17 if (PHP_MAJOR_VERSION === 5 && PHP_MINOR_VERSION === 4) {
18 $this->assertEquals($file, sprintf('@%s;filename=%s;type=', $fixture, basename($fixture)));
19 } else {
20 $this->assertTrue($file instanceof \CURLFile);
21 }
22 }
23
24 public function testHttpBuildQueryWithCurlFile()
25 {
26 $fixture = __DIR__ . '/Mocking/upload.txt';
27
28 $file = Body::File($fixture);
29 $body = [
30 'to' => 'mail@mailinator.com',
31 'from' => 'mail@mailinator.com',
32 'file' => $file
33 ];
34
35 $result = Request::buildHTTPCurlQuery($body);
36 $this->assertEquals($result['file'], $file);
37 }
38
39 public function testJson()
40 {
41 $body = Body::Json(['foo', 'bar']);
42
43 $this->assertEquals($body, '["foo","bar"]');
44 }
45
46 public function testForm()
47 {
48 $body = Body::Form(['foo' => 'bar', 'bar' => 'baz']);
49
50 $this->assertEquals($body, 'foo=bar&bar=baz');
51
52 // try again with a string
53 $body = Body::Form($body);
54
55 $this->assertEquals($body, 'foo=bar&bar=baz');
56 }
57
58 public function testMultipart()
59 {
60 $arr = ['foo' => 'bar', 'bar' => 'baz'];
61
62 $body = Body::Multipart((object) $arr);
63
64 $this->assertEquals($body, $arr);
65
66 $body = Body::Multipart('flat');
67
68 $this->assertEquals($body, ['flat']);
69 }
70
71 public function testMultipartFiles()
72 {
73 $fixture = __DIR__ . '/Mocking/upload.txt';
74
75 $data = ['foo' => 'bar', 'bar' => 'baz'];
76 $files = ['test' => $fixture];
77
78 $body = Body::Multipart($data, $files);
79
80 // echo $body;
81
82 $this->assertEquals($body, [
83 'foo' => 'bar',
84 'bar' => 'baz',
85 'test' => Body::File($fixture)
86 ]);
87 }
88 }
89