fix tests

This commit is contained in:
Dennis Eichhorn 2023-09-24 02:17:50 +00:00
parent c9c9c86667
commit 1c72898d44
2 changed files with 10 additions and 2 deletions

View File

@ -389,6 +389,7 @@ final class BackendController extends Controller
->where(ItemMapper::HAS_MANY['files']['self'], '=', $item->id) ->where(ItemMapper::HAS_MANY['files']['self'], '=', $item->id)
->where(MediaTypeMapper::TABLE . '.' . MediaTypeMapper::getColumnByMember('name'), '=', 'item_profile_image'); ->where(MediaTypeMapper::TABLE . '.' . MediaTypeMapper::getColumnByMember('name'), '=', 'item_profile_image');
/** @var \Modules\Media\Models\Media $itemImage */
$itemImage = MediaMapper::get() $itemImage = MediaMapper::get()
->with('types') ->with('types')
->where('id', $results) ->where('id', $results)
@ -397,8 +398,8 @@ final class BackendController extends Controller
$view->data['itemImage'] = $itemImage; $view->data['itemImage'] = $itemImage;
/** @var \Model\Setting $settings */
// @todo: this one should already be loaded in the backend application no????????? // @todo: this one should already be loaded in the backend application no?????????
/** @var \Model\Setting $settings */
$settings = $this->app->appSettings->get(null, [ $settings = $this->app->appSettings->get(null, [
SettingsEnum::DEFAULT_LOCALIZATION, SettingsEnum::DEFAULT_LOCALIZATION,
]); ]);
@ -408,11 +409,13 @@ final class BackendController extends Controller
$view->data['l11nView'] = new \Web\Backend\Views\L11nView($this->app->l11nManager, $request, $response); $view->data['l11nView'] = new \Web\Backend\Views\L11nView($this->app->l11nManager, $request, $response);
/** @var \phpOMS\Localization\BaseStringL11nType[] $l11nTypes */
$l11nTypes = ItemL11nTypeMapper::getAll() $l11nTypes = ItemL11nTypeMapper::getAll()
->execute(); ->execute();
$view->data['l11nTypes'] = $l11nTypes; $view->data['l11nTypes'] = $l11nTypes;
/** @var \phpOMS\Localization\BaseStringL11n[] $l11nValues */
$l11nValues = ItemL11nMapper::getAll() $l11nValues = ItemL11nMapper::getAll()
->with('type') ->with('type')
->where('ref', $item->id) ->where('ref', $item->id)
@ -420,6 +423,7 @@ final class BackendController extends Controller
$view->data['l11nValues'] = $l11nValues; $view->data['l11nValues'] = $l11nValues;
/** @var \Modules\Attribute\Models\AttributeType[] $attributeTypes */
$attributeTypes = ItemAttributeTypeMapper::getAll() $attributeTypes = ItemAttributeTypeMapper::getAll()
->with('l11n') ->with('l11n')
->where('l11n/language', $response->header->l11n->language) ->where('l11n/language', $response->header->l11n->language)
@ -427,11 +431,13 @@ final class BackendController extends Controller
$view->data['attributeTypes'] = $attributeTypes; $view->data['attributeTypes'] = $attributeTypes;
/** @var \Modules\Organization\Models\Unit[] $units */
$units = UnitMapper::getAll() $units = UnitMapper::getAll()
->execute(); ->execute();
$view->data['units'] = $units; $view->data['units'] = $units;
/** @var \Modules\Billing\Models\Price\Price[] $prices */
$prices = PriceMapper::getAll() $prices = PriceMapper::getAll()
->where('item', $item->id) ->where('item', $item->id)
->where('type', PriceType::SALES) ->where('type', PriceType::SALES)
@ -440,6 +446,7 @@ final class BackendController extends Controller
$view->data['prices'] = $prices; $view->data['prices'] = $prices;
/** @var \Modules\Auditor\Models\Audit[] $audits */
$audits = AuditMapper::getAll() $audits = AuditMapper::getAll()
->where('type', StringUtils::intHash(ItemMapper::class)) ->where('type', StringUtils::intHash(ItemMapper::class))
->where('module', 'ItemManagement') ->where('module', 'ItemManagement')
@ -448,6 +455,7 @@ final class BackendController extends Controller
$view->data['audits'] = $audits; $view->data['audits'] = $audits;
/** @var \Modules\Media\Models\Media[] $files */
$files = MediaMapper::getAll() $files = MediaMapper::getAll()
->with('types') ->with('types')
->join('id', ItemMapper::class, 'files') // id = media id, files = item relations ->join('id', ItemMapper::class, 'files') // id = media id, files = item relations

View File

@ -131,7 +131,7 @@ final class ItemMapper extends DataMapperFactory
left join media_type on media_type_rel.media_type_rel_dst = media_type.media_type_id and media_type.media_type_name = 'item_profile_image' left join media_type on media_type_rel.media_type_rel_dst = media_type.media_type_id and media_type.media_type_name = 'item_profile_image'
SQL; SQL;
$itemsResult = self::$db->con->query($query)->fetchAll(); $itemsResult = self::$db->con->query($query)?->fetchAll() ?? [];
$items = []; $items = [];
foreach ($itemsResult as $res) { foreach ($itemsResult as $res) {