From 379247c74a0309967116b193a5ada2c8601f7c6b Mon Sep 17 00:00:00 2001 From: Dennis Eichhorn Date: Wed, 27 Sep 2023 17:32:55 +0000 Subject: [PATCH] fix tests --- Controller/ApiController.php | 1 + tests/Controller/ApiControllerTest.php | 25 ++++++++----------------- 2 files changed, 9 insertions(+), 17 deletions(-) diff --git a/Controller/ApiController.php b/Controller/ApiController.php index ffe20eb..066b4d0 100755 --- a/Controller/ApiController.php +++ b/Controller/ApiController.php @@ -56,6 +56,7 @@ final class ApiController extends Controller PermissionType::CREATE, $this->app->unitId, $this->app->appId, self::NAME, PermissionCategory::SESSION_FOREIGN )) { $response->header->status = RequestStatusCode::R_403; + $this->createInvalidCreateResponse($request, $response, []); return; } diff --git a/tests/Controller/ApiControllerTest.php b/tests/Controller/ApiControllerTest.php index d125cea..970c84e 100755 --- a/tests/Controller/ApiControllerTest.php +++ b/tests/Controller/ApiControllerTest.php @@ -18,6 +18,8 @@ use Model\CoreSettings; use Modules\Admin\Models\AccountMapper; use Modules\Admin\Models\AccountPermission; use Modules\Admin\Models\NullAccount; +use Modules\HumanResourceManagement\Models\Employee; +use Modules\HumanResourceManagement\Models\EmployeeMapper; use Modules\HumanResourceTimeRecording\Models\ClockingStatus; use Modules\Media\Models\Media; use Modules\Profile\Models\Profile; @@ -104,29 +106,18 @@ final class ApiControllerTest extends \PHPUnit\Framework\TestCase */ public function testApiSessionCR() : void { - $media = new Media(); - $media->createdBy = new NullAccount(1); - $media->description = 'desc'; - $media->setPath('Web/Backend/img/default-user.jpg'); - $media->size = 11; - $media->extension = 'png'; - $media->name = 'Image'; - if (($profile = ProfileMapper::get()->where('account', 1)->execute())->id === 0) { $profile = new Profile(); $profile->account = AccountMapper::get()->where('id', 1)->execute(); - $profile->image = $media; - $profile->birthday = new \DateTime('now'); + $profile->birthday = ($date = new \DateTime('now')); - $id = ProfileMapper::create()->execute($profile); - self::assertGreaterThan(0, $profile->id); - self::assertEquals($id, $profile->id); - } else { - $profile->image = $media; - $profile->birthday = new \DateTime('now'); + ProfileMapper::create()->execute($profile); + } - ProfileMapper::update()->with('image')->execute($profile); + if (($e = EmployeeMapper::get()->with('profile')->where('profile/account', 1)->execute())->id === 0) { + $employee = new Employee($profile); + EmployeeMapper::create()->execute($employee); } $response = new HttpResponse();