diff --git a/Admin/Install/db.json b/Admin/Install/db.json index 3285f7b..c723fa6 100755 --- a/Admin/Install/db.json +++ b/Admin/Install/db.json @@ -225,7 +225,7 @@ }, "billing_bill_currency": { "name": "billing_bill_currency", - "type": "INT", + "type": "VARCHAR(3)", "null": false }, "billing_bill_referral": { diff --git a/Controller/ApiController.php b/Controller/ApiController.php index d33b8f6..9880de9 100755 --- a/Controller/ApiController.php +++ b/Controller/ApiController.php @@ -120,15 +120,10 @@ final class ApiController extends Controller private function validateBillCreate(RequestAbstract $request) : array { $val = []; - /*if (($val['title'] = empty($request->getData('title'))) - || ($val['plain'] = empty($request->getData('plain'))) - || ($val['status'] = ( - $request->getData('status') !== null - && !WikiStatus::isValidValue((int) $request->getData('status')) - )) + if (($val['client/customer'] = empty($request->getData('client') && empty($request->getData('supplier')))) ) { return $val; - }*/ + } return []; } @@ -292,6 +287,12 @@ final class ApiController extends Controller $pdf = $view->build(); + if (!\is_file($pdfDir . $request->getData('bill') . '.pdf')) { + $response->header->status = RequestStatusCode::R_400; + + return; + } + $media = $this->app->moduleManager->get('Media')->createDbEntry( [ 'status' => UploadStatus::OK, @@ -315,6 +316,8 @@ final class ApiController extends Controller $media->getId(), BillMapper::class, 'media', '', $request->getOrigin() ); + + $this->fillJsonResponse($request, $response, NotificationLevel::OK, 'PDF', 'Bill Pdf successfully created.', $media); } /** diff --git a/Controller/BackendController.php b/Controller/BackendController.php index 0efce49..792711a 100755 --- a/Controller/BackendController.php +++ b/Controller/BackendController.php @@ -121,6 +121,48 @@ final class BackendController extends Controller return $view; } + /** + * Routing end-point for application behaviour. + * + * @param RequestAbstract $request Request + * @param ResponseAbstract $response Response + * @param mixed $data Generic data + * + * @return RenderableInterface + * + * @since 1.0.0 + * @codeCoverageIgnore + */ + public function viewBillingPurchaseInvoiceCreate(RequestAbstract $request, ResponseAbstract $response, $data = null) : RenderableInterface + { + $view = new View($this->app->l11nManager, $request, $response); + $view->setTemplate('/Modules/Billing/Theme/Backend/invoice-create'); + $view->addData('nav', $this->app->moduleManager->get('Navigation')->createNavigationMid(1005104001, $request, $response)); + + return $view; + } + + /** + * Routing end-point for application behaviour. + * + * @param RequestAbstract $request Request + * @param ResponseAbstract $response Response + * @param mixed $data Generic data + * + * @return RenderableInterface + * + * @since 1.0.0 + * @codeCoverageIgnore + */ + public function viewBillingStockInvoiceCreate(RequestAbstract $request, ResponseAbstract $response, $data = null) : RenderableInterface + { + $view = new View($this->app->l11nManager, $request, $response); + $view->setTemplate('/Modules/Billing/Theme/Backend/invoice-create'); + $view->addData('nav', $this->app->moduleManager->get('Navigation')->createNavigationMid(1005104001, $request, $response)); + + return $view; + } + /** * Routing end-point for application behaviour. * diff --git a/Models/Bill.php b/Models/Bill.php index c7ed4ca..6e74dab 100755 --- a/Models/Bill.php +++ b/Models/Bill.php @@ -87,7 +87,7 @@ class Bill implements \JsonSerializable * @var null|\DateTime * @since 1.0.0 */ - private ?\DateTime $send = null; + public ?\DateTime $send = null; /** * Creator. @@ -419,20 +419,6 @@ class Bill implements \JsonSerializable ); } - /** - * Set Bill number. - * - * @param string $number Bill number - * - * @return void - * - * @since 1.0.0 - */ - public function setNumber(string $number) : void - { - $this->number = $number; - } - /** * Get type * @@ -485,394 +471,6 @@ class Bill implements \JsonSerializable $this->status = $status; } - /** - * Set shipping date. - * - * @param \DateTime $send Shipping date - * - * @return void - * - * @since 1.0.0 - */ - public function setSend(\DateTime $send) : void - { - $this->send = $send; - } - - /** - * Get shipping date. - * - * @return null|\DateTime - * - * @since 1.0.0 - */ - public function getSend() : ?\DateTime - { - return $this->send; - } - - /** - * Get client. - * - * @return mixed - * - * @since 1.0.0 - */ - public function getClient() - { - return $this->client; - } - - /** - * Set client. - * - * @param mixed $client client - * - * @return void - * - * @since 1.0.0 - */ - public function setClient($client) : void - { - $this->client = $client; - } - - /** - * Set shipping receiver. - * - * @param string $ship Shipping receiver - * - * @return void - * - * @since 1.0.0 - */ - public function setShipTo(string $ship) : void - { - $this->shipTo = $ship; - } - - /** - * Get shipping receiver. - * - * @return string - * - * @since 1.0.0 - */ - public function getShipTo() : string - { - return $this->shipTo; - } - - /** - * Set shipping fao. - * - * @param string $ship FAO - * - * @return void - * - * @since 1.0.0 - */ - public function setShipFAO(string $ship) : void - { - $this->shipFAO = $ship; - } - - /** - * Get shipping fao. - * - * @return string - * - * @since 1.0.0 - */ - public function getShipFAO() : string - { - return $this->shipFAO; - } - - /** - * Set shipping address. - * - * @param string $ship Shipping address - * - * @return void - * - * @since 1.0.0 - */ - public function setShipAddress(string $ship) : void - { - $this->shipAddress = $ship; - } - - /** - * Get shipping address. - * - * @return string - * - * @since 1.0.0 - */ - public function getShipAddress() : string - { - return $this->shipAddress; - } - - /** - * Set shipping city. - * - * @param string $ship City - * - * @return void - * - * @since 1.0.0 - */ - public function setShipCity(string $ship) : void - { - $this->shipCity = $ship; - } - - /** - * Get shipping city. - * - * @return string - * - * @since 1.0.0 - */ - public function getShipCity() : string - { - return $this->shipCity; - } - - /** - * Set shipping zip. - * - * @param string $ship Zip - * - * @return void - * - * @since 1.0.0 - */ - public function setShipZip(string $ship) : void - { - $this->shipZip = $ship; - } - - /** - * Get shipping zip. - * - * @return string - * - * @since 1.0.0 - */ - public function getShipZip() : string - { - return $this->shipZip; - } - - /** - * Set shipping country. - * - * @param string $ship Country - * - * @return void - * - * @since 1.0.0 - */ - public function setShipCountry(string $ship) : void - { - $this->shipCountry = $ship; - } - - /** - * Get shipping country. - * - * @return string - * - * @since 1.0.0 - */ - public function getShipCountry() : string - { - return $this->shipCountry; - } - - /** - * Set billing receiver. - * - * @param string $bill Billing receiver - * - * @return void - * - * @since 1.0.0 - */ - public function setBillTo(string $bill) : void - { - $this->billTo = $bill; - } - - /** - * Get billing receiver. - * - * @return string - * - * @since 1.0.0 - */ - public function getBillTo() : string - { - return $this->billTo; - } - - /** - * Set billing fao. - * - * @param string $bill FAO - * - * @return void - * - * @since 1.0.0 - */ - public function setBillFAO(string $bill) : void - { - $this->billFAO = $bill; - } - - /** - * Get billing fao. - * - * @return string - * - * @since 1.0.0 - */ - public function getBillFAO() : string - { - return $this->billFAO; - } - - /** - * Set billing address. - * - * @param string $bill Billing address - * - * @return void - * - * @since 1.0.0 - */ - public function setBillAddress(string $bill) : void - { - $this->billAddress = $bill; - } - - /** - * Get billing address. - * - * @return string - * - * @since 1.0.0 - */ - public function getBillAddress() : string - { - return $this->billAddress; - } - - /** - * Set billing city. - * - * @param string $bill City - * - * @return void - * - * @since 1.0.0 - */ - public function setBillCity(string $bill) : void - { - $this->billCity = $bill; - } - - /** - * Get billing city. - * - * @return string - * - * @since 1.0.0 - */ - public function getBillCity() : string - { - return $this->billCity; - } - - /** - * Set billing zip. - * - * @param string $bill Zip - * - * @return void - * - * @since 1.0.0 - */ - public function setBillZip(string $bill) : void - { - $this->billZip = $bill; - } - - /** - * Get billing zip. - * - * @return string - * - * @since 1.0.0 - */ - public function getBillZip() : string - { - return $this->billZip; - } - - /** - * Set billing country. - * - * @param string $bill Country - * - * @return void - * - * @since 1.0.0 - */ - public function setBillCountry(string $bill) : void - { - $this->billCountry = $bill; - } - - /** - * Get billing country. - * - * @return string - * - * @since 1.0.0 - */ - public function getBillCountry() : string - { - return $this->billCountry; - } - - /** - * Get net amount. - * - * @return Money - * - * @since 1.0.0 - */ - public function getNet() : Money - { - return $this->net; - } - - /** - * Get gross amount. - * - * @return Money - * - * @since 1.0.0 - */ - public function getGross() : Money - { - return $this->gross; - } - /** * Set currency. * @@ -899,162 +497,6 @@ class Bill implements \JsonSerializable return $this->currency; } - /** - * Set info. - * - * @param string $info Info - * - * @return void - * - * @since 1.0.0 - */ - public function setInfo(string $info) : void - { - $this->info = $info; - } - - /** - * Get info. - * - * @return string - * - * @since 1.0.0 - */ - public function getInfo() : string - { - return $this->info; - } - - /** - * Set payment text. - * - * @param string $payment Payment text - * - * @return void - * - * @since 1.0.0 - */ - public function setPaymentText(string $payment) : void - { - $this->paymentText = $payment; - } - - /** - * Get payment text. - * - * @return string - * - * @since 1.0.0 - */ - public function getPaymentText() : string - { - return $this->paymentText; - } - - /** - * Set shipping terms (e.g. inco). - * - * @param int $terms Terms - * - * @return void - * - * @since 1.0.0 - */ - public function setTerms(int $terms) : void - { - $this->terms = $terms; - } - - /** - * Get terms. - * - * @return int - * - * @since 1.0.0 - */ - public function getTerms() : ?int - { - return $this->terms; - } - - /** - * Set terms text. - * - * @param string $terms Terms text - * - * @return void - * - * @since 1.0.0 - */ - public function setTermsText(string $terms) : void - { - $this->termsText = $terms; - } - - /** - * Get terms text. - * - * @return string - * - * @since 1.0.0 - */ - public function getTermsText() : string - { - return $this->termsText; - } - - /** - * Set shipping. - * - * @param int $shipping Shipping (e.g. incoterm) - * - * @return void - * - * @since 1.0.0 - */ - public function setShipping(int $shipping) : void - { - $this->shipping = $shipping; - } - - /** - * Get shipping. - * - * @return int - * - * @since 1.0.0 - */ - public function getShipping() : ?int - { - return $this->shipping; - } - - /** - * Set shipping text. - * - * @param string $shipping Shipping text - * - * @return void - * - * @since 1.0.0 - */ - public function setShippingText(string $shipping) : void - { - $this->shippingText = $shipping; - } - - /** - * Get shipping text. - * - * @return string - * - * @since 1.0.0 - */ - public function getShippingText() : string - { - return $this->shippingText; - } - /** * Get vouchers. * diff --git a/Models/BillElement.php b/Models/BillElement.php index cd61756..ac17f62 100755 --- a/Models/BillElement.php +++ b/Models/BillElement.php @@ -119,42 +119,16 @@ class BillElement implements \JsonSerializable return $this->id; } - /** - * Set order. - * - * @param int $order Order - * - * @return void - * - * @since 1.0.0 - */ - public function setOrder(int $order) : void - { - $this->order = $order; - } - - /** - * Get order. - * - * @return int - * - * @since 1.0.0 - */ - public function getOrder() : int - { - return $this->order; - } - /** * Set item. * - * @param mixed $item Item + * @param int $item Item * * @return void * * @since 1.0.0 */ - public function setItem($item) : void + public function setItem(int $item) : void { $this->item = $item; } diff --git a/Models/BillMapper.php b/Models/BillMapper.php index 2530b08..b27e396 100755 --- a/Models/BillMapper.php +++ b/Models/BillMapper.php @@ -58,7 +58,7 @@ class BillMapper extends DataMapperAbstract 'billing_bill_net' => ['name' => 'billing_bill_net', 'type' => 'Serializable', 'internal' => 'net'], 'billing_bill_costs' => ['name' => 'billing_bill_costs', 'type' => 'Serializable', 'internal' => 'costs'], 'billing_bill_profit' => ['name' => 'billing_bill_profit', 'type' => 'Serializable', 'internal' => 'profit'], - 'billing_bill_currency' => ['name' => 'billing_bill_currency', 'type' => 'int', 'internal' => 'currency'], + 'billing_bill_currency' => ['name' => 'billing_bill_currency', 'type' => 'string', 'internal' => 'currency'], 'billing_bill_referral' => ['name' => 'billing_bill_referral', 'type' => 'int', 'internal' => 'referral'], 'billing_bill_referral_name' => ['name' => 'billing_bill_referral_name', 'type' => 'string', 'internal' => 'referralName'], 'billing_bill_reference' => ['name' => 'billing_bill_reference', 'type' => 'int', 'internal' => 'reference'], diff --git a/Models/BillTypeL11n.php b/Models/BillTypeL11n.php index c8ba61c..76b9ff0 100755 --- a/Models/BillTypeL11n.php +++ b/Models/BillTypeL11n.php @@ -41,7 +41,7 @@ class BillTypeL11n implements \JsonSerializable, ArrayableInterface * @var int * @since 1.0.0 */ - protected int | BillType $type = 0; + public int | BillType $type = 0; /** * Language. @@ -87,32 +87,6 @@ class BillTypeL11n implements \JsonSerializable, ArrayableInterface return $this->id; } - /** - * Set type. - * - * @param int $type Type id - * - * @return void - * - * @since 1.0.0 - */ - public function setBillType(int $type) : void - { - $this->type = $type; - } - - /** - * Get type - * - * @return int - * - * @since 1.0.0 - */ - public function getType() : int | BillType - { - return $this->type; - } - /** * Get language * diff --git a/Models/NullBill.php b/Models/NullBill.php index b644bbd..245111b 100755 --- a/Models/NullBill.php +++ b/Models/NullBill.php @@ -24,4 +24,16 @@ namespace Modules\Billing\Models; */ final class NullBill extends Bill { + /** + * Constructor + * + * @param int $id Model id + * + * @since 1.0.0 + */ + public function __construct(int $id = 0) + { + $this->id = $id; + parent::__construct(); + } } diff --git a/info.json b/info.json index 16374bc..02dd43f 100755 --- a/info.json +++ b/info.json @@ -20,7 +20,9 @@ "Admin": "1.0.0", "Sales": "1.0.0", "Media": "1.0.0", - "ClientManagement": "1.0.0" + "ItemManagement": "1.0.0", + "ClientManagement": "1.0.0", + "SupplierManagement": "1.0.0" }, "providing": { "Navigation": "*", diff --git a/tests/Admin/AdminTest.php b/tests/Admin/AdminTest.php new file mode 100644 index 0000000..496a52e --- /dev/null +++ b/tests/Admin/AdminTest.php @@ -0,0 +1,27 @@ +app = new class() extends ApplicationAbstract + { + protected string $appName = 'Api'; + }; + + $this->app->dbPool = $GLOBALS['dbpool']; + $this->app->orgId = 1; + $this->app->accountManager = new AccountManager($GLOBALS['session']); + $this->app->appSettings = new CoreSettings(); + $this->app->moduleManager = new ModuleManager($this->app, __DIR__ . '/../../../../Modules/'); + $this->app->dispatcher = new Dispatcher($this->app); + $this->app->eventManager = new EventManager($this->app->dispatcher); + $this->app->eventManager->importFromFile(__DIR__ . '/../../../../Web/Api/Hooks.php'); + + $account = new Account(); + TestUtils::setMember($account, 'id', 1); + + $permission = new AccountPermission(); + $permission->setUnit(1); + $permission->setApp('backend'); + $permission->setPermission( + PermissionType::READ + | PermissionType::CREATE + | PermissionType::MODIFY + | PermissionType::DELETE + | PermissionType::PERMISSION + ); + + $account->addPermission($permission); + + $this->app->accountManager->add($account); + $this->app->router = new WebRouter(); + + $this->module = $this->app->moduleManager->get('Billing'); + + TestUtils::setMember($this->module, 'app', $this->app); + } + + /** + * Tests bill, bill element and bill pdf archive create + * + * @covers Modules\Billing\Controller\ApiController + * @group module + */ + public function testBillCreate() : void + { + $response = new HttpResponse(); + $request = new HttpRequest(new HttpUri('')); + + $request->header->account = 1; + + $request->setData('client', 1); + $request->setData('address', null); + $request->setData('type', 1); + $request->setData('status', null); // null = system settings, value = individual input + $request->setData('performancedate', DateTime::generateDateTime(new \DateTime('2015-01-01'), new \DateTime('now'))->format('Y-m-d H:i:s')); + $request->setData('sales_referral', null); // who these sales belong to + $request->setData('shipping_terms', 1); // e.g. incoterms + $request->setData('shipping_type', 1); + $request->setData('shipping_cost', null); + $request->setData('insurance_type', 1); + $request->setData('insurance_cost', null); // null = system settings, value = individual input + $request->setData('info', null); // null = system settings, value = individual input + $request->setData('currency', null); // null = system settings, value = individual input + $request->setData('payment', null); // null = system settings, value = individual input + $request->setData('payment_terms', null); // null = system settings, value = individual input + + $this->module->apiBillCreate($request, $response); + + $bId = $response->get('')['response']->getId(); + self::assertGreaterThan(0, $bId); + + for ($k = 0; $k < 10; ++$k) { + $response = new HttpResponse(); + $request = new HttpRequest(new HttpUri('')); + + $request->header->account = 1; + + $iId = \mt_rand(0, 10); + + $request->setData('bill', $bId); + $request->setData('item', $iId === 0 ? null : $iId); + + if ($iId === 0) { + // @todo: add text + } + + $request->setData('quantity', \mt_rand(1, 11)); + $request->setData('tax', null); + $request->setData('text', $iId === 0 ? 'Some test text' : null); + + // discounts + if (\mt_rand(1, 100) < 31) { + $request->setData('discount_percentage', \mt_rand(5, 30)); + } + + $this->module->apiBillElementCreate($request, $response); + self::assertGreaterThan(0, $response->get('')['response']->getId()); + } + + $response = new HttpResponse(); + $request = new HttpRequest(new HttpUri('')); + + $request->header->account = 1; + $request->setData('bill', $bId); + + $this->module->apiBillPdfArchiveCreate($request, $response); + + $result = $response->get(''); + self::assertGreaterThan(0, $result === null ? -1 : $result['response']?->getId()); + } + + /** + * @covers Modules\Billing\Controller\ApiController + * @group module + */ + public function testBillCreateInvalidData() : void + { + $response = new HttpResponse(); + $request = new HttpRequest(new HttpUri('')); + + $request->header->account = 1; + + $this->module->apiBillCreate($request, $response); + self::assertEquals(RequestStatusCode::R_400, $response->header->status); + } +} diff --git a/tests/Models/BillElementTest.php b/tests/Models/BillElementTest.php new file mode 100644 index 0000000..91d007f --- /dev/null +++ b/tests/Models/BillElementTest.php @@ -0,0 +1,53 @@ +element = new BillElement(); + } + + /** + * @covers Modules\Billing\Models\BillElement + * @group module + */ + public function testDefault() : void + { + self::assertEquals(0, $this->element->getId()); + self::assertInstanceOf('\phpOMS\Localization\Money', $this->element->singleSalesPriceNet); + self::assertInstanceOf('\phpOMS\Localization\Money', $this->element->totalSalesPriceNet); + self::assertInstanceOf('\phpOMS\Localization\Money', $this->element->singlePurchasePriceNet); + self::assertInstanceOf('\phpOMS\Localization\Money', $this->element->totalPurchasePriceNet); + } + + public function testItemInputOutput() : void + { + $this->element->setItem(123); + self::assertEquals(123, $this->element->item); + } +} diff --git a/tests/Models/BillTest.php b/tests/Models/BillTest.php new file mode 100644 index 0000000..db9e6cc --- /dev/null +++ b/tests/Models/BillTest.php @@ -0,0 +1,142 @@ +bill = new Bill(); + } + + /** + * @covers Modules\Billing\Models\Bill + * @group module + */ + public function testDefault() : void + { + self::assertEquals(0, $this->bill->getId()); + self::assertEquals('', $this->bill->number); + self::assertEquals('', $this->bill->referralName); + self::assertEquals('', $this->bill->info); + 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::assertEquals([], $this->bill->getVouchers()); + self::assertEquals([], $this->bill->getTrackings()); + + self::assertEquals('', $this->bill->shipTo); + self::assertEquals('', $this->bill->shipFAO); + self::assertEquals('', $this->bill->shipAddress); + self::assertEquals('', $this->bill->shipCity); + self::assertEquals('', $this->bill->shipZip); + self::assertEquals('', $this->bill->shipCountry); + + self::assertEquals('', $this->bill->billTo); + self::assertEquals('', $this->bill->billFAO); + self::assertEquals('', $this->bill->billAddress); + self::assertEquals('', $this->bill->billCity); + self::assertEquals('', $this->bill->billZip); + self::assertEquals('', $this->bill->billCountry); + + self::assertInstanceOf('\phpOMS\Localization\Money', $this->bill->net); + self::assertInstanceOf('\phpOMS\Localization\Money', $this->bill->gross); + self::assertInstanceOf('\phpOMS\Localization\Money', $this->bill->costs); + self::assertInstanceOf('\phpOMS\Localization\Money', $this->bill->profit); + + self::assertEquals(0, $this->bill->payment); + self::assertEquals('', $this->bill->paymentText); + self::assertEquals(0, $this->bill->terms); + self::assertEquals('', $this->bill->termsText); + self::assertEquals(0, $this->bill->shipping); + self::assertEquals('', $this->bill->shippingText); + } + + /** + * @covers Modules\Billing\Models\Bill + * @group module + */ + public function testNumberRendering() : void + { + $this->bill->number = '{y}{m}{d}-{id}'; + self::assertEquals(\date('Y') . \date('m') . \date('d') . '-0', $this->bill->getNumber()); + } + + /** + * @covers Modules\Billing\Models\Bill + * @group module + */ + public function testTypeInputOutput() : void + { + $this->bill->setType(new BillType()); + self::assertInstanceOf('\Modules\Billing\Models\BillType', $this->bill->getType()); + } + + /** + * @covers Modules\Billing\Models\Bill + * @group module + */ + public function testStatusInputOutput() : void + { + $this->bill->setStatus(BillStatus::ACTIVE); + self::assertEquals(BillStatus::ACTIVE, $this->bill->getStatus()); + } + + /** + * @covers Modules\Billing\Models\Bill + * @group module + */ + public function testCurrencyInputOutput() : void + { + $this->bill->setCurrency(ISO4217CharEnum::_USD); + self::assertEquals(ISO4217CharEnum::_USD, $this->bill->getCurrency()); + } + + /** + * @covers Modules\Billing\Models\Bill + * @group module + */ + public function testVoucherInputOutput() : void + { + $this->bill->addVoucher('TEST'); + self::assertEquals(['TEST'], $this->bill->getVouchers()); + } + + /** + * @covers Modules\Billing\Models\Bill + * @group module + */ + public function testTrackingInputOutput() : void + { + $this->bill->addTracking('TEST'); + self::assertEquals(['TEST'], $this->bill->getTrackings()); + } +} diff --git a/tests/Models/BillTypeL11nTest.php b/tests/Models/BillTypeL11nTest.php new file mode 100644 index 0000000..65781f7 --- /dev/null +++ b/tests/Models/BillTypeL11nTest.php @@ -0,0 +1,88 @@ +l11n = new BillTypeL11n(); + } + + /** + * @covers Modules\Billing\Models\BillTypeL11n + * @group module + */ + public function testDefault() : void + { + self::assertEquals(0, $this->l11n->getId()); + self::assertEquals('', $this->l11n->name); + self::assertEquals(0, $this->l11n->type); + self::assertEquals(ISO639x1Enum::_EN, $this->l11n->getLanguage()); + } + + /** + * @covers Modules\Billing\Models\BillTypeL11n + * @group module + */ + public function testNameInputOutput() : void + { + $this->l11n->name = 'TestName'; + self::assertEquals('TestName', $this->l11n->name); + } + + /** + * @covers Modules\Billing\Models\BillTypeL11n + * @group module + */ + public function testLanguageInputOutput() : void + { + $this->l11n->setLanguage(ISO639x1Enum::_DE); + self::assertEquals(ISO639x1Enum::_DE, $this->l11n->getLanguage()); + } + + /** + * @covers Modules\Billing\Models\BillTypeL11n + * @group module + */ + public function testSerialize() : void + { + $this->l11n->name = 'Title'; + $this->l11n->description = 'Description'; + $this->l11n->type = 2; + $this->l11n->setLanguage(ISO639x1Enum::_DE); + + self::assertEquals( + [ + 'id' => 0, + 'name' => 'Title', + 'type' => 2, + 'language' => ISO639x1Enum::_DE, + ], + $this->l11n->jsonSerialize() + ); + } +} diff --git a/tests/Models/BillTypeTest.php b/tests/Models/BillTypeTest.php new file mode 100644 index 0000000..55fb931 --- /dev/null +++ b/tests/Models/BillTypeTest.php @@ -0,0 +1,57 @@ +type = new BillType(); + } + + /** + * @covers Modules\Billing\Models\BillType + * @group module + */ + public function testDefault() : void + { + self::assertEquals(0, $this->type->getId()); + self::assertTrue($this->type->transferStock); + } + + /** + * @covers Modules\Billing\Models\BillType + * @group module + */ + public function testL11nInputOutput() : void + { + $this->type->setL11n('Test1'); + self::assertEquals('Test1', $this->type->getL11n()); + + $this->type->setL11n(new BillTypeL11n(0, 'Test2')); + self::assertEquals('Test2', $this->type->getL11n()); + } +} diff --git a/tests/Models/NullBill.php b/tests/Models/NullBill.php new file mode 100644 index 0000000..6697334 --- /dev/null +++ b/tests/Models/NullBill.php @@ -0,0 +1,42 @@ +getId()); + } +} diff --git a/tests/Models/NullBillElement.php b/tests/Models/NullBillElement.php new file mode 100644 index 0000000..ecf1267 --- /dev/null +++ b/tests/Models/NullBillElement.php @@ -0,0 +1,42 @@ +getId()); + } +} diff --git a/tests/Models/NullBillElementTest.php b/tests/Models/NullBillElementTest.php new file mode 100644 index 0000000..6c9a130 --- /dev/null +++ b/tests/Models/NullBillElementTest.php @@ -0,0 +1,42 @@ +getId()); + } +} diff --git a/tests/Models/NullBillTest.php b/tests/Models/NullBillTest.php new file mode 100644 index 0000000..e466693 --- /dev/null +++ b/tests/Models/NullBillTest.php @@ -0,0 +1,42 @@ +getId()); + } +} diff --git a/tests/Models/NullBillType.php b/tests/Models/NullBillType.php new file mode 100644 index 0000000..cd30551 --- /dev/null +++ b/tests/Models/NullBillType.php @@ -0,0 +1,42 @@ +getId()); + } +} diff --git a/tests/Models/NullBillTypeTest.php b/tests/Models/NullBillTypeTest.php new file mode 100644 index 0000000..6070dcf --- /dev/null +++ b/tests/Models/NullBillTypeTest.php @@ -0,0 +1,42 @@ +getId()); + } +}