From ed9792da408948906073e9b162e2f9becb8a0b97 Mon Sep 17 00:00:00 2001 From: Dennis Eichhorn Date: Sat, 8 Apr 2023 04:36:26 +0200 Subject: [PATCH 1/3] fix billing process --- .github/user_bug_report.md | 14 ++++++++++---- Controller/ApiController.php | 16 ++++++++-------- tests/Controller/ApiControllerTest.php | 2 +- 3 files changed, 19 insertions(+), 13 deletions(-) diff --git a/.github/user_bug_report.md b/.github/user_bug_report.md index 9e5f2a5..4b92a8e 100755 --- a/.github/user_bug_report.md +++ b/.github/user_bug_report.md @@ -8,9 +8,11 @@ assignees: '' --- # Bug Description + A clear and concise description of what the bug is. # How to Reproduce + Steps to reproduce the behavior: 1. Go to '...' @@ -19,16 +21,20 @@ Steps to reproduce the behavior: 4. See error # Expected Behavior + A clear and concise description of what you expected to happen. # Screenshots + If applicable, add screenshots to help explain your problem. # System Information - - System: [e.g. PC or iPhone11, ...] - - OS: [e.g. iOS] - - Browser [e.g. chrome, safari] - - KarakaVersion [e.g. 22] + +- System: [e.g. PC or iPhone11, ...] +- OS: [e.g. iOS] +- Browser [e.g. chrome, safari] +- KarakaVersion [e.g. 22] # Additional Information + Add any other context about the problem here. diff --git a/Controller/ApiController.php b/Controller/ApiController.php index 4b66c65..fb533e1 100755 --- a/Controller/ApiController.php +++ b/Controller/ApiController.php @@ -17,8 +17,8 @@ namespace Modules\Profile\Controller; use Modules\Admin\Models\AccountMapper; use Modules\Admin\Models\Address; use Modules\Admin\Models\AddressMapper; -use Modules\Media\Models\NullMedia; use Modules\Media\Models\MediaMapper; +use Modules\Media\Models\NullMedia; use Modules\Media\Models\PathSettings; use Modules\Profile\Models\ContactElement; use Modules\Profile\Models\ContactElementMapper; @@ -271,10 +271,10 @@ final class ApiController extends Controller public function validateContactElementCreate(RequestAbstract $request) : array { $val = []; - if (($val['account'] = (empty($request->getData('account')) && empty($request->getData('profile')))) + if (($val['account'] = (!$request->hasData('account') && !$request->hasData('profile'))) || ($val['type'] = !\is_numeric($request->getData('type'))) - || ($val['content'] = empty($request->getData('content'))) - || ($val['contact'] = empty($request->getData('contact'))) + || ($val['content'] = !$request->hasData('content')) + || ($val['contact'] = !$request->hasData('contact')) ) { return $val; } @@ -356,11 +356,11 @@ final class ApiController extends Controller private function validateAddressCreate(RequestAbstract $request) : array { $val = []; - if (($val['account'] = (empty($request->getData('account')) && empty($request->getData('profile')))) + if (($val['account'] = (!$request->hasData('account') && !$request->hasData('profile'))) || ($val['type'] = !\is_numeric($request->getData('type'))) - || ($val['country'] = empty($request->getData('country'))) - || ($val['city'] = empty($request->getData('city'))) - || ($val['address'] = empty($request->getData('address'))) + || ($val['country'] = !$request->hasData('country')) + || ($val['city'] = !$request->hasData('city')) + || ($val['address'] = !$request->hasData('address')) ) { return $val; } diff --git a/tests/Controller/ApiControllerTest.php b/tests/Controller/ApiControllerTest.php index 1faa19f..8e7ab22 100755 --- a/tests/Controller/ApiControllerTest.php +++ b/tests/Controller/ApiControllerTest.php @@ -73,7 +73,7 @@ final class ApiControllerTest extends \PHPUnit\Framework\TestCase $permission = new AccountPermission(); $permission->setUnit(1); - $permission->setApp('backend'); + $permission->setApp(2); $permission->setPermission( PermissionType::READ | PermissionType::CREATE From 70b2a8e7fac9cdb85281532068dfd7e7afeb7469 Mon Sep 17 00:00:00 2001 From: Dennis Eichhorn Date: Tue, 11 Apr 2023 00:20:13 +0200 Subject: [PATCH 2/3] fix static analysis --- .github/user_feature_request.md | 3 +++ Models/ContactElementMapper.php | 3 +++ Models/ContactMapper.php | 3 +++ Models/ProfileMapper.php | 5 ++++- 4 files changed, 13 insertions(+), 1 deletion(-) diff --git a/.github/user_feature_request.md b/.github/user_feature_request.md index 6eb8ddc..c9595e8 100755 --- a/.github/user_feature_request.md +++ b/.github/user_feature_request.md @@ -8,11 +8,14 @@ assignees: '' --- # What is the feature you request + * A clear and concise description of what the problem is. Ex. I'm always frustrated when [...] * A clear and concise description of what you want to happen. # Alternatives + A clear and concise description of any alternative solutions or features you've considered. # Additional Information + Add any other context or screenshots about the feature request here. diff --git a/Models/ContactElementMapper.php b/Models/ContactElementMapper.php index 79d1b9b..2cf8794 100755 --- a/Models/ContactElementMapper.php +++ b/Models/ContactElementMapper.php @@ -23,6 +23,9 @@ use phpOMS\DataStorage\Database\Mapper\DataMapperFactory; * @license OMS License 2.0 * @link https://jingga.app * @since 1.0.0 + * + * @template T of ContactElement + * @extends DataMapperFactory */ final class ContactElementMapper extends DataMapperFactory { diff --git a/Models/ContactMapper.php b/Models/ContactMapper.php index fcf7eea..640ab26 100755 --- a/Models/ContactMapper.php +++ b/Models/ContactMapper.php @@ -25,6 +25,9 @@ use phpOMS\DataStorage\Database\Mapper\DataMapperFactory; * @license OMS License 2.0 * @link https://jingga.app * @since 1.0.0 + * + * @template T of Contact + * @extends DataMapperFactory */ final class ContactMapper extends DataMapperFactory { diff --git a/Models/ProfileMapper.php b/Models/ProfileMapper.php index bdafa60..0a1def5 100755 --- a/Models/ProfileMapper.php +++ b/Models/ProfileMapper.php @@ -25,6 +25,9 @@ use phpOMS\DataStorage\Database\Mapper\DataMapperFactory; * @license OMS License 2.0 * @link https://jingga.app * @since 1.0.0 + * + * @template T of Profile + * @extends DataMapperFactory */ final class ProfileMapper extends DataMapperFactory { @@ -72,7 +75,7 @@ final class ProfileMapper extends DataMapperFactory /** * Model to use by the mapper. * - * @var class-string + * @var class-string * @since 1.0.0 */ public const MODEL = Profile::class; From 045370d5a69ad3c88a0dbd5fa4f05bc2aa3d3531 Mon Sep 17 00:00:00 2001 From: Dennis Eichhorn Date: Mon, 17 Apr 2023 19:44:57 +0200 Subject: [PATCH 3/3] test fixes --- tests/Controller/ApiControllerTest.php | 2 ++ 1 file changed, 2 insertions(+) diff --git a/tests/Controller/ApiControllerTest.php b/tests/Controller/ApiControllerTest.php index 8e7ab22..4911274 100755 --- a/tests/Controller/ApiControllerTest.php +++ b/tests/Controller/ApiControllerTest.php @@ -26,6 +26,7 @@ use phpOMS\Application\ApplicationAbstract; use phpOMS\Dispatcher\Dispatcher; use phpOMS\Event\EventManager; use phpOMS\Localization\ISO3166TwoEnum; +use phpOMS\Localization\L11nManager; use phpOMS\Message\Http\HttpRequest; use phpOMS\Message\Http\HttpResponse; use phpOMS\Message\Http\RequestStatusCode; @@ -66,6 +67,7 @@ final class ApiControllerTest extends \PHPUnit\Framework\TestCase $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->l11nManager = new L11nManager(); $this->app->eventManager->importFromFile(__DIR__ . '/../../../Web/Api/Hooks.php'); $account = new Account();