PluginProbe ʕ •ᴥ•ʔ
Booking for Appointments and Events Calendar – Amelia / 1.2.20
Booking for Appointments and Events Calendar – Amelia v1.2.20
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 / microsoft / microsoft-graph / tests / Http / StreamTest.php
ameliabooking / vendor / microsoft / microsoft-graph / tests / Http Last commit date
GraphCollectionRequestTest.php 1 year ago GraphRequestTest.php 1 year ago GraphResponseTest.php 1 year ago HttpTest.php 1 year ago MockClientFactory.php 1 year ago StreamTest.php 1 year ago
StreamTest.php
100 lines
1 <?php
2 use PHPUnit\Framework\TestCase;
3 use Microsoft\Graph\Graph;
4 use Microsoft\Graph\Http\GraphRequest;
5 use Microsoft\Graph\Exception\GraphException;
6 use org\bovigo\vfs\vfsStream;
7 use org\bovigo\vfs\vfsStreamFile;
8 use org\bovigo\vfs\vfsStreamWrapper;
9 use org\bobigo\vfs\vfsStreamDirectory;
10
11 class StreamTest extends TestCase
12 {
13 private $root;
14 private $client;
15 private $body;
16 private $container;
17
18 public function setUp(): void
19 {
20 $this->root = vfsStream::setup('testDir');
21
22 $this->body = json_encode(array('body' => 'content'));
23 $stream = AmeliaGuzzleHttp\Psr7\Utils::streamFor('content');
24
25 $mock = new AmeliaGuzzleHttp\Handler\MockHandler([
26 new AmeliaGuzzleHttp\Psr7\Response(200, ['foo' => 'bar'], $this->body),
27 new AmeliaGuzzleHttp\Psr7\Response(200,['foo' => 'bar'], $stream),
28 new AmeliaGuzzleHttp\Psr7\Response(200, ['foo' => 'bar'], 'hello')
29 ]);
30
31 $this->container = [];
32 $history = AmeliaGuzzleHttp\Middleware::history($this->container);
33 $handler = AmeliaGuzzleHttp\HandlerStack::create($mock);
34 $handler->push($history);
35 $this->client = new AmeliaGuzzleHttp\Client(['handler' => $handler]);
36 }
37
38 public function testUpload()
39 {
40 $file = new VfsStreamFile('foo.txt');
41 $this->root->addChild($file);
42 $file->setContent('data');
43
44 $request = new GraphRequest("GET", "/me", "token", "url", "v1.0");
45 $request->upload($file->url(), $this->client);
46
47 $this->assertEquals($this->container[0]['request']->getBody()->getContents(), $file->getContent());
48 }
49
50 public function testInvalidUpload()
51 {
52 $this->expectException(Microsoft\Graph\Exception\GraphException::class);
53
54 $file = new VfsStreamFile('foo.txt', 0000);
55 $this->root->addChild($file);
56
57 $request = new GraphRequest("GET", "/me", "token", "url", "v1.0");
58 $request->upload($file->url(), $this->client);
59 }
60
61 public function testDownload()
62 {
63 $request = new GraphRequest("GET", "/me", "token", "url", "v1.0");
64 $file = new VfsStreamFile('foo.txt');
65 $this->root->addChild($file);
66
67 $request->download($file->url(), $this->client);
68 $this->assertEquals($this->body, $file->getContent());
69 }
70
71 public function testInvalidDownload()
72 {
73 set_error_handler(function() {});
74 try {
75 $this->expectException(Microsoft\Graph\Exception\GraphException::class);
76
77 $file = new VfsStreamFile('foo.txt', 0000);
78 $this->root->addChild($file);
79
80 $request = new GraphRequest("GET", "/me", "token", "url", "v1.0");
81 $request->download($file->url(), $this->client);
82 } finally {
83 restore_error_handler();
84 }
85 }
86
87 public function testSetReturnStream()
88 {
89 $request = new GraphRequest("GET", "/me", "token", "url", "v1.0");
90 $request->setReturnType(AmeliaGuzzleHttp\Psr7\Stream::class);
91
92 $this->assertTrue($request->getReturnsStream());
93
94 $response = $request->execute($this->client);
95 $this->assertInstanceOf(AmeliaGuzzleHttp\Psr7\Stream::class, $response);
96
97 $response = $request->execute($this->client);
98 $this->assertInstanceOf(AmeliaGuzzleHttp\Psr7\Stream::class, $response);
99 }
100 }