ReviewOS

also looking at this

meemalabs/laravel-meema

Collection Response

#5
Merged glennmichael123 wants to merge collection-response into main
7 files +42 -51
config/config.phpmodified+5-0
Changes to config/config.php
@@ -5,4 +5,9 @@ return [
55 * The publishable API key provided by the meema API
66 */
77 'api_key' => env('MEEMA_API_KEY', ''),
8
9 /*
10 * If you want to convert all response to a collection
11 */
12 'to_collection' => env('MEEMA_API_TO_COLLECTION', true),
813];
src/MeemaFacade.phpdeleted+0-21
Changes to src/MeemaFacade.php
@@ -1,21 +0,0 @@
1<?php
2
3namespace Meema\LaravelMeema;
4
5use Illuminate\Support\Facades\Facade;
6
7/**
8 * @see \Meema\LaravelMeema\MeemaClass
9 */
10class MeemaFacade extends Facade
11{
12 /**
13 * Get the registered name of the component.
14 *
15 * @return string
16 */
17 protected static function getFacadeAccessor()
18 {
19 return 'meema';
20 }
21}
src/Providers/MeemaServiceProvider.phpmodified+4-1
Changes to src/Providers/MeemaServiceProvider.php
@@ -53,7 +53,10 @@ class MeemaServiceProvider extends ServiceProvider
5353 protected function registerMeemaClient()
5454 {
5555 $this->app->singleton('meema', function ($app) {
56 $config = ['base_url' => config('meema.meema_test_url')];
56 $config = [
57 'base_url' => config('meema.meema_test_url'),
58 'to_collection' => config('meema.to_collection'),
59 ];
5760
5861 return new Client(config('meema.api_key'), $config);
5962 });
tests/FavoriteTest.phpmodified+6-5
Changes to tests/FavoriteTest.php
@@ -1,5 +1,6 @@
11<?php
22
3use Illuminate\Support\Collection;
34use Meema\LaravelMeema\Facades\Favorite;
45use Meema\LaravelMeema\Tests\LaravelMeemaTestCase;
56
@@ -13,8 +14,8 @@ beforeEach(function () {
1314it('can fetch all favorites', function () {
1415 $favorites = Favorite::get();
1516
16 $this->assertTrue(is_array($favorites));
17 $this->assertTrue(count($favorites) > 0);
17 $this->assertTrue($favorites instanceof Collection);
18 $this->assertTrue($favorites->count() > 0);
1819});
1920
2021it('can fetch specific group of favorites', function () {
@@ -22,8 +23,8 @@ it('can fetch specific group of favorites', function () {
2223
2324 $favorites = Favorite::get($ids);
2425
25 $this->assertTrue(is_array($favorites));
26 $this->assertTrue(count($favorites) === count($ids));
26 $this->assertTrue($favorites instanceof Collection);
27 $this->assertTrue($favorites->count() === count($ids));
2728});
2829
2930it('can find a single favorite', function () {
@@ -54,7 +55,7 @@ it('can update a favorite', function () {
5455});
5556
5657it('can delete a favorite', function () {
57 $favorites = Favorite::get();
58 $favorites = Favorite::get()->toArray();
5859
5960 $favorites = array_reverse($favorites);
6061 $response = Favorite::delete($favorites[0]['id']);
tests/FolderTest.phpmodified+7-6
Changes to tests/FolderTest.php
@@ -1,5 +1,6 @@
11<?php
22
3use Illuminate\Support\Collection;
34use Meema\LaravelMeema\Facades\Folder;
45use Meema\LaravelMeema\Tests\LaravelMeemaTestCase;
56
@@ -13,8 +14,8 @@ beforeEach(function () {
1314it('can fetch all folders', function () {
1415 $folders = Folder::get();
1516
16 $this->assertTrue(is_array($folders));
17 $this->assertTrue(count($folders) > 0);
17 $this->assertTrue($folders instanceof Collection);
18 $this->assertTrue($folders->count() > 0);
1819});
1920
2021it('can search a folder', function () {
@@ -24,7 +25,7 @@ it('can search a folder', function () {
2425
2526 $folders = Folder::search($query);
2627
27 $this->assertTrue(is_array($folders));
28 $this->assertTrue($folders instanceof Collection);
2829 $this->assertTrue(str_contains($folders[0]['name'], $query));
2930});
3031
@@ -33,8 +34,8 @@ it('can fetch specific group of folders', function () {
3334
3435 $folders = Folder::get($ids);
3536
36 $this->assertTrue(is_array($folders));
37 $this->assertTrue(count($folders) === count($ids));
37 $this->assertTrue($folders instanceof Collection);
38 $this->assertTrue($folders->count() === count($ids));
3839});
3940
4041it('can find a single folder', function () {
@@ -88,7 +89,7 @@ it('can duplicate a folder', function () {
8889});
8990
9091it('can delete a folder', function () {
91 $folders = Folder::get();
92 $folders = Folder::get()->toArray();
9293
9394 $folders = array_reverse($folders);
9495 $response = Folder::delete($folders[0]['id']);
tests/MediaTest.phpmodified+11-10
Changes to tests/MediaTest.php
@@ -1,5 +1,6 @@
11<?php
22
3use Illuminate\Support\Collection;
34use Meema\LaravelMeema\Facades\Folder;
45use Meema\LaravelMeema\Facades\Media;
56use Meema\LaravelMeema\Facades\Tag;
@@ -15,8 +16,8 @@ beforeEach(function () {
1516it('can be fetch all media', function () {
1617 $media = Media::get();
1718
18 $this->assertTrue(is_array($media));
19 $this->assertTrue(count($media) > 0);
19 $this->assertTrue($media instanceof Collection);
20 $this->assertTrue($media->count() > 0);
2021});
2122
2223it('can search a media', function () {
@@ -25,7 +26,7 @@ it('can search a media', function () {
2526
2627 $media = Media::search($query);
2728
28 $this->assertTrue(is_array($media));
29 $this->assertTrue($media instanceof Collection);
2930 $this->assertTrue(str_contains($media[0]['name'], $query));
3031});
3132
@@ -35,8 +36,8 @@ it('can be fetch all media for a tag', function () {
3536
3637 $media = $tag->media()->get();
3738
38 $this->assertTrue(is_array($media));
39 $this->assertTrue(count($media) > 0);
39 $this->assertTrue($media instanceof Collection);
40 $this->assertTrue($media->count() > 0);
4041});
4142
4243it('can be fetch all media for a folder', function () {
@@ -45,8 +46,8 @@ it('can be fetch all media for a folder', function () {
4546
4647 $media = $folder->media()->get();
4748
48 $this->assertTrue(is_array($media));
49 $this->assertTrue(count($media) > 0);
49 $this->assertTrue($media instanceof Collection);
50 $this->assertTrue($media->count() > 0);
5051});
5152
5253it('can be fetch specific group of media', function () {
@@ -54,8 +55,8 @@ it('can be fetch specific group of media', function () {
5455
5556 $media = Media::get($ids);
5657
57 $this->assertTrue(is_array($media));
58 $this->assertTrue(count($media) === count($ids));
58 $this->assertTrue($media instanceof Collection);
59 $this->assertTrue($media->count() === count($ids));
5960});
6061
6162it('can find a single media', function () {
@@ -114,7 +115,7 @@ it('can duplicate a media', function () {
114115});
115116
116117it('can delete a media', function () {
117 $media = Media::get();
118 $media = Media::get()->toArray();
118119
119120 $media = array_reverse($media);
120121 $response = Media::delete((int) $media[0]['media_id']);
tests/TagTest.phpmodified+9-8
Changes to tests/TagTest.php
@@ -1,5 +1,6 @@
11<?php
22
3use Illuminate\Support\Collection;
34use Meema\LaravelMeema\Facades\Folder;
45use Meema\LaravelMeema\Facades\Media;
56use Meema\LaravelMeema\Facades\Tag;
@@ -15,8 +16,8 @@ beforeEach(function () {
1516it('can fetch all tags', function () {
1617 $tags = Tag::get();
1718
18 $this->assertTrue(is_array($tags));
19 $this->assertTrue(count($tags) > 0);
19 $this->assertTrue($tags instanceof Collection);
20 $this->assertTrue($tags->count() > 0);
2021});
2122
2223it('can fetch specific group of tags', function () {
@@ -24,8 +25,8 @@ it('can fetch specific group of tags', function () {
2425
2526 $tags = Tag::get($ids);
2627
27 $this->assertTrue(is_array($tags));
28 $this->assertTrue(count($tags) === count($ids));
28 $this->assertTrue($tags instanceof Collection);
29 $this->assertTrue($tags->count() === count($ids));
2930});
3031
3132it('can find a single tag', function () {
@@ -50,8 +51,8 @@ it('can fetch all media tags', function () {
5051 $media = Media::find(1);
5152 $tags = $media->tags()->get();
5253
53 $this->assertTrue(is_array($tags));
54 $this->assertTrue(count($tags[0]) > 0);
54 $this->assertTrue($tags instanceof Collection);
55 $this->assertTrue($tags->count() >= 0);
5556});
5657
5758it('can fetch all folder tags', function () {
@@ -59,12 +60,12 @@ it('can fetch all folder tags', function () {
5960
6061 $tags = $folder->tags()->get();
6162
62 $this->assertTrue(is_array($tags));
63 $this->assertTrue($tags instanceof Collection);
6364 $this->assertTrue(count($tags[0]) > 0);
6465});
6566
6667it('can delete a tag', function () {
67 $tags = Tag::get();
68 $tags = Tag::get()->toArray();
6869
6970 $tags = array_reverse($tags);
7071 $response = Tag::delete($tags[0]['id']);