more tests and make classes final

This commit is contained in:
Dennis Eichhorn 2021-10-21 22:16:05 +02:00
parent 34873f00a6
commit 7483cd7871
21 changed files with 873 additions and 624 deletions

View File

@ -225,7 +225,7 @@
},
"billing_bill_currency": {
"name": "billing_bill_currency",
"type": "INT",
"type": "VARCHAR(3)",
"null": false
},
"billing_bill_referral": {

View File

@ -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);
}
/**

View File

@ -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.
*

View File

@ -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.
*

View File

@ -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;
}

View File

@ -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'],

View File

@ -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
*

View File

@ -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();
}
}

View File

@ -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": "*",

27
tests/Admin/AdminTest.php Normal file
View File

@ -0,0 +1,27 @@
<?php
/**
* Orange Management
*
* PHP Version 8.0
*
* @package tests
* @copyright Dennis Eichhorn
* @license OMS License 1.0
* @version 1.0.0
* @link https://orange-management.org
*/
declare(strict_types=1);
namespace Modules\Billing\tests\Admin;
/**
* @internal
*/
class AdminTest extends \PHPUnit\Framework\TestCase
{
protected const NAME = 'Billing';
protected const URI_LOAD = 'http://127.0.0.1/en/backend/admin/audit';
use \Modules\tests\ModuleTestTrait;
}

View File

@ -0,0 +1,181 @@
<?php
/**
* Orange Management
*
* PHP Version 8.0
*
* @package tests
* @copyright Dennis Eichhorn
* @license OMS License 1.0
* @version 1.0.0
* @link https://orange-management.org
*/
declare(strict_types=1);
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\Uri\HttpUri;
use phpOMS\Utils\RnG\DateTime;
/**
* @testdox Modules\tests\Billing\Controller\ApiControllerTest: Billing api controller
*
* @internal
*/
class ApiControllerTest extends \PHPUnit\Framework\TestCase
{
protected ApplicationAbstract $app;
/**
* @var \Modules\Billing\Controller\ApiController
*/
protected ModuleAbstract $module;
/**
* {@inheritdoc}
*/
protected function setUp() : void
{
$this->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);
}
}

View File

@ -0,0 +1,53 @@
<?php
/**
* Orange Management
*
* PHP Version 8.0
*
* @package tests
* @copyright Dennis Eichhorn
* @license OMS License 1.0
* @version 1.0.0
* @link https://orange-management.org
*/
declare(strict_types=1);
namespace Modules\Billing\tests\Models;
use Modules\Billing\Models\BillElement;
use phpOMS\Localization\ISO4217CharEnum;
/**
* @internal
*/
class BillElementTest extends \PHPUnit\Framework\TestCase
{
private BillElement $element;
/**
* {@inheritdoc}
*/
protected function setUp() : void
{
$this->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);
}
}

142
tests/Models/BillTest.php Normal file
View File

@ -0,0 +1,142 @@
<?php
/**
* Orange Management
*
* PHP Version 8.0
*
* @package tests
* @copyright Dennis Eichhorn
* @license OMS License 1.0
* @version 1.0.0
* @link https://orange-management.org
*/
declare(strict_types=1);
namespace Modules\Billing\tests\Models;
use Modules\Billing\Models\Bill;
use Modules\Billing\Models\BillStatus;
use Modules\Billing\Models\BillType;
use phpOMS\Localization\ISO4217CharEnum;
/**
* @internal
*/
class BillTest extends \PHPUnit\Framework\TestCase
{
private Bill $bill;
/**
* {@inheritdoc}
*/
protected function setUp() : void
{
$this->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());
}
}

View File

@ -0,0 +1,88 @@
<?php
/**
* Orange Management
*
* PHP Version 8.0
*
* @package tests
* @copyright Dennis Eichhorn
* @license OMS License 1.0
* @version 1.0.0
* @link https://orange-management.org
*/
declare(strict_types=1);
namespace Modules\Billing\tests\Models;
use Modules\Billing\Models\BillTypeL11n;
use phpOMS\Localization\ISO639x1Enum;
/**
* @internal
*/
class BillTypeL11nTest extends \PHPUnit\Framework\TestCase
{
private BillTypeL11n $l11n;
/**
* {@inheritdoc}
*/
protected function setUp() : void
{
$this->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()
);
}
}

View File

@ -0,0 +1,57 @@
<?php
/**
* Orange Management
*
* PHP Version 8.0
*
* @package tests
* @copyright Dennis Eichhorn
* @license OMS License 1.0
* @version 1.0.0
* @link https://orange-management.org
*/
declare(strict_types=1);
namespace Modules\Billing\tests\Models;
use Modules\Billing\Models\BillType;
use Modules\Billing\Models\BillTypeL11n;
/**
* @internal
*/
class BillTypeTest extends \PHPUnit\Framework\TestCase
{
private BillType $type;
/**
* {@inheritdoc}
*/
protected function setUp() : void
{
$this->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());
}
}

42
tests/Models/NullBill.php Normal file
View File

