mirror of
https://github.com/Karaka-Management/oms-Billing.git
synced 2026-02-02 01:38:41 +00:00
test fixes
This commit is contained in:
parent
b3006024c3
commit
0506ae8415
|
|
@ -604,21 +604,22 @@ class Bill implements \JsonSerializable
|
|||
/**
|
||||
* Get media file by type
|
||||
*
|
||||
* @param string $type Media type
|
||||
* @param null|int $type Media type
|
||||
*
|
||||
* @return Media
|
||||
* @return array
|
||||
*
|
||||
* @since 1.0.0
|
||||
*/
|
||||
public function getMediaByType(string $type) : Media
|
||||
public function getMediaByType(int $type = null) : array
|
||||
{
|
||||
foreach ($this->media as $media) {
|
||||
if ($media->type === $type) {
|
||||
return $media;
|
||||
$files = [];
|
||||
foreach ($this->media as $file) {
|
||||
if ($file->type === $type) {
|
||||
$files[] = $file;
|
||||
}
|
||||
}
|
||||
|
||||
return new NullMedia();
|
||||
return $files;
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
|||
|
|
@ -18,6 +18,7 @@ use Modules\Billing\Models\Bill;
|
|||
use Modules\Billing\Models\BillElement;
|
||||
use Modules\Billing\Models\BillStatus;
|
||||
use Modules\Billing\Models\BillType;
|
||||
use Modules\Media\Models\Media;
|
||||
use phpOMS\Localization\ISO4217CharEnum;
|
||||
|
||||
/**
|
||||
|
|
@ -53,6 +54,7 @@ final class BillTest extends \PHPUnit\Framework\TestCase
|
|||
self::assertEquals(null, $this->bill->supplier);
|
||||
self::assertEquals([], $this->bill->getVouchers());
|
||||
self::assertEquals([], $this->bill->getTrackings());
|
||||
self::assertEquals([], $this->bill->getMediaByType(0));
|
||||
|
||||
self::assertEquals('', $this->bill->shipTo);
|
||||
self::assertEquals('', $this->bill->shipFAO);
|
||||
|
|
@ -121,6 +123,17 @@ final class BillTest extends \PHPUnit\Framework\TestCase
|
|||
self::assertEquals(ISO4217CharEnum::_USD, $this->bill->getCurrency());
|
||||
}
|
||||
|
||||
/**
|
||||
* @covers Modules\Billing\Models\Bill
|
||||
* @group module
|
||||
*/
|
||||
public function testMediaInputOutput() : void
|
||||
{
|
||||
$this->bill->addMedia($temp = new Media());
|
||||
self::assertCount(1, $this->bill->getMedia());
|
||||
self::assertEquals([$temp], $this->bill->getMediaByType());
|
||||
}
|
||||
|
||||
/**
|
||||
* @covers Modules\Billing\Models\Bill
|
||||
* @group module
|
||||
|
|
|
|||
Loading…
Reference in New Issue
Block a user