-
Notifications
You must be signed in to change notification settings - Fork 0
/
MeocloudClientTest.php
70 lines (54 loc) · 1.89 KB
/
MeocloudClientTest.php
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
66
67
68
69
70
<?php
include_once "vendor/autoload.php";
use Dotenv\Dotenv;
use \PHPUnit\Framework\TestCase;
use \Faker\Factory;
use \digfish\meocloudclient\MeocloudClient;
final class MeocloudClientTest extends TestCase {
var $client;
static $faker;
static $filename;
protected function setUp(): void {
//parent::setUp();
$dotenv = Dotenv::createImmutable('.');
$dotenv->load();
self::$filename = 'test_file.txt';
self::$faker = Factory::create();
$this->client = new MeocloudClient();
}
public function testGetMetadata() {
$metadata = $this->client->get_metadata();
$this->assertEquals(200, $this->client->lastStatus);
}
public function testSendFile() {
if (file_exists(self::$filename)) {
unlink(self::$filename);
}
file_put_contents(self::$filename, self::$faker->text(100));
$this->client->send_file(self::$filename);
$this->assertEquals(200, $this->client->lastStatus);
unlink(self::$filename);
}
public function testGetFile() {
$success = $this->client->get_file(self::$filename);
$file_content = $this->assertEquals(200, $this->client->lastStatus);
file_put_contents(self::$filename, $file_content);
}
public function testDeleteFile() {
$this->client->delete_file(self::$filename);
$this->assertEquals(200, $this->client->lastStatus);
}
public function testAccountInfo() {
$info = $this->client->account_info();
$this->assertEquals($this->client->lastStatus,200);
}
public function testCreateFolder() {
$folder = self::$faker->word(8);
$this->client->create_folder('php');
$this->assertEquals($this->client->lastStatus,403);
}
public function testSearch() {
$this->client->search('created','dropbox', 'image/png');
$this->assertEquals($this->client->lastStatus,200);
}
}