-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathStorageTest.php
More file actions
65 lines (49 loc) · 1.84 KB
/
Copy pathStorageTest.php
File metadata and controls
65 lines (49 loc) · 1.84 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
<?php
declare(strict_types=1);
namespace TestingBot\Tests\Unit\Resource;
use TestingBot\Http\Multipart;
use TestingBot\Tests\Unit\ResourceTestCase;
final class StorageTest extends ResourceTestCase
{
public function testUploadFileSendsMultipart(): void
{
$path = (string) tempnam(sys_get_temp_dir(), 'tb');
file_put_contents($path, 'binary');
try {
$this->client->storage()->uploadFile($path);
} finally {
@unlink($path);
}
$request = $this->assertRequest('POST', 'storage');
self::assertInstanceOf(Multipart::class, $request->body);
self::assertArrayHasKey('file', $request->body->getFields());
}
public function testUploadRemoteUrl(): void
{
$this->client->storage()->uploadRemoteUrl('https://example.com/app.apk');
$request = $this->assertRequest('POST', 'storage');
self::assertSame(['url' => 'https://example.com/app.apk'], $request->body);
}
public function testReplaceStripsScheme(): void
{
$this->client->storage()->replaceRemoteUrl('tb://abc', 'https://example.com/new.apk');
$request = $this->assertRequest('POST', 'storage/abc');
self::assertSame(['url' => 'https://example.com/new.apk'], $request->body);
}
public function testList(): void
{
$this->client->storage()->list(2, 50);
$request = $this->assertRequest('GET', 'storage');
self::assertSame(['offset' => 2, 'count' => 50], $request->query);
}
public function testGetStripsScheme(): void
{
$this->client->storage()->get('tb://abc123');
$this->assertRequest('GET', 'storage/abc123');
}
public function testDeleteStripsScheme(): void
{
$this->client->storage()->delete('tb://abc123');
$this->assertRequest('DELETE', 'storage/abc123');
}
}