From 505199b4fa08987b823bf853b4e9e5395acef31f Mon Sep 17 00:00:00 2001 From: Dennis Eichhorn Date: Sun, 25 Dec 2022 00:06:17 +0100 Subject: [PATCH] test fixes and changes for release --- Controller/ApiController.php | 3 +++ Controller/BackendController.php | 12 +++++++----- Models/Contact.php | 2 +- tests/Bootstrap.php | 19 +++++++++++++++++++ 4 files changed, 30 insertions(+), 6 deletions(-) diff --git a/Controller/ApiController.php b/Controller/ApiController.php index ecd4226..9cf4850 100755 --- a/Controller/ApiController.php +++ b/Controller/ApiController.php @@ -194,6 +194,9 @@ final class ApiController extends Controller ); $profile->image = !empty($uploaded) ? \reset($uploaded) : new NullMedia(); + if (!($profile->image instanceof NullMedia)) { + $profile->image = $this->app->moduleManager->get('Media')->resizeImage($profile->image, 100, 100, false); + } $this->updateModel($request->header->account, $old, $profile, ProfileMapper::class, 'profile', $request->getOrigin()); $this->fillJsonResponse($request, $response, NotificationLevel::OK, 'Profile', 'Profile successfully updated', $profile); diff --git a/Controller/BackendController.php b/Controller/BackendController.php index 61b084d..99f5d0e 100755 --- a/Controller/BackendController.php +++ b/Controller/BackendController.php @@ -100,8 +100,10 @@ final class BackendController extends Controller $profileImage = $this->app->appSettings->get(names: SettingsEnum::DEFAULT_PROFILE_IMAGE, module: 'Profile'); - /** @var \Modules\Media\Modles\Media $image */ - $image = MediaMapper::get()->where('id', (int) $profileImage->content)->execute(); + /** @var \Modules\Media\Models\Media $image */ + $image = MediaMapper::get() + ->where('id', (int) $profileImage->content) + ->execute(); $view->setData('defaultImage', $image); @@ -144,7 +146,7 @@ final class BackendController extends Controller ->with('location') ->with('contactElements'); - /** @var \Modules\Profile\Modles\Profile $profile */ + /** @var \Modules\Profile\Models\Profile $profile */ $profile = $request->getData('for') !== null ? $mapperQuery->where('account', (int) $request->getData('for'))->execute() : $mapperQuery->where('id', (int) $request->getData('id'))->execute(); @@ -162,14 +164,14 @@ final class BackendController extends Controller $accGrpSelector = new \Modules\Profile\Theme\Backend\Components\AccountGroupSelector\BaseView($this->app->l11nManager, $request, $response); $view->addData('accGrpSelector', $accGrpSelector); - /** @var \Modules\Media\Modles\Media[] $media */ + /** @var \Modules\Media\Models\Media[] $media */ $media = MediaMapper::getAll() ->with('createdBy') ->where('createdBy', (int) $profile->account->getId()) ->limit(25) ->execute(); - $view->setData('media', $media instanceof NullMedia ? [] : (!\is_array($media) ? [$media] : $media)); + $view->setData('media', $media); $profileImage = $this->app->appSettings->get(names: SettingsEnum::DEFAULT_PROFILE_IMAGE, module: 'Profile'); $image = MediaMapper::get()->where('id', (int) $profileImage->content)->execute(); diff --git a/Models/Contact.php b/Models/Contact.php index 742b08d..de1019b 100755 --- a/Models/Contact.php +++ b/Models/Contact.php @@ -105,7 +105,7 @@ class Contact * @var int * @since 1.0.0 */ - private int $profile = 0; + public int $profile = 0; /** * Constructor. diff --git a/tests/Bootstrap.php b/tests/Bootstrap.php index d46fd31..b5d36a8 100755 --- a/tests/Bootstrap.php +++ b/tests/Bootstrap.php @@ -257,6 +257,25 @@ $CONFIG = [ 'root' => '/', 'https' => false, ], + 'app' => [ + 'path' => __DIR__, + 'default' => [ + 'app' => 'Backend', + 'id' => 'backend', + 'lang' => 'en', + 'theme' => 'Backend', + 'org' => 1, + ], + 'domains' => [ + '127.0.0.1' => [ + 'app' => 'Backend', + 'id' => 'backend', + 'lang' => 'en', + 'theme' => 'Backend', + 'org' => 1, + ], + ], + ], 'socket' => [ 'master' => [ 'host' => '127.0.0.1',