diff --git a/composer.json b/composer.json index 29dc818..1e15707 100644 --- a/composer.json +++ b/composer.json @@ -18,14 +18,15 @@ ], "require": { "php": "^7.4|^8.0", - "silvanite/nova-field-cloudinary": "^1.3", + "cloudinary/cloudinary_php": "^1.20.0", + "silvanite/nova-field-cloudinary": "^1.3.2", "spatie/eloquent-sortable": "^3.11.0", "tipoff/authorization": "^2.5.1", "tipoff/laravel-google-api": "^1.3.1", "tipoff/support": "^1.6.0" }, "require-dev": { - "php-mock/php-mock-phpunit": "^2.6", + "php-mock/php-mock-mockery": "^1.3", "tipoff/test-support": "^1.2.0" }, "autoload": { diff --git a/tests/Feature/Nova/ImageResourceTest.php b/tests/Feature/Nova/ImageResourceTest.php index 695429e..ece4469 100644 --- a/tests/Feature/Nova/ImageResourceTest.php +++ b/tests/Feature/Nova/ImageResourceTest.php @@ -8,6 +8,7 @@ use DrewRoberts\Media\Tests\TestCase; use Illuminate\Foundation\Testing\DatabaseTransactions; use Illuminate\Foundation\Testing\RefreshDatabase; +use Illuminate\Support\Facades\Config; class ImageResourceTest extends TestCase { @@ -17,6 +18,15 @@ class ImageResourceTest extends TestCase /** @test */ public function index() { + Config::set('app.key', 'base64:CA0WFs+ECA4gq/G95GpRwEaYsoNdUF0cAziYkc83ISE='); + + Config::set('filesystems.disks.cloudinary', [ + 'driver' => 'cloudinary', + 'api_key' => env('CLOUDINARY_API_KEY', 'nonsense'), + 'api_secret' => env('CLOUDINARY_API_SECRET', 'nonsense'), + 'cloud_name' => env('CLOUDINARY_CLOUD_NAME', 'nonsense'), + ]); + Image::factory()->count(1)->create(); $this->actingAs(self::createPermissionedUser('view images', true)); diff --git a/tests/Feature/Nova/TagResourceTest.php b/tests/Feature/Nova/TagResourceTest.php index 3fb4f79..af1b46e 100644 --- a/tests/Feature/Nova/TagResourceTest.php +++ b/tests/Feature/Nova/TagResourceTest.php @@ -8,6 +8,7 @@ use DrewRoberts\Media\Tests\TestCase; use Illuminate\Foundation\Testing\DatabaseTransactions; use Illuminate\Foundation\Testing\RefreshDatabase; +use Illuminate\Support\Facades\Config; class TagResourceTest extends TestCase { @@ -17,6 +18,8 @@ class TagResourceTest extends TestCase /** @test */ public function index() { + Config::set('app.key', 'base64:CA0WFs+ECA4gq/G95GpRwEaYsoNdUF0cAziYkc83ISE='); + Tag::factory()->count(1)->create(); $this->actingAs(self::createPermissionedUser('view tags', true)); diff --git a/tests/Feature/Nova/VideoResourceTest.php b/tests/Feature/Nova/VideoResourceTest.php index 5fb5588..aea499d 100644 --- a/tests/Feature/Nova/VideoResourceTest.php +++ b/tests/Feature/Nova/VideoResourceTest.php @@ -8,6 +8,7 @@ use DrewRoberts\Media\Tests\TestCase; use Illuminate\Foundation\Testing\DatabaseTransactions; use Illuminate\Foundation\Testing\RefreshDatabase; +use Illuminate\Support\Facades\Config; class VideoResourceTest extends TestCase { @@ -17,6 +18,8 @@ class VideoResourceTest extends TestCase /** @test */ public function index() { + Config::set('app.key', 'base64:CA0WFs+ECA4gq/G95GpRwEaYsoNdUF0cAziYkc83ISE='); + Video::factory()->count(1)->create(); $this->actingAs(self::createPermissionedUser('view videos', true)); diff --git a/tests/TestCase.php b/tests/TestCase.php index fb2dde1..e320152 100644 --- a/tests/TestCase.php +++ b/tests/TestCase.php @@ -7,6 +7,7 @@ use DrewRoberts\Media\MediaServiceProvider; use DrewRoberts\Media\Tests\Support\Providers\NovaPackageServiceProvider; use Laravel\Nova\NovaCoreServiceProvider; +use Silvanite\NovaFieldCloudinary\Providers\PackageServiceProvider; use Spatie\Permission\PermissionServiceProvider; use Tipoff\Authorization\AuthorizationServiceProvider; use Tipoff\Support\SupportServiceProvider; @@ -23,6 +24,7 @@ protected function getPackageProviders($app) MediaServiceProvider::class, NovaCoreServiceProvider::class, NovaPackageServiceProvider::class, + PackageServiceProvider::class, ]; } } diff --git a/tests/Unit/Models/ImageTest.php b/tests/Unit/Models/ImageTest.php index 0282fa9..4147f2b 100644 --- a/tests/Unit/Models/ImageTest.php +++ b/tests/Unit/Models/ImageTest.php @@ -4,17 +4,17 @@ use DrewRoberts\Media\Models\Image; use DrewRoberts\Media\Models\Video; -use DrewRoberts\Media\Tests\Support\Models\User; use DrewRoberts\Media\Tests\TestCase; use Illuminate\Database\Eloquent\Collection; use Illuminate\Foundation\Testing\RefreshDatabase; use Illuminate\Foundation\Testing\WithFaker; -use phpmock\phpunit\PHPMock; +use Mockery; +use phpmock\mockery\PHPMockery; +use Tipoff\Authorization\Models\User; class ImageTest extends TestCase { use RefreshDatabase, - PHPMock, WithFaker; /** @test */ @@ -99,21 +99,20 @@ public function it_has_an_url() /** @test */ public function it_determines_the_dimensions_if_empty() { + PHPMockery::mock('DrewRoberts\Media\Models', 'getimagesize')->andReturn([24, 60]); + $image = Image::factory()->make([ 'filename' => 'test.jpg', 'width' => null, 'height' => null, ]); - $this->getFunctionMock('DrewRoberts\Media\Models', 'getimagesize') - ->expects($this->once()) - ->with($image->url) - ->willReturn([24, 60]); - $image->save(); $this->assertEquals(24, $image->width); $this->assertEquals(60, $image->height); + + Mockery::close(); } /** @test */ diff --git a/tests/Unit/Models/TagTest.php b/tests/Unit/Models/TagTest.php index 4e887cc..8b94e2d 100644 --- a/tests/Unit/Models/TagTest.php +++ b/tests/Unit/Models/TagTest.php @@ -3,10 +3,10 @@ namespace DrewRoberts\Media\Tests\Unit\Models; use DrewRoberts\Media\Models\Tag; -use DrewRoberts\Media\Tests\Support\Models\User; use DrewRoberts\Media\Tests\TestCase; use Illuminate\Foundation\Testing\RefreshDatabase; use Illuminate\Foundation\Testing\WithFaker; +use Tipoff\Authorization\Models\User; class TagTest extends TestCase { diff --git a/tests/Unit/Models/VideoTest.php b/tests/Unit/Models/VideoTest.php index 75fb52a..5ebc2f2 100644 --- a/tests/Unit/Models/VideoTest.php +++ b/tests/Unit/Models/VideoTest.php @@ -4,12 +4,12 @@ use DrewRoberts\Media\Models\Image; use DrewRoberts\Media\Models\Video; -use DrewRoberts\Media\Tests\Support\Models\User; use DrewRoberts\Media\Tests\TestCase; use Exception; use Illuminate\Foundation\Testing\RefreshDatabase; use Illuminate\Foundation\Testing\WithFaker; use Illuminate\Support\Carbon; +use Tipoff\Authorization\Models\User; class VideoTest extends TestCase {