ReviewOS

also looking at this

meemalabs/meema-client-php

Add More Tests

#42
Merged glennmichael123 wants to merge add-more-tests into main
6 files +170 -26
tests/MeemaTagTest.phpadded+67-0
Changes to tests/MeemaTagTest.php
@@ -0,0 +1,67 @@
1<?php
2
3uses(Tests\ClientTest::class);
4
5beforeEach(function () {
6 $this->initializeDotEnv();
7 $this->initializeClient();
8});
9
10it('can fetch all tags', function () {
11 $tags = $this->client->tags()->get();
12
13 $this->assertTrue(is_array($tags));
14 $this->assertTrue(count($tags) > 0);
15});
16
17it('can fetch specific group of tags', function () {
18 $ids = [7, 8, 9];
19
20 $tags = $this->client->tags()->get($ids);
21
22 $this->assertTrue(is_array($tags));
23 $this->assertTrue(count($tags['data']) === count($ids));
24});
25
26it('can find a single tag', function () {
27 $id = 7;
28
29 $tags = $this->client->tags()->find($id)->toArray();
30
31 $this->assertTrue(is_array($tags));
32 $this->assertTrue(count($tags) === 1);
33});
34
35it('can update a tag', function () {
36 $color = 'purple-600';
37
38 $tags = $this->client->tags()->update(7, $color);
39
40 $this->assertTrue(is_array($tags));
41 $this->assertTrue($tags['data']['color'] === $color);
42});
43
44it('can delete a tag', function () {
45 $tags = $this->client->tags()->get();
46
47 $tags = array_reverse($tags['data']);
48 $response = $this->client->tags()->delete($tags[0]['id']);
49
50 $this->assertTrue(is_null($response));
51});
52
53it('can fetch all media tags', function () {
54 $media = $this->client->media()->find(1);
55 $tags = $media->tags()->get();
56
57 $this->assertTrue(is_array($tags));
58 $this->assertTrue(count($tags['data'][0]) > 0);
59});
60
61it('can fetch all folder tags', function () {
62 $folder = $this->client->folders()->find(1);
63 $tags = $folder->tags()->get();
64
65 $this->assertTrue(is_array($tags));
66 $this->assertTrue(count($tags['data'][0]) > 0);
67});