From 3d270091783b296a69407c9157197c123a977dc4 Mon Sep 17 00:00:00 2001 From: Dennis Eichhorn Date: Fri, 29 Oct 2021 14:49:55 +0200 Subject: [PATCH] bug and media fixes --- Admin/Install/Media.install.json | 1 + Models/Bill.php | 23 ++++++------ Models/BillElement.php | 14 ++++---- Models/NullBill.php | 2 +- tests/Bootstrap.php | 2 +- tests/Controller/ApiControllerTest.php | 9 +++-- tests/Models/BillElementTest.php | 27 +++++++------- tests/Models/BillTest.php | 48 ++++++++++++------------- tests/Models/BillTypeL11nTest.php | 10 +++--- tests/Models/PurchaseBillMapperTest.php | 5 ++- tests/Models/SalesBillMapperTest.php | 7 ++-- tests/Models/StockBillMapperTest.php | 3 +- 12 files changed, 73 insertions(+), 78 deletions(-) diff --git a/Admin/Install/Media.install.json b/Admin/Install/Media.install.json index 3fdc64d..0903c3b 100755 --- a/Admin/Install/Media.install.json +++ b/Admin/Install/Media.install.json @@ -26,6 +26,7 @@ "name": "Default", "virtualPath": "/Modules/Billing/Templates", "path": "/Modules/Media/Files/Modules/Billing/Templates/Default", + "fixed_names": true, "files": [ "/Modules/Billing/Admin/Install/Media" ], diff --git a/Models/Bill.php b/Models/Bill.php index 26f91cf..c231cec 100755 --- a/Models/Bill.php +++ b/Models/Bill.php @@ -18,7 +18,6 @@ use Modules\Admin\Models\Account; use Modules\Admin\Models\NullAccount; use Modules\ClientManagement\Models\Client; use Modules\Media\Models\Media; -use Modules\Media\Models\NullMedia; use Modules\SupplierManagement\Models\Supplier; use phpOMS\Localization\ISO4217CharEnum; use phpOMS\Localization\Money; @@ -628,20 +627,20 @@ class Bill implements \JsonSerializable public function toArray() : array { return [ - 'id' => $this->id, - 'number' => $this->number, - 'type' => $this->type, - 'shipTo' => $this->shipTo, - 'shipFAO' => $this->shipFAO, + 'id' => $this->id, + 'number' => $this->number, + 'type' => $this->type, + 'shipTo' => $this->shipTo, + 'shipFAO' => $this->shipFAO, 'shipAddress' => $this->shipAddress, - 'shipCity' => $this->shipCity, - 'shipZip' => $this->shipZip, + 'shipCity' => $this->shipCity, + 'shipZip' => $this->shipZip, 'shipCountry' => $this->shipCountry, - 'billTo' => $this->billTo, - 'billFAO' => $this->billFAO, + 'billTo' => $this->billTo, + 'billFAO' => $this->billFAO, 'billAddress' => $this->billAddress, - 'billCity' => $this->billCity, - 'billZip' => $this->billZip, + 'billCity' => $this->billCity, + 'billZip' => $this->billZip, 'billCountry' => $this->billCountry, ]; } diff --git a/Models/BillElement.php b/Models/BillElement.php index 0a8bf81..f3f12ce 100755 --- a/Models/BillElement.php +++ b/Models/BillElement.php @@ -139,14 +139,14 @@ class BillElement implements \JsonSerializable public function toArray() : array { return [ - 'id' => $this->id, - 'order' => $this->order, - 'item' => $this->item, - 'itemNumber' => $this->itemNumber, - 'itemName' => $this->itemName, + 'id' => $this->id, + 'order' => $this->order, + 'item' => $this->item, + 'itemNumber' => $this->itemNumber, + 'itemName' => $this->itemName, 'itemDescription' => $this->itemDescription, - 'quantity' => $this->quantity, - 'bill' => $this->bill, + 'quantity' => $this->quantity, + 'bill' => $this->bill, ]; } diff --git a/Models/NullBill.php b/Models/NullBill.php index 245111b..56f54d1 100755 --- a/Models/NullBill.php +++ b/Models/NullBill.php @@ -24,7 +24,7 @@ namespace Modules\Billing\Models; */ final class NullBill extends Bill { - /** + /** * Constructor * * @param int $id Model id diff --git a/tests/Bootstrap.php b/tests/Bootstrap.php index 051ac7e..f5fc99c 100755 --- a/tests/Bootstrap.php +++ b/tests/Bootstrap.php @@ -392,4 +392,4 @@ function phpServe() : void }); } -phpServe(); +\phpServe(); diff --git a/tests/Controller/ApiControllerTest.php b/tests/Controller/ApiControllerTest.php index 1181374..6d5ae38 100644 --- a/tests/Controller/ApiControllerTest.php +++ b/tests/Controller/ApiControllerTest.php @@ -16,22 +16,21 @@ namespace Modules\Billing\tests\Controller; use Model\CoreSettings; use Modules\Admin\Models\AccountPermission; -use Modules\Billing\Models\AuditMapper; use phpOMS\Account\Account; use phpOMS\Account\AccountManager; use phpOMS\Account\PermissionType; use phpOMS\Application\ApplicationAbstract; use phpOMS\Dispatcher\Dispatcher; use phpOMS\Event\EventManager; -use phpOMS\Module\ModuleAbstract; -use phpOMS\Module\ModuleManager; -use phpOMS\Router\WebRouter; -use phpOMS\Utils\TestUtils; use phpOMS\Message\Http\HttpRequest; use phpOMS\Message\Http\HttpResponse; use phpOMS\Message\Http\RequestStatusCode; +use phpOMS\Module\ModuleAbstract; +use phpOMS\Module\ModuleManager; +use phpOMS\Router\WebRouter; use phpOMS\Uri\HttpUri; use phpOMS\Utils\RnG\DateTime; +use phpOMS\Utils\TestUtils; /** * @testdox Modules\tests\Billing\Controller\ApiControllerTest: Billing api controller diff --git a/tests/Models/BillElementTest.php b/tests/Models/BillElementTest.php index 9520ccf..279907d 100644 --- a/tests/Models/BillElementTest.php +++ b/tests/Models/BillElementTest.php @@ -15,7 +15,6 @@ declare(strict_types=1); namespace Modules\Billing\tests\Models; use Modules\Billing\Models\BillElement; -use phpOMS\Localization\ISO4217CharEnum; /** * @internal @@ -61,24 +60,24 @@ final class BillElementTest extends \PHPUnit\Framework\TestCase */ public function testSerialize() : void { - $this->element->order = 2; - $this->element->item = 3; - $this->element->itemNumber = '123456'; - $this->element->itemName = 'Test'; + $this->element->order = 2; + $this->element->item = 3; + $this->element->itemNumber = '123456'; + $this->element->itemName = 'Test'; $this->element->itemDescription = 'Description'; - $this->element->quantity = 4; - $this->element->bill = 5; + $this->element->quantity = 4; + $this->element->bill = 5; self::assertEquals( [ - 'id' => 0, - 'order' => 2, - 'item' => 3, - 'itemNumber' => '123456', - 'itemName' => 'Test', + 'id' => 0, + 'order' => 2, + 'item' => 3, + 'itemNumber' => '123456', + 'itemName' => 'Test', 'itemDescription' => 'Description', - 'quantity' => 4, - 'bill' => 5, + 'quantity' => 4, + 'bill' => 5, ], $this->element->jsonSerialize() ); diff --git a/tests/Models/BillTest.php b/tests/Models/BillTest.php index f247612..34420e6 100644 --- a/tests/Models/BillTest.php +++ b/tests/Models/BillTest.php @@ -49,9 +49,9 @@ final class BillTest extends \PHPUnit\Framework\TestCase self::assertEquals(0, $this->bill->type); self::assertInstanceOf('\DateTimeImmutable', $this->bill->createdAt); self::assertInstanceOf('\DateTime', $this->bill->performanceDate); - self::assertEquals(null, $this->bill->send); - self::assertEquals(null, $this->bill->client); - self::assertEquals(null, $this->bill->supplier); + self::assertNull($this->bill->send); + self::assertNull($this->bill->client); + self::assertNull($this->bill->supplier); self::assertEquals([], $this->bill->getVouchers()); self::assertEquals([], $this->bill->getTrackings()); self::assertEquals([], $this->bill->getMediaByType(0)); @@ -170,37 +170,37 @@ final class BillTest extends \PHPUnit\Framework\TestCase */ public function testSerialize() : void { - $this->bill->number = '123456'; - $this->bill->type = 2; - $this->bill->shipTo = 'To'; - $this->bill->shipFAO = 'FAO'; + $this->bill->number = '123456'; + $this->bill->type = 2; + $this->bill->shipTo = 'To'; + $this->bill->shipFAO = 'FAO'; $this->bill->shipAddress = 'Address'; - $this->bill->shipCity = 'City'; - $this->bill->shipZip = 'Zip'; + $this->bill->shipCity = 'City'; + $this->bill->shipZip = 'Zip'; $this->bill->shipCountry = 'Country'; - $this->bill->billTo = 'To'; - $this->bill->billFAO = 'FAO'; + $this->bill->billTo = 'To'; + $this->bill->billFAO = 'FAO'; $this->bill->billAddress = 'Address'; - $this->bill->billCity = 'City'; - $this->bill->billZip = 'Zip'; + $this->bill->billCity = 'City'; + $this->bill->billZip = 'Zip'; $this->bill->billCountry = 'Country'; self::assertEquals( [ - 'id' => 0, - 'number' => '123456', - 'type' => 2, - 'shipTo' => 'To', - 'shipFAO' => 'FAO', + 'id' => 0, + 'number' => '123456', + 'type' => 2, + 'shipTo' => 'To', + 'shipFAO' => 'FAO', 'shipAddress' => 'Address', - 'shipCity' => 'City', - 'shipZip' => 'Zip', + 'shipCity' => 'City', + 'shipZip' => 'Zip', 'shipCountry' => 'Country', - 'billTo' => 'To', - 'billFAO' => 'FAO', + 'billTo' => 'To', + 'billFAO' => 'FAO', 'billAddress' => 'Address', - 'billCity' => 'City', - 'billZip' => 'Zip', + 'billCity' => 'City', + 'billZip' => 'Zip', 'billCountry' => 'Country', ], $this->bill->jsonSerialize() diff --git a/tests/Models/BillTypeL11nTest.php b/tests/Models/BillTypeL11nTest.php index 0f2131d..d308fc8 100644 --- a/tests/Models/BillTypeL11nTest.php +++ b/tests/Models/BillTypeL11nTest.php @@ -70,17 +70,17 @@ final class BillTypeL11nTest extends \PHPUnit\Framework\TestCase */ public function testSerialize() : void { - $this->l11n->name = 'Title'; + $this->l11n->name = 'Title'; $this->l11n->description = 'Description'; - $this->l11n->type = 2; + $this->l11n->type = 2; $this->l11n->setLanguage(ISO639x1Enum::_DE); self::assertEquals( [ - 'id' => 0, - 'name' => 'Title', + 'id' => 0, + 'name' => 'Title', 'type' => 2, - 'language' => ISO639x1Enum::_DE, + 'language' => ISO639x1Enum::_DE, ], $this->l11n->jsonSerialize() ); diff --git a/tests/Models/PurchaseBillMapperTest.php b/tests/Models/PurchaseBillMapperTest.php index c55f219..70ff8dd 100644 --- a/tests/Models/PurchaseBillMapperTest.php +++ b/tests/Models/PurchaseBillMapperTest.php @@ -15,7 +15,6 @@ declare(strict_types=1); namespace Modules\Billing\tests\Models; use Modules\Billing\Models\PurchaseBillMapper; -use phpOMS\Utils\TestUtils; /** * @testdox Modules\Billing\tests\Models\PurchaseBillMapperTest: App database mapper @@ -75,7 +74,7 @@ final class PurchaseBillMapperTest extends \PHPUnit\Framework\TestCase */ public function testGetLastOrderDateByItemIdInvalid() : void { - self::assertEquals(null, PurchaseBillMapper::getLastOrderDateByItemId(99999)); + self::assertNull(PurchaseBillMapper::getLastOrderDateByItemId(99999)); } /** @@ -84,7 +83,7 @@ final class PurchaseBillMapperTest extends \PHPUnit\Framework\TestCase */ public function testGetLastOrderDateBySupplierIdInvalid() : void { - self::assertEquals(null, PurchaseBillMapper::getLastOrderDateBySupplierId(99999)); + self::assertNull(PurchaseBillMapper::getLastOrderDateBySupplierId(99999)); } /** diff --git a/tests/Models/SalesBillMapperTest.php b/tests/Models/SalesBillMapperTest.php index 5eec0af..19a872d 100644 --- a/tests/Models/SalesBillMapperTest.php +++ b/tests/Models/SalesBillMapperTest.php @@ -15,7 +15,6 @@ declare(strict_types=1); namespace Modules\Billing\tests\Models; use Modules\Billing\Models\SalesBillMapper; -use phpOMS\Utils\TestUtils; /** * @testdox Modules\Billing\tests\Models\SalesBillMapperTest: App database mapper @@ -24,7 +23,7 @@ use phpOMS\Utils\TestUtils; */ final class SalesBillMapperTest extends \PHPUnit\Framework\TestCase { - /** + /** * @covers Modules\Billing\Models\SalesBillMapper * @group module */ @@ -75,7 +74,7 @@ final class SalesBillMapperTest extends \PHPUnit\Framework\TestCase */ public function testGetLastOrderDateByItemIdInvalid() : void { - self::assertEquals(null, SalesBillMapper::getLastOrderDateByItemId(99999)); + self::assertNull(SalesBillMapper::getLastOrderDateByItemId(99999)); } /** @@ -84,7 +83,7 @@ final class SalesBillMapperTest extends \PHPUnit\Framework\TestCase */ public function testGetLastOrderDateByClientIdInvalid() : void { - self::assertEquals(null, SalesBillMapper::getLastOrderDateByClientId(99999)); + self::assertNull(SalesBillMapper::getLastOrderDateByClientId(99999)); } /** diff --git a/tests/Models/StockBillMapperTest.php b/tests/Models/StockBillMapperTest.php index aacf9b4..c023315 100644 --- a/tests/Models/StockBillMapperTest.php +++ b/tests/Models/StockBillMapperTest.php @@ -15,7 +15,6 @@ declare(strict_types=1); namespace Modules\Billing\tests\Models; use Modules\Billing\Models\StockBillMapper; -use phpOMS\Utils\TestUtils; /** * @testdox Modules\Billing\tests\Models\StockBillMapperTest: App database mapper @@ -24,7 +23,7 @@ use phpOMS\Utils\TestUtils; */ final class StockBillMapperTest extends \PHPUnit\Framework\TestCase { - /** + /** * @covers Modules\Billing\Models\StockBillMapper * @group module */