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/MeemaFavoriteTest.phpadded+60-0
Changes to tests/MeemaFavoriteTest.php
@@ -0,0 +1,60 @@
1<?php
2
3uses(Tests\ClientTest::class);
4
5beforeEach(function () {
6 $this->initializeDotEnv();
7 $this->initializeClient();
8});
9
10it('can fetch all favorites', function () {
11 $favorites = $this->client->favorites()->get();
12
13 $this->assertTrue(is_array($favorites));
14 $this->assertTrue(count($favorites) > 0);
15});
16
17it('can fetch specific group of favorites', function () {
18 $ids = [7, 8, 9];
19
20 $favorites = $this->client->favorites()->get($ids);
21
22 $this->assertTrue(is_array($favorites));
23 $this->assertTrue(count($favorites['data']) === count($ids));
24});
25
26it('can find a single favorite', function () {
27 $id = 7;
28
29 $favorites = $this->client->favorites()->find($id)->toArray();
30
31 $this->assertTrue(is_array($favorites));
32 $this->assertTrue(count($favorites) === 1);
33});
34
35it('can create a favorite', function () {
36 $data = ['name' => 'test favorite', 'icon' => 'house'];
37
38 $favorite = $this->client->favorites()->create($data);
39
40 $this->assertTrue(is_array($favorite));
41 $this->assertTrue($favorite['data']['name'] === $data['name']);
42});
43
44it('can update a favorite', function () {
45 $data = ['name' => 'test favorite update', 'icon' => 'home'];
46
47 $favorites = $this->client->favorites()->update(7, $data);
48
49 $this->assertTrue(is_array($favorites));
50 $this->assertTrue($favorites['data']['name'] === $data['name']);
51});
52
53it('can delete a favorite', function () {
54 $favorites = $this->client->tags()->get();
55
56 $favorites = array_reverse($favorites['data']);
57 $response = $this->client->tags()->delete($favorites[0]['id']);
58
59 $this->assertTrue(is_null($response));
60});