mirror of
https://github.com/Karaka-Management/oms-HumanResourceTimeRecording.git
synced 2026-02-16 12:48:40 +00:00
fix tests
This commit is contained in:
parent
911d7a2536
commit
379247c74a
|
|
@ -56,6 +56,7 @@ final class ApiController extends Controller
|
||||||
PermissionType::CREATE, $this->app->unitId, $this->app->appId, self::NAME, PermissionCategory::SESSION_FOREIGN
|
PermissionType::CREATE, $this->app->unitId, $this->app->appId, self::NAME, PermissionCategory::SESSION_FOREIGN
|
||||||
)) {
|
)) {
|
||||||
$response->header->status = RequestStatusCode::R_403;
|
$response->header->status = RequestStatusCode::R_403;
|
||||||
|
$this->createInvalidCreateResponse($request, $response, []);
|
||||||
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -18,6 +18,8 @@ use Model\CoreSettings;
|
||||||
use Modules\Admin\Models\AccountMapper;
|
use Modules\Admin\Models\AccountMapper;
|
||||||
use Modules\Admin\Models\AccountPermission;
|
use Modules\Admin\Models\AccountPermission;
|
||||||
use Modules\Admin\Models\NullAccount;
|
use Modules\Admin\Models\NullAccount;
|
||||||
|
use Modules\HumanResourceManagement\Models\Employee;
|
||||||
|
use Modules\HumanResourceManagement\Models\EmployeeMapper;
|
||||||
use Modules\HumanResourceTimeRecording\Models\ClockingStatus;
|
use Modules\HumanResourceTimeRecording\Models\ClockingStatus;
|
||||||
use Modules\Media\Models\Media;
|
use Modules\Media\Models\Media;
|
||||||
use Modules\Profile\Models\Profile;
|
use Modules\Profile\Models\Profile;
|
||||||
|
|
@ -104,29 +106,18 @@ final class ApiControllerTest extends \PHPUnit\Framework\TestCase
|
||||||
*/
|
*/
|
||||||
public function testApiSessionCR() : void
|
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) {
|
if (($profile = ProfileMapper::get()->where('account', 1)->execute())->id === 0) {
|
||||||
$profile = new Profile();
|
$profile = new Profile();
|
||||||
|
|
||||||
$profile->account = AccountMapper::get()->where('id', 1)->execute();
|
$profile->account = AccountMapper::get()->where('id', 1)->execute();
|
||||||
$profile->image = $media;
|
$profile->birthday = ($date = new \DateTime('now'));
|
||||||
$profile->birthday = new \DateTime('now');
|
|
||||||
|
|
||||||
$id = ProfileMapper::create()->execute($profile);
|
ProfileMapper::create()->execute($profile);
|
||||||
self::assertGreaterThan(0, $profile->id);
|
}
|
||||||
self::assertEquals($id, $profile->id);
|
|
||||||
} else {
|
|
||||||
$profile->image = $media;
|
|
||||||
$profile->birthday = new \DateTime('now');
|
|
||||||
|
|
||||||
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();
|
$response = new HttpResponse();
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue
Block a user