-
-
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
a1ab078
commit 0f3bfe2
Showing
2 changed files
with
55 additions
and
1 deletion.
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,46 @@ | ||
<?php | ||
|
||
it('returns zero for an empty collection', function () { | ||
expect($this->testModel->countMedia())->toEqual(0); | ||
}); | ||
|
||
it('returns count for a non empty collection', function () { | ||
$this->testModel->addMedia($this->getTestJpg())->toMediaCollection(); | ||
$this->testModel->addMedia($this->getTestPng())->toMediaCollection(); | ||
|
||
expect($this->testModel->countMedia())->toEqual(2); | ||
}); | ||
|
||
it('returns count for a non empty collection in an unsaved model', function () { | ||
$this->testUnsavedModel->addMedia($this->getTestJpg())->toMediaCollection(); | ||
|
||
expect($this->testUnsavedModel->countMedia())->toEqual(1); | ||
}); | ||
|
||
it('returns count if any collection is not empty', function () { | ||
$this->testModel->addMedia($this->getTestJpg())->toMediaCollection('images'); | ||
|
||
expect($this->testModel->countMedia('images'))->toEqual(1); | ||
}); | ||
|
||
it('returns zero for an empty named collection', function () { | ||
expect($this->testModel->countMedia('images'))->toEqual(0); | ||
}); | ||
|
||
it('returns count for a non empty named collection', function () { | ||
$this->testModel->addMedia($this->getTestJpg())->toMediaCollection('images'); | ||
|
||
expect($this->testModel->countMedia('images'))->toEqual(1); | ||
expect($this->testModel->countMedia('downloads'))->toEqual(0); | ||
}); | ||
|
||
it('returns count for a filtered collection', function () { | ||
$this->testModel | ||
->addMedia($this->getTestJpg()) | ||
->withCustomProperties(['test' => true]) | ||
->toMediaCollection(); | ||
|
||
expect($this->testModel->countMedia('default'))->toEqual(1); | ||
expect($this->testModel->countMedia('default', ['test' => true]))->toEqual(1); | ||
expect($this->testModel->countMedia('default', ['test' => false]))->toEqual(0); | ||
}); |