-
-
Notifications
You must be signed in to change notification settings - Fork 1.1k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
8e1256c
commit 48f371a
Showing
10 changed files
with
174 additions
and
52 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
<?php | ||
|
||
namespace Spatie\MediaLibrary\MediaCollection; | ||
|
||
class MediaCollection | ||
{ | ||
/** @var string */ | ||
public $name = ''; | ||
|
||
/** @var string */ | ||
public $diskName = ''; | ||
|
||
public function __construct(string $name) | ||
{ | ||
$this->name = $name; | ||
} | ||
|
||
public static function create($name) | ||
{ | ||
return new static($name); | ||
} | ||
|
||
public function disk(string $diskName) | ||
{ | ||
$this->diskName = $diskName; | ||
|
||
return $this; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,67 @@ | ||
<?php | ||
|
||
namespace Spatie\MediaLibrary\Test\HasMediaConversionsTrait; | ||
|
||
use Spatie\MediaLibrary\HasMedia\Interfaces\HasMediaCollections; | ||
use Spatie\MediaLibrary\Media; | ||
use Spatie\MediaLibrary\Test\TestCase; | ||
use Spatie\MediaLibrary\Test\TestModelWithConversion; | ||
|
||
class MediaCollectionTest extends TestCase | ||
{ | ||
/** @test */ | ||
public function it_will_use_the_disk_from_a_media_collection() | ||
{ | ||
$testModel = new class extends TestModelWithConversion implements HasMediaCollections | ||
{ | ||
public function registerMediaConversions(Media $media = null) | ||
{ | ||
|
||
} | ||
|
||
public function registerMediaCollections() | ||
{ | ||
$this->addMediaCollection('images') | ||
->disk('secondMediaDisk'); | ||
} | ||
}; | ||
|
||
$model = $testModel::create(['name' => 'testmodel']); | ||
|
||
$media = $model->addMedia($this->getTestJpg())->preservingOriginal()->toMediaCollection('images'); | ||
|
||
$this->assertFileNotExists($this->getTempDirectory('media').'/'.$media->id.'/test.jpg'); | ||
|
||
$this->assertFileExists($this->getTempDirectory('media2').'/'.$media->id.'/test.jpg'); | ||
|
||
$media = $model->addMedia($this->getTestJpg())->toMediaCollection('other-images'); | ||
|
||
$this->assertFileExists($this->getTempDirectory('media').'/'.$media->id.'/test.jpg'); | ||
} | ||
|
||
/** @test */ | ||
public function it_will_not_use_the_disk_name_of_the_collection_if_a_diskname_is_specified_while_adding() | ||
{ | ||
$testModel = new class extends TestModelWithConversion implements HasMediaCollections | ||
{ | ||
public function registerMediaConversions(Media $media = null) | ||
{ | ||
|
||
} | ||
|
||
public function registerMediaCollections() | ||
{ | ||
$this->addMediaCollection('images') | ||
->disk('secondMediaDisk'); | ||
} | ||
}; | ||
|
||
$model = $testModel::create(['name' => 'testmodel']); | ||
|
||
$media = $model->addMedia($this->getTestJpg())->toMediaCollection('images', 'public'); | ||
|
||
$this->assertFileExists($this->getTempDirectory('media').'/'.$media->id.'/test.jpg'); | ||
|
||
$this->assertFileNotExists($this->getTempDirectory('media2').'/'.$media->id.'/test.jpg'); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.