@ -0,0 +1,42 @@
<?php
/**
* Orange Management
*
* PHP Version 8.0
*
* @package tests
* @copyright Dennis Eichhorn
* @license OMS License 1.0
* @version 1.0.0
* @link https://orange-management.org
*/
declare(strict_types=1);
namespace Modules\Billing\tests\Models;
use Modules\Billing\Models\NullBill;
/**
* @internal
*/
final class Null extends \PHPUnit\Framework\TestCase
{
/**
* @covers Modules\Billing\Models\NullBill
* @group framework
*/
public function testNull() : void
{
self::assertInstanceOf('\Modules\Billing\Models\Bill', new NullBill());
}
/**
* @covers Modules\Billing\Models\NullBill
* @group framework
*/
public function testId() : void
{
$null = new NullBill(2);
self::assertEquals(2, $null->getId());
}
}

View File

@ -0,0 +1,42 @@
<?php
/**
* Orange Management
*
* PHP Version 8.0
*
* @package tests
* @copyright Dennis Eichhorn
* @license OMS License 1.0
* @version 1.0.0
* @link https://orange-management.org
*/
declare(strict_types=1);
namespace Modules\Billing\tests\Models;
use Modules\Billing\Models\NullBillElement;
/**
* @internal
*/
final class Null extends \PHPUnit\Framework\TestCase
{
/**
* @covers Modules\Billing\Models\NullBillElement
* @group framework
*/
public function testNull() : void
{
self::assertInstanceOf('\Modules\Billing\Models\BillElement', new NullBillElement());
}
/**
* @covers Modules\Billing\Models\NullBillElement
* @group framework
*/
public function testId() : void
{
$null = new NullBillElement(2);
self::assertEquals(2, $null->getId());
}
}

View File

@ -0,0 +1,42 @@
<?php
/**
* Orange Management
*
* PHP Version 8.0
*
* @package tests
* @copyright Dennis Eichhorn
* @license OMS License 1.0
* @version 1.0.0
* @link https://orange-management.org
*/
declare(strict_types=1);
namespace Modules\Billing\tests\Models;
use Modules\Billing\Models\NullBillElement;
/**
* @internal
*/
final class NullBillElementTest extends \PHPUnit\Framework\TestCase
{
/**
* @covers Modules\Billing\Models\NullBillElement
* @group framework
*/
public function testNull() : void
{
self::assertInstanceOf('\Modules\Billing\Models\BillElement', new NullBillElement());
}
/**
* @covers Modules\Billing\Models\NullBillElement
* @group framework
*/
public function testId() : void
{
$null = new NullBillElement(2);
self::assertEquals(2, $null->getId());
}
}

View File

@ -0,0 +1,42 @@
<?php
/**
* Orange Management
*
* PHP Version 8.0
*
* @package tests
* @copyright Dennis Eichhorn
* @license OMS License 1.0
* @version 1.0.0
* @link https://orange-management.org
*/
declare(strict_types=1);
namespace Modules\Billing\tests\Models;
use Modules\Billing\Models\NullBill;
/**
* @internal
*/
final class NullBillTest extends \PHPUnit\Framework\TestCase
{
/**
* @covers Modules\Billing\Models\NullBill
* @group framework
*/
public function testNull() : void
{
self::assertInstanceOf('\Modules\Billing\Models\Bill', new NullBill());
}
/**
* @covers Modules\Billing\Models\NullBill
* @group framework
*/
public function testId() : void
{
$null = new NullBill(2);
self::assertEquals(2, $null->getId());
}
}

View File

@ -0,0 +1,42 @@
<?php
/**
* Orange Management
*
* PHP Version 8.0
*
* @package tests
* @copyright Dennis Eichhorn
* @license OMS License 1.0
* @version 1.0.0
* @link https://orange-management.org
*/
declare(strict_types=1);
namespace Modules\Billing\tests\Models;
use Modules\Billing\Models\NullBillType;
/**
* @internal
*/
final class Null extends \PHPUnit\Framework\TestCase
{
/**
* @covers Modules\Billing\Models\NullBillType
* @group framework
*/
public function testNull() : void
{
self::assertInstanceOf('\Modules\Billing\Models\BillType', new NullBillType());
}
/**
* @covers Modules\Billing\Models\NullBillType
* @group framework
*/
public function testId() : void
{
$null = new NullBillType(2);
self::assertEquals(2, $null->getId());
}
}

View File

@ -0,0 +1,42 @@
<?php
/**
* Orange Management
*
* PHP Version 8.0
*
* @package tests
* @copyright Dennis Eichhorn
* @license OMS License 1.0
* @version 1.0.0
* @link https://orange-management.org
*/
declare(strict_types=1);
namespace Modules\Billing\tests\Models;
use Modules\Billing\Models\NullBillType;
/**
* @internal
*/
final class NullBillTypeTest extends \PHPUnit\Framework\TestCase
{
/**
* @covers Modules\Billing\Models\NullBillType
* @group framework
*/
public function testNull() : void
{
self::assertInstanceOf('\Modules\Billing\Models\BillType', new NullBillType());
}
/**
* @covers Modules\Billing\Models\NullBillType
* @group framework
*/
public function testId() : void
{
$null = new NullBillType(2);
self::assertEquals(2, $null->getId());
}
}