From 0ad12416cbee536acb34fc147513f36d8aa86912 Mon Sep 17 00:00:00 2001 From: matx132 Date: Wed, 26 Jul 2023 12:27:46 +0200 Subject: [PATCH 01/11] IBX-5905: Added content type identifier to ContentInfo --- .../Persistence/Content/ContentInfo.php | 7 + .../Content/Gateway/DoctrineDatabase.php | 12 +- .../Gateway/DoctrineDatabase/QueryBuilder.php | 28 +- src/lib/Persistence/Legacy/Content/Mapper.php | 9 +- .../Content/Gateway/DoctrineDatabase.php | 14 +- .../Content/Gateway/DoctrineDatabaseTest.php | 27 +- .../Legacy/Content/_fixtures/contentclass.php | 410 ++++++++++++++++++ .../_fixtures/extract_content_from_rows.php | 8 + ...ct_content_from_rows_multiple_versions.php | 4 + .../extract_content_from_rows_result.php | 1 + ...rsion_info_from_rows_multiple_versions.php | 2 + 11 files changed, 504 insertions(+), 18 deletions(-) create mode 100644 tests/lib/Persistence/Legacy/Content/_fixtures/contentclass.php diff --git a/src/contracts/Persistence/Content/ContentInfo.php b/src/contracts/Persistence/Content/ContentInfo.php index c372259571..c305457981 100644 --- a/src/contracts/Persistence/Content/ContentInfo.php +++ b/src/contracts/Persistence/Content/ContentInfo.php @@ -43,6 +43,8 @@ class ContentInfo extends ValueObject */ public $contentTypeId; + public string $contentTypeIdentifier; + /** * Section id the content is assigned to. * @@ -134,6 +136,11 @@ class ContentInfo extends ValueObject * @var bool */ public $isHidden = false; + + public function getContentIdentifier(): string + { + return $this->contentTypeIdentifier; + } } class_alias(ContentInfo::class, 'eZ\Publish\SPI\Persistence\Content\ContentInfo'); diff --git a/src/lib/Persistence/Legacy/Content/Gateway/DoctrineDatabase.php b/src/lib/Persistence/Legacy/Content/Gateway/DoctrineDatabase.php index 3931637596..663c9184dc 100644 --- a/src/lib/Persistence/Legacy/Content/Gateway/DoctrineDatabase.php +++ b/src/lib/Persistence/Legacy/Content/Gateway/DoctrineDatabase.php @@ -769,7 +769,8 @@ private function internalLoadContent( 'a.data_text AS ezcontentobject_attribute_data_text', 'a.sort_key_int AS ezcontentobject_attribute_sort_key_int', 'a.sort_key_string AS ezcontentobject_attribute_sort_key_string', - 't.main_node_id AS ezcontentobject_tree_main_node_id' + 't.main_node_id AS ezcontentobject_tree_main_node_id', + 'cc.identifier AS ezcontentclass_identifier', ) ->from('ezcontentobject', 'c') ->innerJoin( @@ -798,6 +799,15 @@ private function internalLoadContent( $expr->eq('c.id', 't.contentobject_id'), $expr->eq('t.node_id', 't.main_node_id') ) + ) + ->leftJoin( + 'c', + 'ezcontentclass', + 'cc', + $expr->and( + $expr->eq('c.contentclass_id', 'cc.id'), + $expr->eq('cc.version', 0) + ) ); $queryBuilder->where( diff --git a/src/lib/Persistence/Legacy/Content/Gateway/DoctrineDatabase/QueryBuilder.php b/src/lib/Persistence/Legacy/Content/Gateway/DoctrineDatabase/QueryBuilder.php index cdc28887e9..3035d5fa62 100644 --- a/src/lib/Persistence/Legacy/Content/Gateway/DoctrineDatabase/QueryBuilder.php +++ b/src/lib/Persistence/Legacy/Content/Gateway/DoctrineDatabase/QueryBuilder.php @@ -113,13 +113,26 @@ public function createLoadContentInfoQueryBuilder( } $queryBuilder - ->select('c.*', 't.main_node_id AS ezcontentobject_tree_main_node_id') + ->select( + 'c.*', + 't.main_node_id AS ezcontentobject_tree_main_node_id', + 'cc.identifier AS ezcontentclass_identifier' + ) ->from(Gateway::CONTENT_ITEM_TABLE, 'c') ->leftJoin( 'c', 'ezcontentobject_tree', 't', $joinCondition + ) + ->leftJoin( + 'c', + 'ezcontentclass', + 'cc', + $expr->and( + $expr->eq('c.contentclass_id', 'cc.id'), + $expr->eq('cc.version', 0) + ) ); return $queryBuilder; @@ -163,7 +176,9 @@ public function createVersionInfoFindQueryBuilder(): DoctrineQueryBuilder 'c.status AS ezcontentobject_status', 'c.name AS ezcontentobject_name', 'c.language_mask AS ezcontentobject_language_mask', - 'c.is_hidden AS ezcontentobject_is_hidden' + 'c.is_hidden AS ezcontentobject_is_hidden', + // Content class + 'cc.identifier AS ezcontentclass_identifier' ) ->from(Gateway::CONTENT_VERSION_TABLE, 'v') ->innerJoin( @@ -180,6 +195,15 @@ public function createVersionInfoFindQueryBuilder(): DoctrineQueryBuilder $expr->eq('t.contentobject_id', 'v.contentobject_id'), $expr->eq('t.main_node_id', 't.node_id') ) + ) + ->leftJoin( + 'c', + 'ezcontentclass', + 'cc', + $expr->and( + $expr->eq('c.contentclass_id', 'cc.id'), + $expr->eq('cc.version', 0) + ) ); return $query; diff --git a/src/lib/Persistence/Legacy/Content/Mapper.php b/src/lib/Persistence/Legacy/Content/Mapper.php index 64456bd400..12d2c08a42 100644 --- a/src/lib/Persistence/Legacy/Content/Mapper.php +++ b/src/lib/Persistence/Legacy/Content/Mapper.php @@ -379,12 +379,17 @@ private function loadCachedVersionFieldDefinitionsPerLanguage( * * @return \Ibexa\Contracts\Core\Persistence\Content\ContentInfo */ - public function extractContentInfoFromRow(array $row, $prefix = '', $treePrefix = 'ezcontentobject_tree_') - { + public function extractContentInfoFromRow( + array $row, + $prefix = '', + $treePrefix = 'ezcontentobject_tree_', + $contentClassPrefix = 'ezcontentclass_' + ) { $contentInfo = new ContentInfo(); $contentInfo->id = (int)$row["{$prefix}id"]; $contentInfo->name = (string)$row["{$prefix}name"]; $contentInfo->contentTypeId = (int)$row["{$prefix}contentclass_id"]; + $contentInfo->contentTypeIdentifier = $row["{$contentClassPrefix}identifier"]; $contentInfo->sectionId = (int)$row["{$prefix}section_id"]; $contentInfo->currentVersionNo = (int)$row["{$prefix}current_version"]; $contentInfo->ownerId = (int)$row["{$prefix}owner_id"]; diff --git a/src/lib/Search/Legacy/Content/Gateway/DoctrineDatabase.php b/src/lib/Search/Legacy/Content/Gateway/DoctrineDatabase.php index 1fb0688ca2..7f8f2fd525 100644 --- a/src/lib/Search/Legacy/Content/Gateway/DoctrineDatabase.php +++ b/src/lib/Search/Legacy/Content/Gateway/DoctrineDatabase.php @@ -216,8 +216,9 @@ private function getContentInfoList( array $languageFilter ): array { $query = $this->connection->createQueryBuilder(); + $expr = $query->expr(); $query->select( - 'DISTINCT c.*, main_tree.main_node_id AS main_tree_main_node_id', + 'DISTINCT c.*, main_tree.main_node_id AS main_tree_main_node_id, cc.identifier AS ezcontentclass_identifier', ); if ($sort !== null) { @@ -236,10 +237,19 @@ private function getContentInfoList( 'c', LocationGateway::CONTENT_TREE_TABLE, 'main_tree', - $query->expr()->andX( + $expr->andX( 'main_tree.contentobject_id = c.id', 'main_tree.main_node_id = main_tree.node_id' ) + ) + ->leftJoin( + 'c', + 'ezcontentclass', + 'cc', + $expr->and( + $expr->eq('c.contentclass_id', 'cc.id'), + $expr->eq('cc.version', 0) + ) ); if ($sort !== null) { diff --git a/tests/lib/Persistence/Legacy/Content/Gateway/DoctrineDatabaseTest.php b/tests/lib/Persistence/Legacy/Content/Gateway/DoctrineDatabaseTest.php index 8d8a004560..1975202b91 100644 --- a/tests/lib/Persistence/Legacy/Content/Gateway/DoctrineDatabaseTest.php +++ b/tests/lib/Persistence/Legacy/Content/Gateway/DoctrineDatabaseTest.php @@ -608,7 +608,7 @@ public function testListVersions(): void foreach ($res as $row) { $this->assertCount( - 23, + 24, $row ); } @@ -651,7 +651,7 @@ public function testListVersionsForUser() foreach ($res as $row) { $this->assertCount( - 23, + 24, $row ); } @@ -698,9 +698,7 @@ public function testLoadWithAllTranslations() public function testCreateFixtureForMapperExtractContentFromRowsMultipleVersions() { - $this->insertDatabaseFixture( - __DIR__ . '/../_fixtures/contentobjects.php' - ); + $this->insertContentToDatabase(); $gateway = $this->getDatabaseGateway(); @@ -721,9 +719,7 @@ public function testCreateFixtureForMapperExtractContentFromRowsMultipleVersions public function testCreateFixtureForMapperExtractContentFromRows() { - $this->insertDatabaseFixture( - __DIR__ . '/../_fixtures/contentobjects.php' - ); + $this->insertContentToDatabase(); $gateway = $this->getDatabaseGateway(); @@ -1667,9 +1663,7 @@ public function testUpdateContentRemoveAlwaysAvailableFlagMultilingual(): void */ public function testLoadVersionInfo(): void { - $this->insertDatabaseFixture( - __DIR__ . '/../_fixtures/contentobjects.php' - ); + $this->insertContentToDatabase(); $gateway = $this->getDatabaseGateway(); @@ -1989,6 +1983,17 @@ private function assertContentVersionAttributesLanguages( ->orderBy('id') ); } + + private function insertContentToDatabase(): void + { + $this->insertDatabaseFixture( + __DIR__ . '/../_fixtures/contentclass.php' + ); + + $this->insertDatabaseFixture( + __DIR__ . '/../_fixtures/contentobjects.php' + ); + } } class_alias(DoctrineDatabaseTest::class, 'eZ\Publish\Core\Persistence\Legacy\Tests\Content\Gateway\DoctrineDatabaseTest'); diff --git a/tests/lib/Persistence/Legacy/Content/_fixtures/contentclass.php b/tests/lib/Persistence/Legacy/Content/_fixtures/contentclass.php new file mode 100644 index 0000000000..7dc4005b62 --- /dev/null +++ b/tests/lib/Persistence/Legacy/Content/_fixtures/contentclass.php @@ -0,0 +1,410 @@ + [ + 0 => [ + 'id' => 1, + 'version' => '0', + 'always_available' => 0, + 'contentobject_name' => '', + 'created' => '1033917596', + 'creator_id' => 14, + 'identifier' => 'folder', + 'initial_language_id' => 2, + 'is_container' => true, + 'language_mask' => 2, + 'modified' => '1311154215', + 'modifier_id' => 14, + 'remote_id' => '5fcdb3fb687dd6dcf8c94bc84e8bd1b2', + 'serialized_description_list' => 'a:0:{}', + 'serialized_name_list' => 'a:1:{s:6:"eng-GB";s:6:"Folder";}', + 'sort_field' => 1, + 'sort_order' => 1, + 'url_alias_name' => null, + ], + 1 => [ + 'id' => 3, + 'version' => '0', + 'always_available' => 1, + 'contentobject_name' => '', + 'created' => '1033917896', + 'creator_id' => 14, + 'identifier' => 'user_group', + 'initial_language_id' => 2, + 'is_container' => true, + 'language_mask' => 2, + 'modified' => '1311154815', + 'modifier_id' => 14, + 'remote_id' => '0f2622aad22267e195c8e76b05c25e29', + 'serialized_description_list' => 'a:0:{}', + 'serialized_name_list' => 'a:2:{s:6:"eng-GB";s:10:"User group";s:16:"always-available";s:6:"eng-GB";}', + 'sort_field' => 1, + 'sort_order' => 1, + 'url_alias_name' => null, + ], + 2 => [ + 'id' => 4, + 'version' => '0', + 'always_available' => 0, + 'contentobject_name' => ' ', + 'created' => '1033918596', + 'creator_id' => 14, + 'identifier' => 'user', + 'initial_language_id' => 2, + 'is_container' => false, + 'language_mask' => 2, + 'modified' => '1311184215', + 'modifier_id' => 14, + 'remote_id' => '40cca73dac5cec06af9e2f3e1d79f296', + 'serialized_description_list' => 'a:0:{}', + 'serialized_name_list' => 'a:2:{s:6:"eng-GB";s:4:"User";s:16:"always-available";s:6:"eng-GB";}', + 'sort_field' => 1, + 'sort_order' => 1, + 'url_alias_name' => null, + ], + 3 => [ + 'id' => 14, + 'version' => '0', + 'always_available' => 0, + 'contentobject_name' => '', + 'created' => '1033917896', + 'creator_id' => 14, + 'identifier' => 'file', + 'initial_language_id' => 2, + 'is_container' => false, + 'language_mask' => 2, + 'modified' => '1311158215', + 'modifier_id' => 14, + 'remote_id' => '808394adba21c655214c18aeab95fc27', + 'serialized_description_list' => 'a:0:{}', + 'serialized_name_list' => 'a:2:{s:6:"eng-GB";s:4:"File";s:16:"always-available";s:6:"eng-GB";}', + 'sort_field' => 1, + 'sort_order' => 1, + 'url_alias_name' => null, + ], + 4 => [ + 'id' => 15, + 'version' => 1, + 'always_available' => 0, + 'contentobject_name' => null, + 'created' => '1033917996', + 'creator_id' => 14, + 'identifier' => 'landing_page', + 'initial_language_id' => 2, + 'is_container' => true, + 'language_mask' => 2, + 'modified' => '1311154915', + 'modifier_id' => 14, + 'remote_id' => '3f0f42fe0d5ad444ffbc4fefe92a3f06', + 'serialized_description_list' => 'a:0:{}', + 'serialized_name_list' => 'a:1:{s:6:"eng-GB";s:12:"Landing page";}', + 'sort_field' => 1, + 'sort_order' => 1, + 'url_alias_name' => null, + ], + 5 => [ + 'id' => 16, + 'version' => '0', + 'always_available' => 0, + 'contentobject_name' => '<name>', + 'created' => '1033915596', + 'creator_id' => 14, + 'identifier' => 'article', + 'initial_language_id' => 2, + 'is_container' => true, + 'language_mask' => 2, + 'modified' => '1311154255', + 'modifier_id' => 14, + 'remote_id' => 'af4e6d7bf4ed96fc77eb5839e8c2ceb8', + 'serialized_description_list' => 'a:0:{}', + 'serialized_name_list' => 'a:1:{s:6:"eng-GB";s:7:"Article";}', + 'sort_field' => 1, + 'sort_order' => 1, + 'url_alias_name' => null, + ], + 6 => [ + 'id' => 18, + 'version' => '0', + 'always_available' => 0, + 'contentobject_name' => '<name>', + 'created' => '1033917536', + 'creator_id' => 14, + 'identifier' => 'tag', + 'initial_language_id' => 2, + 'is_container' => true, + 'language_mask' => 2, + 'modified' => '13111542635', + 'modifier_id' => 14, + 'remote_id' => '9f4373927b4f2d9109aa5b97dc3fbeb6', + 'serialized_description_list' => 'a:0:{}', + 'serialized_name_list' => 'a:1:{s:6:"eng-GB";s:3:"Tag";}', + 'sort_field' => 1, + 'sort_order' => 1, + 'url_alias_name' => null, + ], + 7 => [ + 'id' => 20, + 'version' => '0', + 'always_available' => 0, + 'contentobject_name' => '<name>', + 'created' => '1033917556', + 'creator_id' => 14, + 'identifier' => 'product_category_tag', + 'initial_language_id' => 2, + 'is_container' => true, + 'language_mask' => 2, + 'modified' => '1311154255', + 'modifier_id' => 14, + 'remote_id' => 'f64c05d15c81d9ed239c997c7ef7f088', + 'serialized_description_list' => 'a:0:{}', + 'serialized_name_list' => 'a:1:{s:6:"eng-GB";s:6:"Folder";}', + 'sort_field' => 1, + 'sort_order' => 1, + 'url_alias_name' => null, + ], + 8 => [ + 'id' => 21, + 'version' => '0', + 'always_available' => 0, + 'contentobject_name' => '<name>', + 'created' => '1033917796', + 'creator_id' => 14, + 'identifier' => 'customer', + 'initial_language_id' => 2, + 'is_container' => false, + 'language_mask' => 2, + 'modified' => '1311154415', + 'modifier_id' => 14, + 'remote_id' => '14883b7cf325724dcb7cc279a0455a7b', + 'serialized_description_list' => 'a:0:{}', + 'serialized_name_list' => 'a:1:{s:6:"eng-GB";s:8:"Customer";}', + 'sort_field' => 1, + 'sort_order' => 1, + 'url_alias_name' => null, + ], + 9 => [ + 'id' => 22, + 'version' => '0', + 'always_available' => 1, + 'contentobject_name' => '<name>', + 'created' => '1033917696', + 'creator_id' => 14, + 'identifier' => 'member', + 'initial_language_id' => 2, + 'is_container' => false, + 'language_mask' => 2, + 'modified' => '1311154225', + 'modifier_id' => 14, + 'remote_id' => 'e8b9d33d5fd346e3d2787fdf0a75ab1a', + 'serialized_description_list' => 'a:0:{}', + 'serialized_name_list' => 'a:1:{s:6:"eng-GB";s:6:"Member";}', + 'sort_field' => 1, + 'sort_order' => 1, + 'url_alias_name' => null, + ], + 10 => [ + 'id' => 23, + 'version' => '0', + 'always_available' => 0, + 'contentobject_name' => '<name>', + 'created' => '1033917096', + 'creator_id' => 14, + 'identifier' => 'company', + 'initial_language_id' => 2, + 'is_container' => false, + 'language_mask' => 2, + 'modified' => '1311154015', + 'modifier_id' => 14, + 'remote_id' => 'd1bc6331c8df0a5efb4d24d8bd5862da', + 'serialized_description_list' => 'a:0:{}', + 'serialized_name_list' => 'a:1:{s:6:"eng-GB";s:7:"Company";}', + 'sort_field' => 1, + 'sort_order' => 1, + 'url_alias_name' => null, + ], + 11 => [ + 'id' => 24, + 'version' => '0', + 'always_available' => 0, + 'contentobject_name' => '<name>', + 'created' => '1033917506', + 'creator_id' => 14, + 'identifier' => 'shipping_address', + 'initial_language_id' => 2, + 'is_container' => true, + 'language_mask' => 2, + 'modified' => '1311154205', + 'modifier_id' => 14, + 'remote_id' => '4180aa6f06a49835fbb9e380a30d9fe5', + 'serialized_description_list' => 'a:0:{}', + 'serialized_name_list' => 'a:1:{s:6:"eng-GB";s:16:"Shipping address";}', + 'sort_field' => 1, + 'sort_order' => 1, + 'url_alias_name' => null, + ], + 12 => [ + 'id' => 25, + 'version' => '0', + 'always_available' => 0, + 'contentobject_name' => '<name>', + 'created' => '1033917590', + 'creator_id' => 14, + 'identifier' => 'customer_portal', + 'initial_language_id' => 2, + 'is_container' => true, + 'language_mask' => 2, + 'modified' => '1311154210', + 'modifier_id' => 14, + 'remote_id' => '7fb809789d8a799f24d1205c284555df', + 'serialized_description_list' => 'a:0:{}', + 'serialized_name_list' => 'a:1:{s:6:"eng-GB";s:15:"Customer Portal";}', + 'sort_field' => 1, + 'sort_order' => 1, + 'url_alias_name' => null, + ], + 13 => [ + 'id' => 26, + 'version' => '0', + 'always_available' => 1, + 'contentobject_name' => '<name>', + 'created' => '1033917600', + 'creator_id' => 14, + 'identifier' => 'new_product_type', + 'initial_language_id' => 2, + 'is_container' => true, + 'language_mask' => 2, + 'modified' => '1311154220', + 'modifier_id' => 14, + 'remote_id' => '826779f2aef696943a9e0c1d55bb881d', + 'serialized_description_list' => 'a:0:{}', + 'serialized_name_list' => 'a:1:{s:6:"eng-GB";s:16:"New product type";}', + 'sort_field' => 1, + 'sort_order' => 1, + 'url_alias_name' => null, + ], + 14 => [ + 'id' => 30, + 'version' => '0', + 'always_available' => 0, + 'contentobject_name' => '<tag_name>', + 'created' => '1033917599', + 'creator_id' => 14, + 'identifier' => 'new_tag', + 'initial_language_id' => 2, + 'is_container' => true, + 'language_mask' => 2, + 'modified' => '1311154219', + 'modifier_id' => 14, + 'remote_id' => '5ea8fae70c53f76ca83b23cce8a5400a', + 'serialized_description_list' => 'a:0:{}', + 'serialized_name_list' => 'a:1:{s:6:"eng-GB";s:7:"New Tag";}', + 'sort_field' => 1, + 'sort_order' => 1, + 'url_alias_name' => null, + ], + 15 => [ + 'id' => 35, + 'version' => '0', + 'always_available' => 0, + 'contentobject_name' => '<name>', + 'created' => '1033917598', + 'creator_id' => 14, + 'identifier' => 'old_tag', + 'initial_language_id' => 2, + 'is_container' => false, + 'language_mask' => 2, + 'modified' => '1311154218', + 'modifier_id' => 14, + 'remote_id' => '10820975ade1fe98bc93372c4263f0fb', + 'serialized_description_list' => 'a:0:{}', + 'serialized_name_list' => 'a:1:{s:6:"eng-GB";s:7:"Old Tag";}', + 'sort_field' => 1, + 'sort_order' => 1, + 'url_alias_name' => null, + ], + 16 => [ + 'id' => 37, + 'version' => '0', + 'always_available' => 0, + 'contentobject_name' => '<name>', + 'created' => '1033917597', + 'creator_id' => 14, + 'identifier' => 'page', + 'initial_language_id' => 2, + 'is_container' => true, + 'language_mask' => 2, + 'modified' => '1311154217', + 'modifier_id' => 14, + 'remote_id' => 'ac76f2a4caea8329c11126957941e2e0', + 'serialized_description_list' => 'a:0:{}', + 'serialized_name_list' => 'a:1:{s:6:"eng-GB";s:4:"Page";}', + 'sort_field' => 1, + 'sort_order' => 1, + 'url_alias_name' => null, + ], + 17 => [ + 'id' => 38, + 'version' => '0', + 'always_available' => 1, + 'contentobject_name' => '<name>', + 'created' => '1033917591', + 'creator_id' => 14, + 'identifier' => 'lottery', + 'initial_language_id' => 2, + 'is_container' => false, + 'language_mask' => 2, + 'modified' => '1311154211', + 'modifier_id' => 14, + 'remote_id' => '0e9228de7bd25b334c138e2fb143db77', + 'serialized_description_list' => 'a:0:{}', + 'serialized_name_list' => 'a:1:{s:6:"eng-GB";s:7:"Lottery";}', + 'sort_field' => 1, + 'sort_order' => 1, + 'url_alias_name' => null, + ], + 18 => [ + 'id' => 41, + 'version' => '0', + 'always_available' => 0, + 'contentobject_name' => '<name>', + 'created' => '1033917594', + 'creator_id' => 14, + 'identifier' => 'test', + 'initial_language_id' => 2, + 'is_container' => false, + 'language_mask' => 2, + 'modified' => '1311154213', + 'modifier_id' => 14, + 'remote_id' => '513ea82647fef3e8401a985d2743884b', + 'serialized_description_list' => 'a:0:{}', + 'serialized_name_list' => 'a:1:{s:6:"eng-GB";s:4:"Test";}', + 'sort_field' => 1, + 'sort_order' => 1, + 'url_alias_name' => null, + ], + 19 => [ + 'id' => 42, + 'version' => '0', + 'always_available' => 1, + 'contentobject_name' => '<name>', + 'created' => '1033917595', + 'creator_id' => 14, + 'identifier' => 'news', + 'initial_language_id' => 2, + 'is_container' => true, + 'language_mask' => 2, + 'modified' => '1311154214', + 'modifier_id' => 14, + 'remote_id' => 'faeb8e023bcba08bac3439732d49ab40', + 'serialized_description_list' => 'a:0:{}', + 'serialized_name_list' => 'a:1:{s:6:"eng-GB";s:4:"News";}', + 'sort_field' => 1, + 'sort_order' => 1, + 'url_alias_name' => null, + ], + ], +]; diff --git a/tests/lib/Persistence/Legacy/Content/_fixtures/extract_content_from_rows.php b/tests/lib/Persistence/Legacy/Content/_fixtures/extract_content_from_rows.php index 0e05b81b1d..d5979a3dbe 100644 --- a/tests/lib/Persistence/Legacy/Content/_fixtures/extract_content_from_rows.php +++ b/tests/lib/Persistence/Legacy/Content/_fixtures/extract_content_from_rows.php @@ -38,6 +38,7 @@ 'ezcontentobject_attribute_sort_key_int' => 0, 'ezcontentobject_attribute_sort_key_string' => 'new test article (2)', 'ezcontentobject_tree_main_node_id' => 228, + 'ezcontentclass_identifier' => 'article', ], 1 => [ 'ezcontentobject_id' => 226, @@ -72,6 +73,7 @@ 'ezcontentobject_attribute_sort_key_string' => 'something', 'ezcontentobject_tree_main_node_id' => 228, 'ezcontentobject_is_hidden' => 0, + 'ezcontentclass_identifier' => 'article', ], 2 => [ 'ezcontentobject_id' => 226, @@ -108,6 +110,7 @@ 'ezcontentobject_attribute_sort_key_string' => '', 'ezcontentobject_tree_main_node_id' => 228, 'ezcontentobject_is_hidden' => 0, + 'ezcontentclass_identifier' => 'article', ], 3 => [ 'ezcontentobject_id' => 226, @@ -142,6 +145,7 @@ 'ezcontentobject_attribute_sort_key_string' => '', 'ezcontentobject_tree_main_node_id' => 228, 'ezcontentobject_is_hidden' => 0, + 'ezcontentclass_identifier' => 'article', ], 4 => [ 'ezcontentobject_id' => 226, @@ -178,6 +182,7 @@ 'ezcontentobject_attribute_sort_key_string' => '', 'ezcontentobject_tree_main_node_id' => 228, 'ezcontentobject_is_hidden' => 0, + 'ezcontentclass_identifier' => 'article', ], 5 => [ 'ezcontentobject_id' => 226, @@ -212,6 +217,7 @@ 'ezcontentobject_attribute_sort_key_string' => '', 'ezcontentobject_tree_main_node_id' => 228, 'ezcontentobject_is_hidden' => 0, + 'ezcontentclass_identifier' => 'article', ], 6 => [ 'ezcontentobject_id' => 226, @@ -246,6 +252,7 @@ 'ezcontentobject_attribute_sort_key_string' => '', 'ezcontentobject_tree_main_node_id' => 228, 'ezcontentobject_is_hidden' => 0, + 'ezcontentclass_identifier' => 'article', ], 7 => [ 'ezcontentobject_id' => 226, @@ -314,5 +321,6 @@ 'ezcontentobject_attribute_sort_key_string' => '', 'ezcontentobject_tree_main_node_id' => 228, 'ezcontentobject_is_hidden' => 0, + 'ezcontentclass_identifier' => 'article', ], ]; diff --git a/tests/lib/Persistence/Legacy/Content/_fixtures/extract_content_from_rows_multiple_versions.php b/tests/lib/Persistence/Legacy/Content/_fixtures/extract_content_from_rows_multiple_versions.php index 7acb59c8fc..632262fa9e 100644 --- a/tests/lib/Persistence/Legacy/Content/_fixtures/extract_content_from_rows_multiple_versions.php +++ b/tests/lib/Persistence/Legacy/Content/_fixtures/extract_content_from_rows_multiple_versions.php @@ -38,6 +38,7 @@ 'ezcontentobject_attribute_sort_key_string' => '', 'ezcontentobject_tree_main_node_id' => '12', 'ezcontentobject_is_hidden' => '0', + 'ezcontentclass_identifier' => 'user_group', ], 1 => [ 'ezcontentobject_id' => '11', @@ -72,6 +73,7 @@ 'ezcontentobject_attribute_sort_key_string' => '', 'ezcontentobject_tree_main_node_id' => '12', 'ezcontentobject_is_hidden' => '0', + 'ezcontentclass_identifier' => 'user_group', ], 2 => [ 'ezcontentobject_id' => '11', @@ -106,6 +108,7 @@ 'ezcontentobject_attribute_sort_key_string' => 'members', 'ezcontentobject_tree_main_node_id' => '12', 'ezcontentobject_is_hidden' => '0', + 'ezcontentclass_identifier' => 'user_group', ], 3 => [ 'ezcontentobject_id' => '11', @@ -140,5 +143,6 @@ 'ezcontentobject_attribute_sort_key_string' => '', 'ezcontentobject_tree_main_node_id' => '12', 'ezcontentobject_is_hidden' => '0', + 'ezcontentclass_identifier' => 'user_group', ], ]; diff --git a/tests/lib/Persistence/Legacy/Content/_fixtures/extract_content_from_rows_result.php b/tests/lib/Persistence/Legacy/Content/_fixtures/extract_content_from_rows_result.php index 03f9783faa..08588d1b01 100644 --- a/tests/lib/Persistence/Legacy/Content/_fixtures/extract_content_from_rows_result.php +++ b/tests/lib/Persistence/Legacy/Content/_fixtures/extract_content_from_rows_result.php @@ -40,6 +40,7 @@ $versionInfo->contentInfo->name = 'Something'; $versionInfo->contentInfo->mainLocationId = 228; $versionInfo->contentInfo->status = 1; +$versionInfo->contentInfo->contentTypeIdentifier = 'article'; $content->versionInfo = $versionInfo; diff --git a/tests/lib/Persistence/Legacy/Content/_fixtures/extract_version_info_from_rows_multiple_versions.php b/tests/lib/Persistence/Legacy/Content/_fixtures/extract_version_info_from_rows_multiple_versions.php index bfe811f9ae..392413e8db 100644 --- a/tests/lib/Persistence/Legacy/Content/_fixtures/extract_version_info_from_rows_multiple_versions.php +++ b/tests/lib/Persistence/Legacy/Content/_fixtures/extract_version_info_from_rows_multiple_versions.php @@ -29,6 +29,7 @@ 'ezcontentobject_language_mask' => '3', 'ezcontentobject_is_hidden' => '0', 'ezcontentobject_version_contentobject_id' => '11', + 'ezcontentclass_identifier' => 'user_group', ], 1 => [ 'ezcontentobject_version_id' => '674', @@ -54,5 +55,6 @@ 'ezcontentobject_language_mask' => '3', 'ezcontentobject_is_hidden' => '0', 'ezcontentobject_version_contentobject_id' => '11', + 'ezcontentclass_identifier' => 'user_group', ], ]; From 5d33001b7ae0c6495256eec212cba62e0e1af815 Mon Sep 17 00:00:00 2001 From: matx132 <mateusz@mateuszdebinski.pl> Date: Thu, 27 Jul 2023 11:22:45 +0200 Subject: [PATCH 02/11] Changed naming & query building, tests adapted to changes --- .../Persistence/Content/ContentInfo.php | 2 +- .../Content/Gateway/DoctrineDatabase.php | 17 +++---- .../Gateway/DoctrineDatabase/QueryBuilder.php | 22 +++++----- src/lib/Persistence/Legacy/Content/Mapper.php | 5 +-- .../Content/Gateway/DoctrineDatabase.php | 13 +++--- .../Content/Gateway/DoctrineDatabaseTest.php | 40 +++++------------ ...iases_swap_multilang_cleanup_composite.php | 44 +++++++++++++++++++ .../urlaliases_swap_multilang_diff.php | 44 +++++++++++++++++++ .../urlaliases_swap_multilang_diff_simple.php | 44 +++++++++++++++++++ ...p_multilang_path_identification_string.php | 44 +++++++++++++++++++ .../urlaliases_swap_multilang_simple.php | 44 +++++++++++++++++++ ...liases_swap_path_identification_string.php | 44 +++++++++++++++++++ ...laliases_swap_reusing_external_history.php | 44 +++++++++++++++++++ .../_fixtures/urlaliases_swap_reusing_nop.php | 44 +++++++++++++++++++ .../urlaliases_swap_siblings_same_name.php | 44 +++++++++++++++++++ ...ases_swap_siblings_same_name_multilang.php | 44 +++++++++++++++++++ .../urlaliases_swap_siblings_simple.php | 44 +++++++++++++++++++ ...rlaliases_swap_siblings_simple_history.php | 44 +++++++++++++++++++ .../_fixtures/urlaliases_swap_simple.php | 44 +++++++++++++++++++ .../urlaliases_swap_simple_conflict.php | 44 +++++++++++++++++++ .../urlaliases_swap_simple_history.php | 44 +++++++++++++++++++ ...ct_content_from_rows_multiple_versions.php | 8 ++-- ...rsion_info_from_rows_multiple_versions.php | 4 +- .../ValueObject/ContentInfoTest.php | 21 +++++++++ 24 files changed, 728 insertions(+), 64 deletions(-) create mode 100644 tests/lib/Persistence/ValueObject/ContentInfoTest.php diff --git a/src/contracts/Persistence/Content/ContentInfo.php b/src/contracts/Persistence/Content/ContentInfo.php index c305457981..884a3bc28a 100644 --- a/src/contracts/Persistence/Content/ContentInfo.php +++ b/src/contracts/Persistence/Content/ContentInfo.php @@ -137,7 +137,7 @@ class ContentInfo extends ValueObject */ public $isHidden = false; - public function getContentIdentifier(): string + public function getContentTypeIdentifier(): string { return $this->contentTypeIdentifier; } diff --git a/src/lib/Persistence/Legacy/Content/Gateway/DoctrineDatabase.php b/src/lib/Persistence/Legacy/Content/Gateway/DoctrineDatabase.php index 663c9184dc..992e684afe 100644 --- a/src/lib/Persistence/Legacy/Content/Gateway/DoctrineDatabase.php +++ b/src/lib/Persistence/Legacy/Content/Gateway/DoctrineDatabase.php @@ -20,6 +20,7 @@ use Ibexa\Contracts\Core\Persistence\Content\Language\Handler as LanguageHandler; use Ibexa\Contracts\Core\Persistence\Content\MetadataUpdateStruct; use Ibexa\Contracts\Core\Persistence\Content\Relation\CreateStruct as RelationCreateStruct; +use Ibexa\Contracts\Core\Persistence\Content\Type; use Ibexa\Contracts\Core\Persistence\Content\UpdateStruct; use Ibexa\Contracts\Core\Persistence\Content\VersionInfo; use Ibexa\Contracts\Core\Repository\Values\Content\Relation; @@ -770,14 +771,14 @@ private function internalLoadContent( 'a.sort_key_int AS ezcontentobject_attribute_sort_key_int', 'a.sort_key_string AS ezcontentobject_attribute_sort_key_string', 't.main_node_id AS ezcontentobject_tree_main_node_id', - 'cc.identifier AS ezcontentclass_identifier', + 'ct.identifier AS content_type_identifier', ) ->from('ezcontentobject', 'c') ->innerJoin( 'c', 'ezcontentobject_version', 'v', - $expr->andX( + $expr->and( $expr->eq('c.id', 'v.contentobject_id'), $expr->eq('v.version', $version ?? 'c.current_version') ) @@ -786,7 +787,7 @@ private function internalLoadContent( 'v', 'ezcontentobject_attribute', 'a', - $expr->andX( + $expr->and( $expr->eq('v.contentobject_id', 'a.contentobject_id'), $expr->eq('v.version', 'a.version') ) @@ -795,18 +796,18 @@ private function internalLoadContent( 'c', 'ezcontentobject_tree', 't', - $expr->andX( + $expr->and( $expr->eq('c.id', 't.contentobject_id'), $expr->eq('t.node_id', 't.main_node_id') ) ) - ->leftJoin( + ->innerJoin( 'c', 'ezcontentclass', - 'cc', + 'ct', $expr->and( - $expr->eq('c.contentclass_id', 'cc.id'), - $expr->eq('cc.version', 0) + $expr->eq('c.contentclass_id', 'ct.id'), + $expr->eq('ct.version', Type::STATUS_DEFINED) ) ); diff --git a/src/lib/Persistence/Legacy/Content/Gateway/DoctrineDatabase/QueryBuilder.php b/src/lib/Persistence/Legacy/Content/Gateway/DoctrineDatabase/QueryBuilder.php index 3035d5fa62..4b0f60ce0c 100644 --- a/src/lib/Persistence/Legacy/Content/Gateway/DoctrineDatabase/QueryBuilder.php +++ b/src/lib/Persistence/Legacy/Content/Gateway/DoctrineDatabase/QueryBuilder.php @@ -9,6 +9,7 @@ use Doctrine\DBAL\Connection; use Doctrine\DBAL\ParameterType; use Doctrine\DBAL\Query\QueryBuilder as DoctrineQueryBuilder; +use Ibexa\Contracts\Core\Persistence\Content\Type; use Ibexa\Core\Persistence\Legacy\Content\Gateway; use function time; @@ -116,7 +117,7 @@ public function createLoadContentInfoQueryBuilder( ->select( 'c.*', 't.main_node_id AS ezcontentobject_tree_main_node_id', - 'cc.identifier AS ezcontentclass_identifier' + 'ct.identifier AS content_type_identifier' ) ->from(Gateway::CONTENT_ITEM_TABLE, 'c') ->leftJoin( @@ -125,13 +126,13 @@ public function createLoadContentInfoQueryBuilder( 't', $joinCondition ) - ->leftJoin( + ->innerJoin( 'c', 'ezcontentclass', - 'cc', + 'ct', $expr->and( - $expr->eq('c.contentclass_id', 'cc.id'), - $expr->eq('cc.version', 0) + $expr->eq('c.contentclass_id', 'ct.id'), + $expr->eq('ct.version', Type::STATUS_DEFINED) ) ); @@ -177,8 +178,7 @@ public function createVersionInfoFindQueryBuilder(): DoctrineQueryBuilder 'c.name AS ezcontentobject_name', 'c.language_mask AS ezcontentobject_language_mask', 'c.is_hidden AS ezcontentobject_is_hidden', - // Content class - 'cc.identifier AS ezcontentclass_identifier' + 'ct.identifier AS content_type_identifier' ) ->from(Gateway::CONTENT_VERSION_TABLE, 'v') ->innerJoin( @@ -196,13 +196,13 @@ public function createVersionInfoFindQueryBuilder(): DoctrineQueryBuilder $expr->eq('t.main_node_id', 't.node_id') ) ) - ->leftJoin( + ->innerJoin( 'c', 'ezcontentclass', - 'cc', + 'ct', $expr->and( - $expr->eq('c.contentclass_id', 'cc.id'), - $expr->eq('cc.version', 0) + $expr->eq('c.contentclass_id', 'ct.id'), + $expr->eq('ct.version', Type::STATUS_DEFINED) ) ); diff --git a/src/lib/Persistence/Legacy/Content/Mapper.php b/src/lib/Persistence/Legacy/Content/Mapper.php index 12d2c08a42..53d53a5e37 100644 --- a/src/lib/Persistence/Legacy/Content/Mapper.php +++ b/src/lib/Persistence/Legacy/Content/Mapper.php @@ -382,14 +382,13 @@ private function loadCachedVersionFieldDefinitionsPerLanguage( public function extractContentInfoFromRow( array $row, $prefix = '', - $treePrefix = 'ezcontentobject_tree_', - $contentClassPrefix = 'ezcontentclass_' + $treePrefix = 'ezcontentobject_tree_' ) { $contentInfo = new ContentInfo(); $contentInfo->id = (int)$row["{$prefix}id"]; $contentInfo->name = (string)$row["{$prefix}name"]; $contentInfo->contentTypeId = (int)$row["{$prefix}contentclass_id"]; - $contentInfo->contentTypeIdentifier = $row["{$contentClassPrefix}identifier"]; + $contentInfo->contentTypeIdentifier = $row['content_type_identifier']; $contentInfo->sectionId = (int)$row["{$prefix}section_id"]; $contentInfo->currentVersionNo = (int)$row["{$prefix}current_version"]; $contentInfo->ownerId = (int)$row["{$prefix}owner_id"]; diff --git a/src/lib/Search/Legacy/Content/Gateway/DoctrineDatabase.php b/src/lib/Search/Legacy/Content/Gateway/DoctrineDatabase.php index 7f8f2fd525..7e7bdefa52 100644 --- a/src/lib/Search/Legacy/Content/Gateway/DoctrineDatabase.php +++ b/src/lib/Search/Legacy/Content/Gateway/DoctrineDatabase.php @@ -12,6 +12,7 @@ use Doctrine\DBAL\Query\QueryBuilder; use Ibexa\Contracts\Core\Persistence\Content\ContentInfo; use Ibexa\Contracts\Core\Persistence\Content\Language\Handler as LanguageHandler; +use Ibexa\Contracts\Core\Persistence\Content\Type; use Ibexa\Contracts\Core\Repository\Values\Content\Query\Criterion; use Ibexa\Contracts\Core\Repository\Values\Content\VersionInfo; use Ibexa\Core\Persistence\Legacy\Content\Gateway as ContentGateway; @@ -218,7 +219,7 @@ private function getContentInfoList( $query = $this->connection->createQueryBuilder(); $expr = $query->expr(); $query->select( - 'DISTINCT c.*, main_tree.main_node_id AS main_tree_main_node_id, cc.identifier AS ezcontentclass_identifier', + 'DISTINCT c.*, main_tree.main_node_id AS main_tree_main_node_id, ct.identifier AS content_type_identifier', ); if ($sort !== null) { @@ -237,18 +238,18 @@ private function getContentInfoList( 'c', LocationGateway::CONTENT_TREE_TABLE, 'main_tree', - $expr->andX( + $expr->and( 'main_tree.contentobject_id = c.id', 'main_tree.main_node_id = main_tree.node_id' ) ) - ->leftJoin( + ->innerJoin( 'c', 'ezcontentclass', - 'cc', + 'ct', $expr->and( - $expr->eq('c.contentclass_id', 'cc.id'), - $expr->eq('cc.version', 0) + $expr->eq('c.contentclass_id', 'ct.id'), + $expr->eq('ct.version', Type::STATUS_DEFINED) ) ); diff --git a/tests/lib/Persistence/Legacy/Content/Gateway/DoctrineDatabaseTest.php b/tests/lib/Persistence/Legacy/Content/Gateway/DoctrineDatabaseTest.php index 1975202b91..d350b8bc8e 100644 --- a/tests/lib/Persistence/Legacy/Content/Gateway/DoctrineDatabaseTest.php +++ b/tests/lib/Persistence/Legacy/Content/Gateway/DoctrineDatabaseTest.php @@ -287,9 +287,7 @@ public function testUpdateContent() { $gateway = $this->getDatabaseGateway(); - $this->insertDatabaseFixture( - __DIR__ . '/../_fixtures/contentobjects.php' - ); + $this->insertContentToDatabase(); $metadataStruct = $this->getMetadataUpdateStructFixture(); @@ -594,9 +592,7 @@ public function testUpdateNonTranslatableField() public function testListVersions(): void { - $this->insertDatabaseFixture( - __DIR__ . '/../_fixtures/contentobjects.php' - ); + $this->insertContentToDatabase(); $gateway = $this->getDatabaseGateway(); $res = $gateway->listVersions(226); @@ -637,9 +633,7 @@ public function testListVersionNumbers() public function testListVersionsForUser() { - $this->insertDatabaseFixture( - __DIR__ . '/../_fixtures/contentobjects.php' - ); + $this->insertContentToDatabase(); $gateway = $this->getDatabaseGateway(); $res = $gateway->listVersionsForUser(14); @@ -676,9 +670,7 @@ public function testListVersionsForUser() public function testLoadWithAllTranslations() { - $this->insertDatabaseFixture( - __DIR__ . '/../_fixtures/contentobjects.php' - ); + $this->insertContentToDatabase(); $gateway = $this->getDatabaseGateway(); $res = $gateway->load(226, 2); @@ -737,9 +729,7 @@ public function testCreateFixtureForMapperExtractContentFromRows() public function testLoadWithSingleTranslation() { - $this->insertDatabaseFixture( - __DIR__ . '/../_fixtures/contentobjects.php' - ); + $this->insertContentToDatabase(); $gateway = $this->getDatabaseGateway(); $res = $gateway->load(226, 2, [self::ENG_GB]); @@ -1430,9 +1420,7 @@ public function testDeleteRelationWithCompositeBitmask(): void */ public function testUpdateAlwaysAvailableFlagRemove(): void { - $this->insertDatabaseFixture( - __DIR__ . '/../_fixtures/contentobjects.php' - ); + $this->insertContentToDatabase(); $gateway = $this->getDatabaseGateway(); $gateway->updateAlwaysAvailableFlag(103, false); @@ -1496,9 +1484,7 @@ public function testUpdateAlwaysAvailableFlagRemove(): void */ public function testUpdateAlwaysAvailableFlagAdd(): void { - $this->insertDatabaseFixture( - __DIR__ . '/../_fixtures/contentobjects.php' - ); + $this->insertContentToDatabase(); $gateway = $this->getDatabaseGateway(); $contentId = 102; @@ -1566,9 +1552,7 @@ public function testUpdateAlwaysAvailableFlagAdd(): void */ public function testUpdateContentAddAlwaysAvailableFlagMultilingual(): void { - $this->insertDatabaseFixture( - __DIR__ . '/../_fixtures/contentobjects_multilingual.php' - ); + $this->insertContentToDatabase('contentobjects_multilingual.php'); $gateway = $this->getDatabaseGateway(); $contentMetadataUpdateStruct = new MetadataUpdateStruct( @@ -1615,9 +1599,7 @@ public function testUpdateContentAddAlwaysAvailableFlagMultilingual(): void */ public function testUpdateContentRemoveAlwaysAvailableFlagMultilingual(): void { - $this->insertDatabaseFixture( - __DIR__ . '/../_fixtures/contentobjects_multilingual.php' - ); + $this->insertContentToDatabase('contentobjects_multilingual.php'); $gateway = $this->getDatabaseGateway(); $contentMetadataUpdateStruct = new MetadataUpdateStruct( @@ -1984,14 +1966,14 @@ private function assertContentVersionAttributesLanguages( ); } - private function insertContentToDatabase(): void + private function insertContentToDatabase(string $fileName = 'contentobjects.php'): void { $this->insertDatabaseFixture( __DIR__ . '/../_fixtures/contentclass.php' ); $this->insertDatabaseFixture( - __DIR__ . '/../_fixtures/contentobjects.php' + __DIR__ . '/../_fixtures/' . $fileName ); } } diff --git a/tests/lib/Persistence/Legacy/Content/UrlAlias/_fixtures/urlaliases_swap_multilang_cleanup_composite.php b/tests/lib/Persistence/Legacy/Content/UrlAlias/_fixtures/urlaliases_swap_multilang_cleanup_composite.php index f163a68873..9d405fabb9 100644 --- a/tests/lib/Persistence/Legacy/Content/UrlAlias/_fixtures/urlaliases_swap_multilang_cleanup_composite.php +++ b/tests/lib/Persistence/Legacy/Content/UrlAlias/_fixtures/urlaliases_swap_multilang_cleanup_composite.php @@ -184,11 +184,13 @@ 'id' => 3, 'initial_language_id' => 2, 'current_version' => 1, + 'contentclass_id' => 1, ], 1 => [ 'id' => 4, 'initial_language_id' => 2, 'current_version' => 1, + 'contentclass_id' => 2, ], ], 'ezcontentobject_name' => [ @@ -223,4 +225,46 @@ 'content_translation' => 'eng-GB', ], ], + 'ezcontentclass' => [ + 0 => [ + 'id' => 1, + 'version' => '0', + 'always_available' => 0, + 'contentobject_name' => '<short_name|name>', + 'created' => '1033917596', + 'creator_id' => 14, + 'identifier' => 'folder', + 'initial_language_id' => 2, + 'is_container' => true, + 'language_mask' => 2, + 'modified' => '1311154215', + 'modifier_id' => 14, + 'remote_id' => '5fcdb3fb687dd6dcf8c94bc84e8bd1b2', + 'serialized_description_list' => 'a:0:{}', + 'serialized_name_list' => 'a:1:{s:6:"eng-GB";s:6:"Folder";}', + 'sort_field' => 1, + 'sort_order' => 1, + 'url_alias_name' => null, + ], + 1 => [ + 'id' => 2, + 'version' => '0', + 'always_available' => 1, + 'contentobject_name' => '<name>', + 'created' => '1033917896', + 'creator_id' => 14, + 'identifier' => 'user_group', + 'initial_language_id' => 2, + 'is_container' => true, + 'language_mask' => 2, + 'modified' => '1311154815', + 'modifier_id' => 14, + 'remote_id' => '0f2622aad22267e195c8e76b05c25e29', + 'serialized_description_list' => 'a:0:{}', + 'serialized_name_list' => 'a:2:{s:6:"eng-GB";s:10:"User group";s:16:"always-available";s:6:"eng-GB";}', + 'sort_field' => 1, + 'sort_order' => 1, + 'url_alias_name' => null, + ], + ], ]; diff --git a/tests/lib/Persistence/Legacy/Content/UrlAlias/_fixtures/urlaliases_swap_multilang_diff.php b/tests/lib/Persistence/Legacy/Content/UrlAlias/_fixtures/urlaliases_swap_multilang_diff.php index d465fe35e2..1831643fc9 100644 --- a/tests/lib/Persistence/Legacy/Content/UrlAlias/_fixtures/urlaliases_swap_multilang_diff.php +++ b/tests/lib/Persistence/Legacy/Content/UrlAlias/_fixtures/urlaliases_swap_multilang_diff.php @@ -184,11 +184,13 @@ 'id' => 3, 'initial_language_id' => 2, 'current_version' => 1, + 'contentclass_id' => 1, ], 1 => [ 'id' => 4, 'initial_language_id' => 2, 'current_version' => 1, + 'contentclass_id' => 2, ], ], 'ezcontentobject_name' => [ @@ -229,4 +231,46 @@ 'content_translation' => 'eng-GB', ], ], + 'ezcontentclass' => [ + 0 => [ + 'id' => 1, + 'version' => '0', + 'always_available' => 0, + 'contentobject_name' => '<short_name|name>', + 'created' => '1033917596', + 'creator_id' => 14, + 'identifier' => 'folder', + 'initial_language_id' => 2, + 'is_container' => true, + 'language_mask' => 2, + 'modified' => '1311154215', + 'modifier_id' => 14, + 'remote_id' => '5fcdb3fb687dd6dcf8c94bc84e8bd1b2', + 'serialized_description_list' => 'a:0:{}', + 'serialized_name_list' => 'a:1:{s:6:"eng-GB";s:6:"Folder";}', + 'sort_field' => 1, + 'sort_order' => 1, + 'url_alias_name' => null, + ], + 1 => [ + 'id' => 2, + 'version' => '0', + 'always_available' => 1, + 'contentobject_name' => '<name>', + 'created' => '1033917896', + 'creator_id' => 14, + 'identifier' => 'user_group', + 'initial_language_id' => 2, + 'is_container' => true, + 'language_mask' => 2, + 'modified' => '1311154815', + 'modifier_id' => 14, + 'remote_id' => '0f2622aad22267e195c8e76b05c25e29', + 'serialized_description_list' => 'a:0:{}', + 'serialized_name_list' => 'a:2:{s:6:"eng-GB";s:10:"User group";s:16:"always-available";s:6:"eng-GB";}', + 'sort_field' => 1, + 'sort_order' => 1, + 'url_alias_name' => null, + ], + ], ]; diff --git a/tests/lib/Persistence/Legacy/Content/UrlAlias/_fixtures/urlaliases_swap_multilang_diff_simple.php b/tests/lib/Persistence/Legacy/Content/UrlAlias/_fixtures/urlaliases_swap_multilang_diff_simple.php index fc98ba8f8b..b271698024 100644 --- a/tests/lib/Persistence/Legacy/Content/UrlAlias/_fixtures/urlaliases_swap_multilang_diff_simple.php +++ b/tests/lib/Persistence/Legacy/Content/UrlAlias/_fixtures/urlaliases_swap_multilang_diff_simple.php @@ -178,11 +178,13 @@ 'id' => 3, 'initial_language_id' => 2, 'current_version' => 1, + 'contentclass_id' => 1, ], 1 => [ 'id' => 4, 'initial_language_id' => 2, 'current_version' => 1, + 'contentclass_id' => 2, ], ], 'ezcontentobject_name' => [ @@ -211,4 +213,46 @@ 'content_translation' => 'eng-GB', ], ], + 'ezcontentclass' => [ + 0 => [ + 'id' => 1, + 'version' => '0', + 'always_available' => 0, + 'contentobject_name' => '<short_name|name>', + 'created' => '1033917596', + 'creator_id' => 14, + 'identifier' => 'folder', + 'initial_language_id' => 2, + 'is_container' => true, + 'language_mask' => 2, + 'modified' => '1311154215', + 'modifier_id' => 14, + 'remote_id' => '5fcdb3fb687dd6dcf8c94bc84e8bd1b2', + 'serialized_description_list' => 'a:0:{}', + 'serialized_name_list' => 'a:1:{s:6:"eng-GB";s:6:"Folder";}', + 'sort_field' => 1, + 'sort_order' => 1, + 'url_alias_name' => null, + ], + 1 => [ + 'id' => 2, + 'version' => '0', + 'always_available' => 1, + 'contentobject_name' => '<name>', + 'created' => '1033917896', + 'creator_id' => 14, + 'identifier' => 'user_group', + 'initial_language_id' => 2, + 'is_container' => true, + 'language_mask' => 2, + 'modified' => '1311154815', + 'modifier_id' => 14, + 'remote_id' => '0f2622aad22267e195c8e76b05c25e29', + 'serialized_description_list' => 'a:0:{}', + 'serialized_name_list' => 'a:2:{s:6:"eng-GB";s:10:"User group";s:16:"always-available";s:6:"eng-GB";}', + 'sort_field' => 1, + 'sort_order' => 1, + 'url_alias_name' => null, + ], + ], ]; diff --git a/tests/lib/Persistence/Legacy/Content/UrlAlias/_fixtures/urlaliases_swap_multilang_path_identification_string.php b/tests/lib/Persistence/Legacy/Content/UrlAlias/_fixtures/urlaliases_swap_multilang_path_identification_string.php index 2034a1743c..5cc2c4c7ba 100644 --- a/tests/lib/Persistence/Legacy/Content/UrlAlias/_fixtures/urlaliases_swap_multilang_path_identification_string.php +++ b/tests/lib/Persistence/Legacy/Content/UrlAlias/_fixtures/urlaliases_swap_multilang_path_identification_string.php @@ -137,11 +137,13 @@ 'id' => 2, 'initial_language_id' => 2, 'current_version' => 1, + 'contentclass_id' => 1, ], 1 => [ 'id' => 3, 'initial_language_id' => 8, 'current_version' => 1, + 'contentclass_id' => 2, ], ], 'ezcontentobject_name' => [ @@ -170,4 +172,46 @@ 'content_translation' => 'eng-GB', ], ], + 'ezcontentclass' => [ + 0 => [ + 'id' => 1, + 'version' => '0', + 'always_available' => 0, + 'contentobject_name' => '<short_name|name>', + 'created' => '1033917596', + 'creator_id' => 14, + 'identifier' => 'folder', + 'initial_language_id' => 2, + 'is_container' => true, + 'language_mask' => 2, + 'modified' => '1311154215', + 'modifier_id' => 14, + 'remote_id' => '5fcdb3fb687dd6dcf8c94bc84e8bd1b2', + 'serialized_description_list' => 'a:0:{}', + 'serialized_name_list' => 'a:1:{s:6:"eng-GB";s:6:"Folder";}', + 'sort_field' => 1, + 'sort_order' => 1, + 'url_alias_name' => null, + ], + 1 => [ + 'id' => 2, + 'version' => '0', + 'always_available' => 1, + 'contentobject_name' => '<name>', + 'created' => '1033917896', + 'creator_id' => 14, + 'identifier' => 'user_group', + 'initial_language_id' => 2, + 'is_container' => true, + 'language_mask' => 2, + 'modified' => '1311154815', + 'modifier_id' => 14, + 'remote_id' => '0f2622aad22267e195c8e76b05c25e29', + 'serialized_description_list' => 'a:0:{}', + 'serialized_name_list' => 'a:2:{s:6:"eng-GB";s:10:"User group";s:16:"always-available";s:6:"eng-GB";}', + 'sort_field' => 1, + 'sort_order' => 1, + 'url_alias_name' => null, + ], + ], ]; diff --git a/tests/lib/Persistence/Legacy/Content/UrlAlias/_fixtures/urlaliases_swap_multilang_simple.php b/tests/lib/Persistence/Legacy/Content/UrlAlias/_fixtures/urlaliases_swap_multilang_simple.php index 6492f1e66c..551e82e7de 100644 --- a/tests/lib/Persistence/Legacy/Content/UrlAlias/_fixtures/urlaliases_swap_multilang_simple.php +++ b/tests/lib/Persistence/Legacy/Content/UrlAlias/_fixtures/urlaliases_swap_multilang_simple.php @@ -172,11 +172,13 @@ 'id' => 3, 'initial_language_id' => 2, 'current_version' => 1, + 'contentclass_id' => 1, ], 1 => [ 'id' => 4, 'initial_language_id' => 2, 'current_version' => 1, + 'contentclass_id' => 2, ], ], 'ezcontentobject_name' => [ @@ -205,4 +207,46 @@ 'content_translation' => 'eng-GB', ], ], + 'ezcontentclass' => [ + 0 => [ + 'id' => 1, + 'version' => '0', + 'always_available' => 0, + 'contentobject_name' => '<short_name|name>', + 'created' => '1033917596', + 'creator_id' => 14, + 'identifier' => 'folder', + 'initial_language_id' => 2, + 'is_container' => true, + 'language_mask' => 2, + 'modified' => '1311154215', + 'modifier_id' => 14, + 'remote_id' => '5fcdb3fb687dd6dcf8c94bc84e8bd1b2', + 'serialized_description_list' => 'a:0:{}', + 'serialized_name_list' => 'a:1:{s:6:"eng-GB";s:6:"Folder";}', + 'sort_field' => 1, + 'sort_order' => 1, + 'url_alias_name' => null, + ], + 1 => [ + 'id' => 2, + 'version' => '0', + 'always_available' => 1, + 'contentobject_name' => '<name>', + 'created' => '1033917896', + 'creator_id' => 14, + 'identifier' => 'user_group', + 'initial_language_id' => 2, + 'is_container' => true, + 'language_mask' => 2, + 'modified' => '1311154815', + 'modifier_id' => 14, + 'remote_id' => '0f2622aad22267e195c8e76b05c25e29', + 'serialized_description_list' => 'a:0:{}', + 'serialized_name_list' => 'a:2:{s:6:"eng-GB";s:10:"User group";s:16:"always-available";s:6:"eng-GB";}', + 'sort_field' => 1, + 'sort_order' => 1, + 'url_alias_name' => null, + ], + ], ]; diff --git a/tests/lib/Persistence/Legacy/Content/UrlAlias/_fixtures/urlaliases_swap_path_identification_string.php b/tests/lib/Persistence/Legacy/Content/UrlAlias/_fixtures/urlaliases_swap_path_identification_string.php index 488d2907ae..8187614763 100644 --- a/tests/lib/Persistence/Legacy/Content/UrlAlias/_fixtures/urlaliases_swap_path_identification_string.php +++ b/tests/lib/Persistence/Legacy/Content/UrlAlias/_fixtures/urlaliases_swap_path_identification_string.php @@ -111,11 +111,13 @@ 'id' => 2, 'initial_language_id' => 2, 'current_version' => 1, + 'contentclass_id' => 1, ], 1 => [ 'id' => 3, 'initial_language_id' => 2, 'current_version' => 1, + 'contentclass_id' => 2, ], ], 'ezcontentobject_name' => [ @@ -132,4 +134,46 @@ 'content_translation' => 'cro-HR', ], ], + 'ezcontentclass' => [ + 0 => [ + 'id' => 1, + 'version' => '0', + 'always_available' => 0, + 'contentobject_name' => '<short_name|name>', + 'created' => '1033917596', + 'creator_id' => 14, + 'identifier' => 'folder', + 'initial_language_id' => 2, + 'is_container' => true, + 'language_mask' => 2, + 'modified' => '1311154215', + 'modifier_id' => 14, + 'remote_id' => '5fcdb3fb687dd6dcf8c94bc84e8bd1b2', + 'serialized_description_list' => 'a:0:{}', + 'serialized_name_list' => 'a:1:{s:6:"eng-GB";s:6:"Folder";}', + 'sort_field' => 1, + 'sort_order' => 1, + 'url_alias_name' => null, + ], + 1 => [ + 'id' => 2, + 'version' => '0', + 'always_available' => 1, + 'contentobject_name' => '<name>', + 'created' => '1033917896', + 'creator_id' => 14, + 'identifier' => 'user_group', + 'initial_language_id' => 2, + 'is_container' => true, + 'language_mask' => 2, + 'modified' => '1311154815', + 'modifier_id' => 14, + 'remote_id' => '0f2622aad22267e195c8e76b05c25e29', + 'serialized_description_list' => 'a:0:{}', + 'serialized_name_list' => 'a:2:{s:6:"eng-GB";s:10:"User group";s:16:"always-available";s:6:"eng-GB";}', + 'sort_field' => 1, + 'sort_order' => 1, + 'url_alias_name' => null, + ], + ], ]; diff --git a/tests/lib/Persistence/Legacy/Content/UrlAlias/_fixtures/urlaliases_swap_reusing_external_history.php b/tests/lib/Persistence/Legacy/Content/UrlAlias/_fixtures/urlaliases_swap_reusing_external_history.php index 7b006ca6f9..8e16d2bbf0 100644 --- a/tests/lib/Persistence/Legacy/Content/UrlAlias/_fixtures/urlaliases_swap_reusing_external_history.php +++ b/tests/lib/Persistence/Legacy/Content/UrlAlias/_fixtures/urlaliases_swap_reusing_external_history.php @@ -204,11 +204,13 @@ 'id' => 3, 'initial_language_id' => 2, 'current_version' => 1, + 'contentclass_id' => 1, ], 1 => [ 'id' => 4, 'initial_language_id' => 2, 'current_version' => 1, + 'contentclass_id' => 2, ], ], 'ezcontentobject_name' => [ @@ -225,4 +227,46 @@ 'content_translation' => 'cro-HR', ], ], + 'ezcontentclass' => [ + 0 => [ + 'id' => 1, + 'version' => '0', + 'always_available' => 0, + 'contentobject_name' => '<short_name|name>', + 'created' => '1033917596', + 'creator_id' => 14, + 'identifier' => 'folder', + 'initial_language_id' => 2, + 'is_container' => true, + 'language_mask' => 2, + 'modified' => '1311154215', + 'modifier_id' => 14, + 'remote_id' => '5fcdb3fb687dd6dcf8c94bc84e8bd1b2', + 'serialized_description_list' => 'a:0:{}', + 'serialized_name_list' => 'a:1:{s:6:"eng-GB";s:6:"Folder";}', + 'sort_field' => 1, + 'sort_order' => 1, + 'url_alias_name' => null, + ], + 1 => [ + 'id' => 2, + 'version' => '0', + 'always_available' => 1, + 'contentobject_name' => '<name>', + 'created' => '1033917896', + 'creator_id' => 14, + 'identifier' => 'user_group', + 'initial_language_id' => 2, + 'is_container' => true, + 'language_mask' => 2, + 'modified' => '1311154815', + 'modifier_id' => 14, + 'remote_id' => '0f2622aad22267e195c8e76b05c25e29', + 'serialized_description_list' => 'a:0:{}', + 'serialized_name_list' => 'a:2:{s:6:"eng-GB";s:10:"User group";s:16:"always-available";s:6:"eng-GB";}', + 'sort_field' => 1, + 'sort_order' => 1, + 'url_alias_name' => null, + ], + ], ]; diff --git a/tests/lib/Persistence/Legacy/Content/UrlAlias/_fixtures/urlaliases_swap_reusing_nop.php b/tests/lib/Persistence/Legacy/Content/UrlAlias/_fixtures/urlaliases_swap_reusing_nop.php index b73b2e0185..a40a2973b1 100644 --- a/tests/lib/Persistence/Legacy/Content/UrlAlias/_fixtures/urlaliases_swap_reusing_nop.php +++ b/tests/lib/Persistence/Legacy/Content/UrlAlias/_fixtures/urlaliases_swap_reusing_nop.php @@ -172,11 +172,13 @@ 'id' => 3, 'initial_language_id' => 2, 'current_version' => 1, + 'contentclass_id' => 1, ], 1 => [ 'id' => 4, 'initial_language_id' => 2, 'current_version' => 1, + 'contentclass_id' => 2, ], ], 'ezcontentobject_name' => [ @@ -193,4 +195,46 @@ 'content_translation' => 'cro-HR', ], ], + 'ezcontentclass' => [ + 0 => [ + 'id' => 1, + 'version' => '0', + 'always_available' => 0, + 'contentobject_name' => '<short_name|name>', + 'created' => '1033917596', + 'creator_id' => 14, + 'identifier' => 'folder', + 'initial_language_id' => 2, + 'is_container' => true, + 'language_mask' => 2, + 'modified' => '1311154215', + 'modifier_id' => 14, + 'remote_id' => '5fcdb3fb687dd6dcf8c94bc84e8bd1b2', + 'serialized_description_list' => 'a:0:{}', + 'serialized_name_list' => 'a:1:{s:6:"eng-GB";s:6:"Folder";}', + 'sort_field' => 1, + 'sort_order' => 1, + 'url_alias_name' => null, + ], + 1 => [ + 'id' => 2, + 'version' => '0', + 'always_available' => 1, + 'contentobject_name' => '<name>', + 'created' => '1033917896', + 'creator_id' => 14, + 'identifier' => 'user_group', + 'initial_language_id' => 2, + 'is_container' => true, + 'language_mask' => 2, + 'modified' => '1311154815', + 'modifier_id' => 14, + 'remote_id' => '0f2622aad22267e195c8e76b05c25e29', + 'serialized_description_list' => 'a:0:{}', + 'serialized_name_list' => 'a:2:{s:6:"eng-GB";s:10:"User group";s:16:"always-available";s:6:"eng-GB";}', + 'sort_field' => 1, + 'sort_order' => 1, + 'url_alias_name' => null, + ], + ], ]; diff --git a/tests/lib/Persistence/Legacy/Content/UrlAlias/_fixtures/urlaliases_swap_siblings_same_name.php b/tests/lib/Persistence/Legacy/Content/UrlAlias/_fixtures/urlaliases_swap_siblings_same_name.php index 3de9a6da9c..4c0fca9c5d 100644 --- a/tests/lib/Persistence/Legacy/Content/UrlAlias/_fixtures/urlaliases_swap_siblings_same_name.php +++ b/tests/lib/Persistence/Legacy/Content/UrlAlias/_fixtures/urlaliases_swap_siblings_same_name.php @@ -99,11 +99,13 @@ 'id' => 2, 'initial_language_id' => 2, 'current_version' => 1, + 'contentclass_id' => 1, ], 1 => [ 'id' => 3, 'initial_language_id' => 2, 'current_version' => 1, + 'contentclass_id' => 2, ], ], 'ezcontentobject_name' => [ @@ -120,4 +122,46 @@ 'content_translation' => 'cro-HR', ], ], + 'ezcontentclass' => [ + 0 => [ + 'id' => 1, + 'version' => '0', + 'always_available' => 0, + 'contentobject_name' => '<short_name|name>', + 'created' => '1033917596', + 'creator_id' => 14, + 'identifier' => 'folder', + 'initial_language_id' => 2, + 'is_container' => true, + 'language_mask' => 2, + 'modified' => '1311154215', + 'modifier_id' => 14, + 'remote_id' => '5fcdb3fb687dd6dcf8c94bc84e8bd1b2', + 'serialized_description_list' => 'a:0:{}', + 'serialized_name_list' => 'a:1:{s:6:"eng-GB";s:6:"Folder";}', + 'sort_field' => 1, + 'sort_order' => 1, + 'url_alias_name' => null, + ], + 1 => [ + 'id' => 2, + 'version' => '0', + 'always_available' => 1, + 'contentobject_name' => '<name>', + 'created' => '1033917896', + 'creator_id' => 14, + 'identifier' => 'user_group', + 'initial_language_id' => 2, + 'is_container' => true, + 'language_mask' => 2, + 'modified' => '1311154815', + 'modifier_id' => 14, + 'remote_id' => '0f2622aad22267e195c8e76b05c25e29', + 'serialized_description_list' => 'a:0:{}', + 'serialized_name_list' => 'a:2:{s:6:"eng-GB";s:10:"User group";s:16:"always-available";s:6:"eng-GB";}', + 'sort_field' => 1, + 'sort_order' => 1, + 'url_alias_name' => null, + ], + ], ]; diff --git a/tests/lib/Persistence/Legacy/Content/UrlAlias/_fixtures/urlaliases_swap_siblings_same_name_multilang.php b/tests/lib/Persistence/Legacy/Content/UrlAlias/_fixtures/urlaliases_swap_siblings_same_name_multilang.php index 5e6862c3d8..03f6259041 100644 --- a/tests/lib/Persistence/Legacy/Content/UrlAlias/_fixtures/urlaliases_swap_siblings_same_name_multilang.php +++ b/tests/lib/Persistence/Legacy/Content/UrlAlias/_fixtures/urlaliases_swap_siblings_same_name_multilang.php @@ -131,11 +131,13 @@ 'id' => 2, 'initial_language_id' => 2, 'current_version' => 1, + 'contentclass_id' => 1, ], 1 => [ 'id' => 3, 'initial_language_id' => 2, 'current_version' => 1, + 'contentclass_id' => 2, ], ], 'ezcontentobject_name' => [ @@ -164,4 +166,46 @@ 'content_translation' => 'eng-GB', ], ], + 'ezcontentclass' => [ + 0 => [ + 'id' => 1, + 'version' => '0', + 'always_available' => 0, + 'contentobject_name' => '<short_name|name>', + 'created' => '1033917596', + 'creator_id' => 14, + 'identifier' => 'folder', + 'initial_language_id' => 2, + 'is_container' => true, + 'language_mask' => 2, + 'modified' => '1311154215', + 'modifier_id' => 14, + 'remote_id' => '5fcdb3fb687dd6dcf8c94bc84e8bd1b2', + 'serialized_description_list' => 'a:0:{}', + 'serialized_name_list' => 'a:1:{s:6:"eng-GB";s:6:"Folder";}', + 'sort_field' => 1, + 'sort_order' => 1, + 'url_alias_name' => null, + ], + 1 => [ + 'id' => 2, + 'version' => '0', + 'always_available' => 1, + 'contentobject_name' => '<name>', + 'created' => '1033917896', + 'creator_id' => 14, + 'identifier' => 'user_group', + 'initial_language_id' => 2, + 'is_container' => true, + 'language_mask' => 2, + 'modified' => '1311154815', + 'modifier_id' => 14, + 'remote_id' => '0f2622aad22267e195c8e76b05c25e29', + 'serialized_description_list' => 'a:0:{}', + 'serialized_name_list' => 'a:2:{s:6:"eng-GB";s:10:"User group";s:16:"always-available";s:6:"eng-GB";}', + 'sort_field' => 1, + 'sort_order' => 1, + 'url_alias_name' => null, + ], + ], ]; diff --git a/tests/lib/Persistence/Legacy/Content/UrlAlias/_fixtures/urlaliases_swap_siblings_simple.php b/tests/lib/Persistence/Legacy/Content/UrlAlias/_fixtures/urlaliases_swap_siblings_simple.php index a8b350cf20..d0cdb52459 100644 --- a/tests/lib/Persistence/Legacy/Content/UrlAlias/_fixtures/urlaliases_swap_siblings_simple.php +++ b/tests/lib/Persistence/Legacy/Content/UrlAlias/_fixtures/urlaliases_swap_siblings_simple.php @@ -99,11 +99,13 @@ 'id' => 2, 'initial_language_id' => 2, 'current_version' => 1, + 'contentclass_id' => 1, ], 1 => [ 'id' => 3, 'initial_language_id' => 2, 'current_version' => 1, + 'contentclass_id' => 2, ], ], 'ezcontentobject_name' => [ @@ -120,4 +122,46 @@ 'content_translation' => 'cro-HR', ], ], + 'ezcontentclass' => [ + 0 => [ + 'id' => 1, + 'version' => '0', + 'always_available' => 0, + 'contentobject_name' => '<short_name|name>', + 'created' => '1033917596', + 'creator_id' => 14, + 'identifier' => 'folder', + 'initial_language_id' => 2, + 'is_container' => true, + 'language_mask' => 2, + 'modified' => '1311154215', + 'modifier_id' => 14, + 'remote_id' => '5fcdb3fb687dd6dcf8c94bc84e8bd1b2', + 'serialized_description_list' => 'a:0:{}', + 'serialized_name_list' => 'a:1:{s:6:"eng-GB";s:6:"Folder";}', + 'sort_field' => 1, + 'sort_order' => 1, + 'url_alias_name' => null, + ], + 1 => [ + 'id' => 2, + 'version' => '0', + 'always_available' => 1, + 'contentobject_name' => '<name>', + 'created' => '1033917896', + 'creator_id' => 14, + 'identifier' => 'user_group', + 'initial_language_id' => 2, + 'is_container' => true, + 'language_mask' => 2, + 'modified' => '1311154815', + 'modifier_id' => 14, + 'remote_id' => '0f2622aad22267e195c8e76b05c25e29', + 'serialized_description_list' => 'a:0:{}', + 'serialized_name_list' => 'a:2:{s:6:"eng-GB";s:10:"User group";s:16:"always-available";s:6:"eng-GB";}', + 'sort_field' => 1, + 'sort_order' => 1, + 'url_alias_name' => null, + ], + ], ]; diff --git a/tests/lib/Persistence/Legacy/Content/UrlAlias/_fixtures/urlaliases_swap_siblings_simple_history.php b/tests/lib/Persistence/Legacy/Content/UrlAlias/_fixtures/urlaliases_swap_siblings_simple_history.php index 49e74d0807..c793b47fc1 100644 --- a/tests/lib/Persistence/Legacy/Content/UrlAlias/_fixtures/urlaliases_swap_siblings_simple_history.php +++ b/tests/lib/Persistence/Legacy/Content/UrlAlias/_fixtures/urlaliases_swap_siblings_simple_history.php @@ -131,11 +131,13 @@ 'id' => 2, 'initial_language_id' => 2, 'current_version' => 1, + 'contentclass_id' => 1, ], 1 => [ 'id' => 3, 'initial_language_id' => 2, 'current_version' => 1, + 'contentclass_id' => 2, ], ], 'ezcontentobject_name' => [ @@ -152,4 +154,46 @@ 'content_translation' => 'cro-HR', ], ], + 'ezcontentclass' => [ + 0 => [ + 'id' => 1, + 'version' => '0', + 'always_available' => 0, + 'contentobject_name' => '<short_name|name>', + 'created' => '1033917596', + 'creator_id' => 14, + 'identifier' => 'folder', + 'initial_language_id' => 2, + 'is_container' => true, + 'language_mask' => 2, + 'modified' => '1311154215', + 'modifier_id' => 14, + 'remote_id' => '5fcdb3fb687dd6dcf8c94bc84e8bd1b2', + 'serialized_description_list' => 'a:0:{}', + 'serialized_name_list' => 'a:1:{s:6:"eng-GB";s:6:"Folder";}', + 'sort_field' => 1, + 'sort_order' => 1, + 'url_alias_name' => null, + ], + 1 => [ + 'id' => 2, + 'version' => '0', + 'always_available' => 1, + 'contentobject_name' => '<name>', + 'created' => '1033917896', + 'creator_id' => 14, + 'identifier' => 'user_group', + 'initial_language_id' => 2, + 'is_container' => true, + 'language_mask' => 2, + 'modified' => '1311154815', + 'modifier_id' => 14, + 'remote_id' => '0f2622aad22267e195c8e76b05c25e29', + 'serialized_description_list' => 'a:0:{}', + 'serialized_name_list' => 'a:2:{s:6:"eng-GB";s:10:"User group";s:16:"always-available";s:6:"eng-GB";}', + 'sort_field' => 1, + 'sort_order' => 1, + 'url_alias_name' => null, + ], + ], ]; diff --git a/tests/lib/Persistence/Legacy/Content/UrlAlias/_fixtures/urlaliases_swap_simple.php b/tests/lib/Persistence/Legacy/Content/UrlAlias/_fixtures/urlaliases_swap_simple.php index f1aaab3b69..c7f1427adc 100644 --- a/tests/lib/Persistence/Legacy/Content/UrlAlias/_fixtures/urlaliases_swap_simple.php +++ b/tests/lib/Persistence/Legacy/Content/UrlAlias/_fixtures/urlaliases_swap_simple.php @@ -140,11 +140,13 @@ 'id' => 3, 'initial_language_id' => 2, 'current_version' => 1, + 'contentclass_id' => 1, ], 1 => [ 'id' => 4, 'initial_language_id' => 2, 'current_version' => 1, + 'contentclass_id' => 2, ], ], 'ezcontentobject_name' => [ @@ -161,4 +163,46 @@ 'content_translation' => 'cro-HR', ], ], + 'ezcontentclass' => [ + 0 => [ + 'id' => 1, + 'version' => '0', + 'always_available' => 0, + 'contentobject_name' => '<short_name|name>', + 'created' => '1033917596', + 'creator_id' => 14, + 'identifier' => 'folder', + 'initial_language_id' => 2, + 'is_container' => true, + 'language_mask' => 2, + 'modified' => '1311154215', + 'modifier_id' => 14, + 'remote_id' => '5fcdb3fb687dd6dcf8c94bc84e8bd1b2', + 'serialized_description_list' => 'a:0:{}', + 'serialized_name_list' => 'a:1:{s:6:"eng-GB";s:6:"Folder";}', + 'sort_field' => 1, + 'sort_order' => 1, + 'url_alias_name' => null, + ], + 1 => [ + 'id' => 2, + 'version' => '0', + 'always_available' => 1, + 'contentobject_name' => '<name>', + 'created' => '1033917896', + 'creator_id' => 14, + 'identifier' => 'user_group', + 'initial_language_id' => 2, + 'is_container' => true, + 'language_mask' => 2, + 'modified' => '1311154815', + 'modifier_id' => 14, + 'remote_id' => '0f2622aad22267e195c8e76b05c25e29', + 'serialized_description_list' => 'a:0:{}', + 'serialized_name_list' => 'a:2:{s:6:"eng-GB";s:10:"User group";s:16:"always-available";s:6:"eng-GB";}', + 'sort_field' => 1, + 'sort_order' => 1, + 'url_alias_name' => null, + ], + ], ]; diff --git a/tests/lib/Persistence/Legacy/Content/UrlAlias/_fixtures/urlaliases_swap_simple_conflict.php b/tests/lib/Persistence/Legacy/Content/UrlAlias/_fixtures/urlaliases_swap_simple_conflict.php index 6079ac3ce0..ed0809372e 100644 --- a/tests/lib/Persistence/Legacy/Content/UrlAlias/_fixtures/urlaliases_swap_simple_conflict.php +++ b/tests/lib/Persistence/Legacy/Content/UrlAlias/_fixtures/urlaliases_swap_simple_conflict.php @@ -198,11 +198,13 @@ 'id' => 3, 'initial_language_id' => 2, 'current_version' => 1, + 'contentclass_id' => 1, ], 1 => [ 'id' => 4, 'initial_language_id' => 2, 'current_version' => 1, + 'contentclass_id' => 2, ], ], 'ezcontentobject_name' => [ @@ -219,4 +221,46 @@ 'content_translation' => 'cro-HR', ], ], + 'ezcontentclass' => [ + 0 => [ + 'id' => 1, + 'version' => '0', + 'always_available' => 0, + 'contentobject_name' => '<short_name|name>', + 'created' => '1033917596', + 'creator_id' => 14, + 'identifier' => 'folder', + 'initial_language_id' => 2, + 'is_container' => true, + 'language_mask' => 2, + 'modified' => '1311154215', + 'modifier_id' => 14, + 'remote_id' => '5fcdb3fb687dd6dcf8c94bc84e8bd1b2', + 'serialized_description_list' => 'a:0:{}', + 'serialized_name_list' => 'a:1:{s:6:"eng-GB";s:6:"Folder";}', + 'sort_field' => 1, + 'sort_order' => 1, + 'url_alias_name' => null, + ], + 1 => [ + 'id' => 2, + 'version' => '0', + 'always_available' => 1, + 'contentobject_name' => '<name>', + 'created' => '1033917896', + 'creator_id' => 14, + 'identifier' => 'user_group', + 'initial_language_id' => 2, + 'is_container' => true, + 'language_mask' => 2, + 'modified' => '1311154815', + 'modifier_id' => 14, + 'remote_id' => '0f2622aad22267e195c8e76b05c25e29', + 'serialized_description_list' => 'a:0:{}', + 'serialized_name_list' => 'a:2:{s:6:"eng-GB";s:10:"User group";s:16:"always-available";s:6:"eng-GB";}', + 'sort_field' => 1, + 'sort_order' => 1, + 'url_alias_name' => null, + ], + ], ]; diff --git a/tests/lib/Persistence/Legacy/Content/UrlAlias/_fixtures/urlaliases_swap_simple_history.php b/tests/lib/Persistence/Legacy/Content/UrlAlias/_fixtures/urlaliases_swap_simple_history.php index 194ec2aaca..97945d1ec6 100644 --- a/tests/lib/Persistence/Legacy/Content/UrlAlias/_fixtures/urlaliases_swap_simple_history.php +++ b/tests/lib/Persistence/Legacy/Content/UrlAlias/_fixtures/urlaliases_swap_simple_history.php @@ -172,11 +172,13 @@ 'id' => 3, 'initial_language_id' => 2, 'current_version' => 1, + 'contentclass_id' => 1, ], 1 => [ 'id' => 4, 'initial_language_id' => 2, 'current_version' => 1, + 'contentclass_id' => 2, ], ], 'ezcontentobject_name' => [ @@ -193,4 +195,46 @@ 'content_translation' => 'cro-HR', ], ], + 'ezcontentclass' => [ + 0 => [ + 'id' => 1, + 'version' => '0', + 'always_available' => 0, + 'contentobject_name' => '<short_name|name>', + 'created' => '1033917596', + 'creator_id' => 14, + 'identifier' => 'folder', + 'initial_language_id' => 2, + 'is_container' => true, + 'language_mask' => 2, + 'modified' => '1311154215', + 'modifier_id' => 14, + 'remote_id' => '5fcdb3fb687dd6dcf8c94bc84e8bd1b2', + 'serialized_description_list' => 'a:0:{}', + 'serialized_name_list' => 'a:1:{s:6:"eng-GB";s:6:"Folder";}', + 'sort_field' => 1, + 'sort_order' => 1, + 'url_alias_name' => null, + ], + 1 => [ + 'id' => 2, + 'version' => '0', + 'always_available' => 1, + 'contentobject_name' => '<name>', + 'created' => '1033917896', + 'creator_id' => 14, + 'identifier' => 'user_group', + 'initial_language_id' => 2, + 'is_container' => true, + 'language_mask' => 2, + 'modified' => '1311154815', + 'modifier_id' => 14, + 'remote_id' => '0f2622aad22267e195c8e76b05c25e29', + 'serialized_description_list' => 'a:0:{}', + 'serialized_name_list' => 'a:2:{s:6:"eng-GB";s:10:"User group";s:16:"always-available";s:6:"eng-GB";}', + 'sort_field' => 1, + 'sort_order' => 1, + 'url_alias_name' => null, + ], + ], ]; diff --git a/tests/lib/Persistence/Legacy/Content/_fixtures/extract_content_from_rows_multiple_versions.php b/tests/lib/Persistence/Legacy/Content/_fixtures/extract_content_from_rows_multiple_versions.php index 632262fa9e..182c89d56d 100644 --- a/tests/lib/Persistence/Legacy/Content/_fixtures/extract_content_from_rows_multiple_versions.php +++ b/tests/lib/Persistence/Legacy/Content/_fixtures/extract_content_from_rows_multiple_versions.php @@ -38,7 +38,7 @@ 'ezcontentobject_attribute_sort_key_string' => '', 'ezcontentobject_tree_main_node_id' => '12', 'ezcontentobject_is_hidden' => '0', - 'ezcontentclass_identifier' => 'user_group', + 'content_type_identifier' => 'user_group', ], 1 => [ 'ezcontentobject_id' => '11', @@ -73,7 +73,7 @@ 'ezcontentobject_attribute_sort_key_string' => '', 'ezcontentobject_tree_main_node_id' => '12', 'ezcontentobject_is_hidden' => '0', - 'ezcontentclass_identifier' => 'user_group', + 'content_type_identifier' => 'user_group', ], 2 => [ 'ezcontentobject_id' => '11', @@ -108,7 +108,7 @@ 'ezcontentobject_attribute_sort_key_string' => 'members', 'ezcontentobject_tree_main_node_id' => '12', 'ezcontentobject_is_hidden' => '0', - 'ezcontentclass_identifier' => 'user_group', + 'content_type_identifier' => 'user_group', ], 3 => [ 'ezcontentobject_id' => '11', @@ -143,6 +143,6 @@ 'ezcontentobject_attribute_sort_key_string' => '', 'ezcontentobject_tree_main_node_id' => '12', 'ezcontentobject_is_hidden' => '0', - 'ezcontentclass_identifier' => 'user_group', + 'content_type_identifier' => 'user_group', ], ]; diff --git a/tests/lib/Persistence/Legacy/Content/_fixtures/extract_version_info_from_rows_multiple_versions.php b/tests/lib/Persistence/Legacy/Content/_fixtures/extract_version_info_from_rows_multiple_versions.php index 392413e8db..666acff70d 100644 --- a/tests/lib/Persistence/Legacy/Content/_fixtures/extract_version_info_from_rows_multiple_versions.php +++ b/tests/lib/Persistence/Legacy/Content/_fixtures/extract_version_info_from_rows_multiple_versions.php @@ -29,7 +29,7 @@ 'ezcontentobject_language_mask' => '3', 'ezcontentobject_is_hidden' => '0', 'ezcontentobject_version_contentobject_id' => '11', - 'ezcontentclass_identifier' => 'user_group', + 'content_type_identifier' => 'user_group', ], 1 => [ 'ezcontentobject_version_id' => '674', @@ -55,6 +55,6 @@ 'ezcontentobject_language_mask' => '3', 'ezcontentobject_is_hidden' => '0', 'ezcontentobject_version_contentobject_id' => '11', - 'ezcontentclass_identifier' => 'user_group', + 'content_type_identifier' => 'user_group', ], ]; diff --git a/tests/lib/Persistence/ValueObject/ContentInfoTest.php b/tests/lib/Persistence/ValueObject/ContentInfoTest.php new file mode 100644 index 0000000000..2afe461071 --- /dev/null +++ b/tests/lib/Persistence/ValueObject/ContentInfoTest.php @@ -0,0 +1,21 @@ +<?php + +/** + * @copyright Copyright (C) Ibexa AS. All rights reserved. + * @license For full copyright and license information view LICENSE file distributed with this source code. + */ +namespace Ibexa\Tests\Core\Persistence\ValueObject; + +use Ibexa\Contracts\Core\Persistence\Content\ContentInfo; +use Ibexa\Tests\Core\Persistence\Legacy\TestCase; + +class ContentInfoTest extends TestCase +{ + public function testGetContentTypeIdentifier(): void + { + $contentTypeIdentifier = 'foo'; + $contentInfo = new ContentInfo(['contentTypeIdentifier' => $contentTypeIdentifier]); + + self::assertSame($contentTypeIdentifier, $contentInfo->getContentTypeIdentifier()); + } +} From f798d7e5983718a24b35dd56cd1fe6dd1affbf38 Mon Sep 17 00:00:00 2001 From: matx132 <mateusz@mateuszdebinski.pl> Date: Thu, 27 Jul 2023 21:50:09 +0200 Subject: [PATCH 03/11] Removed unnecessary tests, Added exclusions for sonar cloud --- sonar-project.properties | 2 ++ .../Content/Gateway/DoctrineDatabaseTest.php | 14 -------------- .../Persistence/ValueObject/ContentInfoTest.php | 2 +- 3 files changed, 3 insertions(+), 15 deletions(-) create mode 100644 sonar-project.properties diff --git a/sonar-project.properties b/sonar-project.properties new file mode 100644 index 0000000000..ff20cce753 --- /dev/null +++ b/sonar-project.properties @@ -0,0 +1,2 @@ +# Exclude test data dumps +sonar.exclusions = tests/**/_fixtures/**.php \ No newline at end of file diff --git a/tests/lib/Persistence/Legacy/Content/Gateway/DoctrineDatabaseTest.php b/tests/lib/Persistence/Legacy/Content/Gateway/DoctrineDatabaseTest.php index d350b8bc8e..26d74c4bf9 100644 --- a/tests/lib/Persistence/Legacy/Content/Gateway/DoctrineDatabaseTest.php +++ b/tests/lib/Persistence/Legacy/Content/Gateway/DoctrineDatabaseTest.php @@ -602,13 +602,6 @@ public function testListVersions(): void $res ); - foreach ($res as $row) { - $this->assertCount( - 24, - $row - ); - } - $this->assertEquals( 675, $res[0]['ezcontentobject_version_id'] @@ -643,13 +636,6 @@ public function testListVersionsForUser() $res ); - foreach ($res as $row) { - $this->assertCount( - 24, - $row - ); - } - $this->assertEquals( 677, $res[0]['ezcontentobject_version_id'] diff --git a/tests/lib/Persistence/ValueObject/ContentInfoTest.php b/tests/lib/Persistence/ValueObject/ContentInfoTest.php index 2afe461071..64f77eeae7 100644 --- a/tests/lib/Persistence/ValueObject/ContentInfoTest.php +++ b/tests/lib/Persistence/ValueObject/ContentInfoTest.php @@ -9,7 +9,7 @@ use Ibexa\Contracts\Core\Persistence\Content\ContentInfo; use Ibexa\Tests\Core\Persistence\Legacy\TestCase; -class ContentInfoTest extends TestCase +final class ContentInfoTest extends TestCase { public function testGetContentTypeIdentifier(): void { From 5648319dd8f7ab9b451195cf9859631074563b8c Mon Sep 17 00:00:00 2001 From: matx132 <mateusz@mateuszdebinski.pl> Date: Fri, 28 Jul 2023 11:01:26 +0200 Subject: [PATCH 04/11] Removed unnecessary tests, Added exclusions for sonar cloud --- sonar-project.properties | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/sonar-project.properties b/sonar-project.properties index ff20cce753..78014c525f 100644 --- a/sonar-project.properties +++ b/sonar-project.properties @@ -1,2 +1,2 @@ # Exclude test data dumps -sonar.exclusions = tests/**/_fixtures/**.php \ No newline at end of file +sonar.test.exclusions = tests/lib/Persistence/Legacy/Content/_fixtures/contentclass.php From 2422f38c7200b7c184e3ae2cf1300b51d1ca313e Mon Sep 17 00:00:00 2001 From: matx132 <mateusz@mateuszdebinski.pl> Date: Fri, 28 Jul 2023 12:34:18 +0200 Subject: [PATCH 05/11] Removed sonar-project.properties --- sonar-project.properties | 2 -- 1 file changed, 2 deletions(-) delete mode 100644 sonar-project.properties diff --git a/sonar-project.properties b/sonar-project.properties deleted file mode 100644 index 78014c525f..0000000000 --- a/sonar-project.properties +++ /dev/null @@ -1,2 +0,0 @@ -# Exclude test data dumps -sonar.test.exclusions = tests/lib/Persistence/Legacy/Content/_fixtures/contentclass.php From 63bdc34d7b40fb257dbdcc521772e3db3ada9d94 Mon Sep 17 00:00:00 2001 From: matx132 <mateusz@mateuszdebinski.pl> Date: Mon, 7 Aug 2023 12:00:32 +0200 Subject: [PATCH 06/11] Added declaring strict types. --- .../_fixtures/extract_content_from_rows.php | 17 +++++++++-------- .../Persistence/ValueObject/ContentInfoTest.php | 2 ++ 2 files changed, 11 insertions(+), 8 deletions(-) diff --git a/tests/lib/Persistence/Legacy/Content/_fixtures/extract_content_from_rows.php b/tests/lib/Persistence/Legacy/Content/_fixtures/extract_content_from_rows.php index d5979a3dbe..af448438c6 100644 --- a/tests/lib/Persistence/Legacy/Content/_fixtures/extract_content_from_rows.php +++ b/tests/lib/Persistence/Legacy/Content/_fixtures/extract_content_from_rows.php @@ -38,7 +38,7 @@ 'ezcontentobject_attribute_sort_key_int' => 0, 'ezcontentobject_attribute_sort_key_string' => 'new test article (2)', 'ezcontentobject_tree_main_node_id' => 228, - 'ezcontentclass_identifier' => 'article', + 'content_type_identifier' => 'article', ], 1 => [ 'ezcontentobject_id' => 226, @@ -73,7 +73,7 @@ 'ezcontentobject_attribute_sort_key_string' => 'something', 'ezcontentobject_tree_main_node_id' => 228, 'ezcontentobject_is_hidden' => 0, - 'ezcontentclass_identifier' => 'article', + 'content_type_identifier' => 'article', ], 2 => [ 'ezcontentobject_id' => 226, @@ -110,7 +110,7 @@ 'ezcontentobject_attribute_sort_key_string' => '', 'ezcontentobject_tree_main_node_id' => 228, 'ezcontentobject_is_hidden' => 0, - 'ezcontentclass_identifier' => 'article', + 'content_type_identifier' => 'article', ], 3 => [ 'ezcontentobject_id' => 226, @@ -145,7 +145,7 @@ 'ezcontentobject_attribute_sort_key_string' => '', 'ezcontentobject_tree_main_node_id' => 228, 'ezcontentobject_is_hidden' => 0, - 'ezcontentclass_identifier' => 'article', + 'content_type_identifier' => 'article', ], 4 => [ 'ezcontentobject_id' => 226, @@ -182,7 +182,7 @@ 'ezcontentobject_attribute_sort_key_string' => '', 'ezcontentobject_tree_main_node_id' => 228, 'ezcontentobject_is_hidden' => 0, - 'ezcontentclass_identifier' => 'article', + 'content_type_identifier' => 'article', ], 5 => [ 'ezcontentobject_id' => 226, @@ -217,7 +217,7 @@ 'ezcontentobject_attribute_sort_key_string' => '', 'ezcontentobject_tree_main_node_id' => 228, 'ezcontentobject_is_hidden' => 0, - 'ezcontentclass_identifier' => 'article', + 'content_type_identifier' => 'article', ], 6 => [ 'ezcontentobject_id' => 226, @@ -252,7 +252,7 @@ 'ezcontentobject_attribute_sort_key_string' => '', 'ezcontentobject_tree_main_node_id' => 228, 'ezcontentobject_is_hidden' => 0, - 'ezcontentclass_identifier' => 'article', + 'content_type_identifier' => 'article', ], 7 => [ 'ezcontentobject_id' => 226, @@ -287,6 +287,7 @@ 'ezcontentobject_attribute_sort_key_string' => '', 'ezcontentobject_tree_main_node_id' => 228, 'ezcontentobject_is_hidden' => 0, + 'content_type_identifier' => 'article', ], 8 => [ 'ezcontentobject_id' => 226, @@ -321,6 +322,6 @@ 'ezcontentobject_attribute_sort_key_string' => '', 'ezcontentobject_tree_main_node_id' => 228, 'ezcontentobject_is_hidden' => 0, - 'ezcontentclass_identifier' => 'article', + 'content_type_identifier' => 'article', ], ]; diff --git a/tests/lib/Persistence/ValueObject/ContentInfoTest.php b/tests/lib/Persistence/ValueObject/ContentInfoTest.php index 64f77eeae7..0d60506e73 100644 --- a/tests/lib/Persistence/ValueObject/ContentInfoTest.php +++ b/tests/lib/Persistence/ValueObject/ContentInfoTest.php @@ -4,6 +4,8 @@ * @copyright Copyright (C) Ibexa AS. All rights reserved. * @license For full copyright and license information view LICENSE file distributed with this source code. */ +declare(strict_types=1); + namespace Ibexa\Tests\Core\Persistence\ValueObject; use Ibexa\Contracts\Core\Persistence\Content\ContentInfo; From cd9d9ddd9bee93175edaa0e0f1d0b8144b3b5bbb Mon Sep 17 00:00:00 2001 From: matx132 <mateusz@mateuszdebinski.pl> Date: Thu, 25 Jul 2024 10:41:11 +0200 Subject: [PATCH 07/11] Added BeforeLoadContentEvent --- phpstan-baseline.neon | 5 + .../Events/Content/BeforeLoadContentEvent.php | 84 ++++++++++++++ src/lib/Event/ContentService.php | 26 +++++ src/lib/Persistence/Legacy/Content/Mapper.php | 2 +- tests/lib/Event/AbstractServiceTest.php | 7 +- tests/lib/Event/ContentServiceTest.php | 106 ++++++++++++++++++ 6 files changed, 227 insertions(+), 3 deletions(-) create mode 100644 src/contracts/Repository/Events/Content/BeforeLoadContentEvent.php diff --git a/phpstan-baseline.neon b/phpstan-baseline.neon index cba4316dd0..1d2c3996b9 100644 --- a/phpstan-baseline.neon +++ b/phpstan-baseline.neon @@ -62469,3 +62469,8 @@ parameters: message: "#^Method Ibexa\\\\Tests\\\\Core\\\\Specification\\\\Content\\\\ContentTypeSpecificationTest\\:\\:providerForIsSatisfiedBy\\(\\) return type has no value type specified in iterable type array\\.$#" count: 1 path: tests/lib/Specification/Content/ContentTypeSpecificationTest.php + + - + message: "#^Method Ibexa\\\\Contracts\\\\Core\\\\Repository\\\\Events\\\\Content\\\\BeforeLoadContentEvent\\:\\:getContent\\(\\) should return Ibexa\\\\Contracts\\\\Core\\\\Repository\\\\Values\\\\Content\\\\Content but returns Ibexa\\\\Contracts\\\\Core\\\\Repository\\\\Values\\\\Content\\\\Content\\|null\\.$#" + count: 1 + path: src/contracts/Repository/Events/Content/BeforeLoadContentEvent.php \ No newline at end of file diff --git a/src/contracts/Repository/Events/Content/BeforeLoadContentEvent.php b/src/contracts/Repository/Events/Content/BeforeLoadContentEvent.php new file mode 100644 index 0000000000..f92029d286 --- /dev/null +++ b/src/contracts/Repository/Events/Content/BeforeLoadContentEvent.php @@ -0,0 +1,84 @@ +<?php + +/** + * @copyright Copyright (C) Ibexa AS. All rights reserved. + * @license For full copyright and license information view LICENSE file distributed with this source code. + */ +declare(strict_types=1); + +namespace Ibexa\Contracts\Core\Repository\Events\Content; + +use Ibexa\Contracts\Core\Repository\Event\BeforeEvent; +use Ibexa\Contracts\Core\Repository\Values\Content\Content; +use UnexpectedValueException; + +final class BeforeLoadContentEvent extends BeforeEvent +{ + private int $contentId; + + /** @var string[]|null */ + private ?array $languages; + + private ?int $versionNo; + + private bool $useAlwaysAvailable; + + private ?Content $content = null; + + /** + * @param string[] $languages + */ + public function __construct( + int $contentId, + array $languages = null, + ?int $versionNo = null, + bool $useAlwaysAvailable = true + ) { + $this->contentId = $contentId; + $this->languages = $languages; + $this->versionNo = $versionNo; + $this->useAlwaysAvailable = $useAlwaysAvailable; + } + + public function getContentId(): int + { + return $this->contentId; + } + + /** + * @return string[]|null + */ + public function getLanguages(): ?array + { + return $this->languages; + } + + public function getVersionNo(): ?int + { + return $this->versionNo; + } + + public function getUseAlwaysAvailable(): bool + { + return $this->useAlwaysAvailable; + } + + public function getContent(): Content + { + if (!$this->hasContent()) { + throw new UnexpectedValueException(sprintf('Return value is not set or not of type %s. Check hasContent() or set it using setContent() before you call the getter.', Content::class)); + } + + return $this->content; + } + + public function setContent(?Content $content): void + { + $this->content = $content; + } + + public function hasContent(): bool + { + return $this->content instanceof Content; + } +} diff --git a/src/lib/Event/ContentService.php b/src/lib/Event/ContentService.php index dee89f597c..e17e2cf34f 100644 --- a/src/lib/Event/ContentService.php +++ b/src/lib/Event/ContentService.php @@ -20,6 +20,7 @@ use Ibexa\Contracts\Core\Repository\Events\Content\BeforeDeleteTranslationEvent; use Ibexa\Contracts\Core\Repository\Events\Content\BeforeDeleteVersionEvent; use Ibexa\Contracts\Core\Repository\Events\Content\BeforeHideContentEvent; +use Ibexa\Contracts\Core\Repository\Events\Content\BeforeLoadContentEvent; use Ibexa\Contracts\Core\Repository\Events\Content\BeforePublishVersionEvent; use Ibexa\Contracts\Core\Repository\Events\Content\BeforeRevealContentEvent; use Ibexa\Contracts\Core\Repository\Events\Content\BeforeUpdateContentEvent; @@ -380,6 +381,31 @@ public function revealContent(ContentInfo $contentInfo): void new RevealContentEvent(...$eventData) ); } + + public function loadContent( + int $contentId, + array $languages = null, + ?int $versionNo = null, + bool $useAlwaysAvailable = true + ): Content { + $eventData = [ + $contentId, + $languages, + $versionNo, + $useAlwaysAvailable, + ]; + + $beforeEvent = new BeforeLoadContentEvent(...$eventData); + + $this->eventDispatcher->dispatch($beforeEvent); + if ($beforeEvent->isPropagationStopped()) { + return $beforeEvent->getContent(); + } + + return $beforeEvent->hasContent() + ? $beforeEvent->getContent() + : $this->innerService->loadContent($contentId, $languages, $versionNo, $useAlwaysAvailable); + } } class_alias(ContentService::class, 'eZ\Publish\Core\Event\ContentService'); diff --git a/src/lib/Persistence/Legacy/Content/Mapper.php b/src/lib/Persistence/Legacy/Content/Mapper.php index 53d53a5e37..1509fd6688 100644 --- a/src/lib/Persistence/Legacy/Content/Mapper.php +++ b/src/lib/Persistence/Legacy/Content/Mapper.php @@ -388,7 +388,7 @@ public function extractContentInfoFromRow( $contentInfo->id = (int)$row["{$prefix}id"]; $contentInfo->name = (string)$row["{$prefix}name"]; $contentInfo->contentTypeId = (int)$row["{$prefix}contentclass_id"]; - $contentInfo->contentTypeIdentifier = $row['content_type_identifier']; + $contentInfo->contentTypeIdentifier = (string)$row['content_type_identifier']; $contentInfo->sectionId = (int)$row["{$prefix}section_id"]; $contentInfo->currentVersionNo = (int)$row["{$prefix}current_version"]; $contentInfo->ownerId = (int)$row["{$prefix}owner_id"]; diff --git a/tests/lib/Event/AbstractServiceTest.php b/tests/lib/Event/AbstractServiceTest.php index 8dd461c73c..6f0633b599 100644 --- a/tests/lib/Event/AbstractServiceTest.php +++ b/tests/lib/Event/AbstractServiceTest.php @@ -15,11 +15,14 @@ abstract class AbstractServiceTest extends TestCase { - public function getEventDispatcher(string $beforeEventName, string $eventName): TraceableEventDispatcher + public function getEventDispatcher(string $beforeEventName, ?string $eventName): TraceableEventDispatcher { $eventDispatcher = new EventDispatcher(); $eventDispatcher->addListener($beforeEventName, static function (BeforeEvent $event) {}); - $eventDispatcher->addListener($eventName, static function (AfterEvent $event) {}); + if ($eventName !== null) { + $eventDispatcher->addListener($eventName, static function (AfterEvent $event) { + }); + } return new TraceableEventDispatcher( $eventDispatcher, diff --git a/tests/lib/Event/ContentServiceTest.php b/tests/lib/Event/ContentServiceTest.php index 3a5761249b..f85d9919e1 100644 --- a/tests/lib/Event/ContentServiceTest.php +++ b/tests/lib/Event/ContentServiceTest.php @@ -17,6 +17,7 @@ use Ibexa\Contracts\Core\Repository\Events\Content\BeforeDeleteTranslationEvent; use Ibexa\Contracts\Core\Repository\Events\Content\BeforeDeleteVersionEvent; use Ibexa\Contracts\Core\Repository\Events\Content\BeforeHideContentEvent; +use Ibexa\Contracts\Core\Repository\Events\Content\BeforeLoadContentEvent; use Ibexa\Contracts\Core\Repository\Events\Content\BeforePublishVersionEvent; use Ibexa\Contracts\Core\Repository\Events\Content\BeforeRevealContentEvent; use Ibexa\Contracts\Core\Repository\Events\Content\BeforeUpdateContentEvent; @@ -1153,6 +1154,111 @@ public function testRevealContentStopPropagationInBeforeEvents() [RevealContentEvent::class, 0], ]); } + + public function testLoadContentEvents(): void + { + $traceableEventDispatcher = $this->getEventDispatcher( + BeforeLoadContentEvent::class, + null + ); + + $parameters = [ + 2, + [], + null, + true, + ]; + + $content = $this->createMock(Content::class); + $innerServiceMock = $this->createMock(ContentServiceInterface::class); + $innerServiceMock->method('loadContent')->willReturn($content); + + $service = new ContentService($innerServiceMock, $traceableEventDispatcher); + $result = $service->loadContent(...$parameters); + + $calledListeners = $this->getListenersStack($traceableEventDispatcher->getCalledListeners()); + + $this->assertSame($content, $result); + $this->assertSame($calledListeners, [ + [BeforeLoadContentEvent::class, 0], + ]); + $this->assertSame([], $traceableEventDispatcher->getNotCalledListeners()); + } + + public function testReturnLoadContentResultInBeforeEvents(): void + { + $traceableEventDispatcher = $this->getEventDispatcher( + BeforeLoadContentEvent::class, + null + ); + + $parameters = [ + 2, + [], + null, + true, + ]; + + $content = $this->createMock(Content::class); + $eventContent = $this->createMock(Content::class); + $innerServiceMock = $this->createMock(ContentServiceInterface::class); + $innerServiceMock->method('loadContent')->willReturn($content); + + $traceableEventDispatcher->addListener(BeforeLoadContentEvent::class, static function (BeforeLoadContentEvent $event) use ($eventContent) { + $event->setContent($eventContent); + }, 10); + + $service = new ContentService($innerServiceMock, $traceableEventDispatcher); + $result = $service->loadContent(...$parameters); + + $calledListeners = $this->getListenersStack($traceableEventDispatcher->getCalledListeners()); + + $this->assertSame($eventContent, $result); + $this->assertSame($calledListeners, [ + [BeforeLoadContentEvent::class, 10], + [BeforeLoadContentEvent::class, 0], + ]); + $this->assertSame([], $traceableEventDispatcher->getNotCalledListeners()); + } + + public function testLoadContentStopPropagationInBeforeEvents(): void + { + $traceableEventDispatcher = $this->getEventDispatcher( + BeforeLoadContentEvent::class, + null + ); + + $parameters = [ + 2, + [], + null, + true, + ]; + + $content = $this->createMock(Content::class); + $eventContent = $this->createMock(Content::class); + $innerServiceMock = $this->createMock(ContentServiceInterface::class); + $innerServiceMock->method('loadContent')->willReturn($content); + + $traceableEventDispatcher->addListener(BeforeLoadContentEvent::class, static function (BeforeLoadContentEvent $event) use ($eventContent) { + $event->setContent($eventContent); + $event->stopPropagation(); + }, 10); + + $service = new ContentService($innerServiceMock, $traceableEventDispatcher); + $result = $service->loadContent(...$parameters); + + $calledListeners = $this->getListenersStack($traceableEventDispatcher->getCalledListeners()); + $notCalledListeners = $this->getListenersStack($traceableEventDispatcher->getNotCalledListeners()); + + $this->assertSame($eventContent, $result); + $this->assertSame($calledListeners, [ + [BeforeLoadContentEvent::class, 10], + ]); + $this->assertSame($notCalledListeners, [ + [BeforeLoadContentEvent::class, 0], + ]); + } } class_alias(ContentServiceTest::class, 'eZ\Publish\Core\Event\Tests\ContentServiceTest'); From 52431c5cc3a15118c55b439aadc041912914d1b3 Mon Sep 17 00:00:00 2001 From: matx132 <mateusz@mateuszdebinski.pl> Date: Fri, 26 Jul 2024 16:28:01 +0200 Subject: [PATCH 08/11] Corrected CS --- phpstan-baseline.neon | 5 ----- .../Events/Content/BeforeLoadContentEvent.php | 8 +++++++- tests/lib/Event/ContentServiceTest.php | 20 +++---------------- 3 files changed, 10 insertions(+), 23 deletions(-) diff --git a/phpstan-baseline.neon b/phpstan-baseline.neon index 1d2c3996b9..cba4316dd0 100644 --- a/phpstan-baseline.neon +++ b/phpstan-baseline.neon @@ -62469,8 +62469,3 @@ parameters: message: "#^Method Ibexa\\\\Tests\\\\Core\\\\Specification\\\\Content\\\\ContentTypeSpecificationTest\\:\\:providerForIsSatisfiedBy\\(\\) return type has no value type specified in iterable type array\\.$#" count: 1 path: tests/lib/Specification/Content/ContentTypeSpecificationTest.php - - - - message: "#^Method Ibexa\\\\Contracts\\\\Core\\\\Repository\\\\Events\\\\Content\\\\BeforeLoadContentEvent\\:\\:getContent\\(\\) should return Ibexa\\\\Contracts\\\\Core\\\\Repository\\\\Values\\\\Content\\\\Content but returns Ibexa\\\\Contracts\\\\Core\\\\Repository\\\\Values\\\\Content\\\\Content\\|null\\.$#" - count: 1 - path: src/contracts/Repository/Events/Content/BeforeLoadContentEvent.php \ No newline at end of file diff --git a/src/contracts/Repository/Events/Content/BeforeLoadContentEvent.php b/src/contracts/Repository/Events/Content/BeforeLoadContentEvent.php index f92029d286..c8910b5279 100644 --- a/src/contracts/Repository/Events/Content/BeforeLoadContentEvent.php +++ b/src/contracts/Repository/Events/Content/BeforeLoadContentEvent.php @@ -66,7 +66,12 @@ public function getUseAlwaysAvailable(): bool public function getContent(): Content { if (!$this->hasContent()) { - throw new UnexpectedValueException(sprintf('Return value is not set or not of type %s. Check hasContent() or set it using setContent() before you call the getter.', Content::class)); + throw new UnexpectedValueException( + sprintf( + 'Return value is not set or not of type %s. Check hasContent() or set it using setContent() before you call the getter.', + Content::class + ) + ); } return $this->content; @@ -77,6 +82,7 @@ public function setContent(?Content $content): void $this->content = $content; } + /** @phpstan-assert-if-true !null $this->content */ public function hasContent(): bool { return $this->content instanceof Content; diff --git a/tests/lib/Event/ContentServiceTest.php b/tests/lib/Event/ContentServiceTest.php index f85d9919e1..84fd020e88 100644 --- a/tests/lib/Event/ContentServiceTest.php +++ b/tests/lib/Event/ContentServiceTest.php @@ -1162,19 +1162,12 @@ public function testLoadContentEvents(): void null ); - $parameters = [ - 2, - [], - null, - true, - ]; - $content = $this->createMock(Content::class); $innerServiceMock = $this->createMock(ContentServiceInterface::class); $innerServiceMock->method('loadContent')->willReturn($content); $service = new ContentService($innerServiceMock, $traceableEventDispatcher); - $result = $service->loadContent(...$parameters); + $result = $service->loadContent(2, []); $calledListeners = $this->getListenersStack($traceableEventDispatcher->getCalledListeners()); @@ -1209,7 +1202,7 @@ public function testReturnLoadContentResultInBeforeEvents(): void }, 10); $service = new ContentService($innerServiceMock, $traceableEventDispatcher); - $result = $service->loadContent(...$parameters); + $result = $service->loadContent(2, []); $calledListeners = $this->getListenersStack($traceableEventDispatcher->getCalledListeners()); @@ -1228,13 +1221,6 @@ public function testLoadContentStopPropagationInBeforeEvents(): void null ); - $parameters = [ - 2, - [], - null, - true, - ]; - $content = $this->createMock(Content::class); $eventContent = $this->createMock(Content::class); $innerServiceMock = $this->createMock(ContentServiceInterface::class); @@ -1246,7 +1232,7 @@ public function testLoadContentStopPropagationInBeforeEvents(): void }, 10); $service = new ContentService($innerServiceMock, $traceableEventDispatcher); - $result = $service->loadContent(...$parameters); + $result = $service->loadContent(2, []); $calledListeners = $this->getListenersStack($traceableEventDispatcher->getCalledListeners()); $notCalledListeners = $this->getListenersStack($traceableEventDispatcher->getNotCalledListeners()); From 1b2205b320ea09cbbc26d038dd7a5fb9ef825dfe Mon Sep 17 00:00:00 2001 From: matx132 <mateusz@mateuszdebinski.pl> Date: Tue, 14 Jan 2025 11:02:24 +0100 Subject: [PATCH 09/11] Added missing LoadContentEvent after loadContent --- .../Events/Content/LoadContentEvent.php | 71 +++++++++++++++++++ src/lib/Event/ContentService.php | 9 ++- tests/lib/Event/AbstractServiceTest.php | 7 +- tests/lib/Event/ContentServiceTest.php | 17 ++--- 4 files changed, 88 insertions(+), 16 deletions(-) create mode 100644 src/contracts/Repository/Events/Content/LoadContentEvent.php diff --git a/src/contracts/Repository/Events/Content/LoadContentEvent.php b/src/contracts/Repository/Events/Content/LoadContentEvent.php new file mode 100644 index 0000000000..4bf18cd089 --- /dev/null +++ b/src/contracts/Repository/Events/Content/LoadContentEvent.php @@ -0,0 +1,71 @@ +<?php + +/** + * @copyright Copyright (C) Ibexa AS. All rights reserved. + * @license For full copyright and license information view LICENSE file distributed with this source code. + */ +declare(strict_types=1); + +namespace Ibexa\Contracts\Core\Repository\Events\Content; + +use Ibexa\Contracts\Core\Repository\Event\AfterEvent; +use Ibexa\Contracts\Core\Repository\Values\Content\Content; + +final class LoadContentEvent extends AfterEvent +{ + private int $contentId; + + private Content $content; + + /** @var string[]|null */ + private ?array $languages; + + private ?int $versionNo; + + private bool $useAlwaysAvailable; + + /** + * @param string[] $languages + */ + public function __construct( + Content $content, + int $contentId, + array $languages = null, + ?int $versionNo = null, + bool $useAlwaysAvailable = true + ) { + $this->contentId = $contentId; + $this->content = $content; + $this->languages = $languages; + $this->versionNo = $versionNo; + $this->useAlwaysAvailable = $useAlwaysAvailable; + } + + public function getContent(): Content + { + return $this->content; + } + + /** + * @return string[]|null + */ + public function getLanguages(): ?array + { + return $this->languages; + } + + public function getVersionNo(): ?int + { + return $this->versionNo; + } + + public function getUseAlwaysAvailable(): bool + { + return $this->useAlwaysAvailable; + } + + public function getContentId(): int + { + return $this->contentId; + } +} diff --git a/src/lib/Event/ContentService.php b/src/lib/Event/ContentService.php index e17e2cf34f..2ed15452bd 100644 --- a/src/lib/Event/ContentService.php +++ b/src/lib/Event/ContentService.php @@ -33,6 +33,7 @@ use Ibexa\Contracts\Core\Repository\Events\Content\DeleteTranslationEvent; use Ibexa\Contracts\Core\Repository\Events\Content\DeleteVersionEvent; use Ibexa\Contracts\Core\Repository\Events\Content\HideContentEvent; +use Ibexa\Contracts\Core\Repository\Events\Content\LoadContentEvent; use Ibexa\Contracts\Core\Repository\Events\Content\PublishVersionEvent; use Ibexa\Contracts\Core\Repository\Events\Content\RevealContentEvent; use Ibexa\Contracts\Core\Repository\Events\Content\UpdateContentEvent; @@ -402,9 +403,15 @@ public function loadContent( return $beforeEvent->getContent(); } - return $beforeEvent->hasContent() + $content = $beforeEvent->hasContent() ? $beforeEvent->getContent() : $this->innerService->loadContent($contentId, $languages, $versionNo, $useAlwaysAvailable); + + $this->eventDispatcher->dispatch( + new LoadContentEvent($content, ...$eventData) + ); + + return $content; } } diff --git a/tests/lib/Event/AbstractServiceTest.php b/tests/lib/Event/AbstractServiceTest.php index 6f0633b599..8dd461c73c 100644 --- a/tests/lib/Event/AbstractServiceTest.php +++ b/tests/lib/Event/AbstractServiceTest.php @@ -15,14 +15,11 @@ abstract class AbstractServiceTest extends TestCase { - public function getEventDispatcher(string $beforeEventName, ?string $eventName): TraceableEventDispatcher + public function getEventDispatcher(string $beforeEventName, string $eventName): TraceableEventDispatcher { $eventDispatcher = new EventDispatcher(); $eventDispatcher->addListener($beforeEventName, static function (BeforeEvent $event) {}); - if ($eventName !== null) { - $eventDispatcher->addListener($eventName, static function (AfterEvent $event) { - }); - } + $eventDispatcher->addListener($eventName, static function (AfterEvent $event) {}); return new TraceableEventDispatcher( $eventDispatcher, diff --git a/tests/lib/Event/ContentServiceTest.php b/tests/lib/Event/ContentServiceTest.php index 84fd020e88..1e38abc36a 100644 --- a/tests/lib/Event/ContentServiceTest.php +++ b/tests/lib/Event/ContentServiceTest.php @@ -30,6 +30,7 @@ use Ibexa\Contracts\Core\Repository\Events\Content\DeleteTranslationEvent; use Ibexa\Contracts\Core\Repository\Events\Content\DeleteVersionEvent; use Ibexa\Contracts\Core\Repository\Events\Content\HideContentEvent; +use Ibexa\Contracts\Core\Repository\Events\Content\LoadContentEvent; use Ibexa\Contracts\Core\Repository\Events\Content\PublishVersionEvent; use Ibexa\Contracts\Core\Repository\Events\Content\RevealContentEvent; use Ibexa\Contracts\Core\Repository\Events\Content\UpdateContentEvent; @@ -1159,7 +1160,7 @@ public function testLoadContentEvents(): void { $traceableEventDispatcher = $this->getEventDispatcher( BeforeLoadContentEvent::class, - null + LoadContentEvent::class ); $content = $this->createMock(Content::class); @@ -1174,6 +1175,7 @@ public function testLoadContentEvents(): void $this->assertSame($content, $result); $this->assertSame($calledListeners, [ [BeforeLoadContentEvent::class, 0], + [LoadContentEvent::class, 0], ]); $this->assertSame([], $traceableEventDispatcher->getNotCalledListeners()); } @@ -1182,16 +1184,9 @@ public function testReturnLoadContentResultInBeforeEvents(): void { $traceableEventDispatcher = $this->getEventDispatcher( BeforeLoadContentEvent::class, - null + LoadContentEvent::class ); - $parameters = [ - 2, - [], - null, - true, - ]; - $content = $this->createMock(Content::class); $eventContent = $this->createMock(Content::class); $innerServiceMock = $this->createMock(ContentServiceInterface::class); @@ -1210,6 +1205,7 @@ public function testReturnLoadContentResultInBeforeEvents(): void $this->assertSame($calledListeners, [ [BeforeLoadContentEvent::class, 10], [BeforeLoadContentEvent::class, 0], + [LoadContentEvent::class, 0], ]); $this->assertSame([], $traceableEventDispatcher->getNotCalledListeners()); } @@ -1218,7 +1214,7 @@ public function testLoadContentStopPropagationInBeforeEvents(): void { $traceableEventDispatcher = $this->getEventDispatcher( BeforeLoadContentEvent::class, - null + LoadContentEvent::class ); $content = $this->createMock(Content::class); @@ -1243,6 +1239,7 @@ public function testLoadContentStopPropagationInBeforeEvents(): void ]); $this->assertSame($notCalledListeners, [ [BeforeLoadContentEvent::class, 0], + [LoadContentEvent::class, 0], ]); } } From 0b497c3d8fde3622cdfafbd9378c71e59508cdbc Mon Sep 17 00:00:00 2001 From: matx132 <mateusz@mateuszdebinski.pl> Date: Tue, 14 Jan 2025 11:52:58 +0100 Subject: [PATCH 10/11] Corrected CS --- tests/lib/Event/ContentServiceTest.php | 40 +++++++++++++++----------- 1 file changed, 24 insertions(+), 16 deletions(-) diff --git a/tests/lib/Event/ContentServiceTest.php b/tests/lib/Event/ContentServiceTest.php index 1e38abc36a..49aeaeaf58 100644 --- a/tests/lib/Event/ContentServiceTest.php +++ b/tests/lib/Event/ContentServiceTest.php @@ -1172,12 +1172,12 @@ public function testLoadContentEvents(): void $calledListeners = $this->getListenersStack($traceableEventDispatcher->getCalledListeners()); - $this->assertSame($content, $result); - $this->assertSame($calledListeners, [ + self::assertSame($content, $result); + self::assertSame($calledListeners, [ [BeforeLoadContentEvent::class, 0], [LoadContentEvent::class, 0], ]); - $this->assertSame([], $traceableEventDispatcher->getNotCalledListeners()); + self::assertSame([], $traceableEventDispatcher->getNotCalledListeners()); } public function testReturnLoadContentResultInBeforeEvents(): void @@ -1192,22 +1192,26 @@ public function testReturnLoadContentResultInBeforeEvents(): void $innerServiceMock = $this->createMock(ContentServiceInterface::class); $innerServiceMock->method('loadContent')->willReturn($content); - $traceableEventDispatcher->addListener(BeforeLoadContentEvent::class, static function (BeforeLoadContentEvent $event) use ($eventContent) { - $event->setContent($eventContent); - }, 10); + $traceableEventDispatcher->addListener( + BeforeLoadContentEvent::class, + static function (BeforeLoadContentEvent $event) use ($eventContent) { + $event->setContent($eventContent); + }, + 10 + ); $service = new ContentService($innerServiceMock, $traceableEventDispatcher); $result = $service->loadContent(2, []); $calledListeners = $this->getListenersStack($traceableEventDispatcher->getCalledListeners()); - $this->assertSame($eventContent, $result); - $this->assertSame($calledListeners, [ + self::assertSame($eventContent, $result); + self::assertSame($calledListeners, [ [BeforeLoadContentEvent::class, 10], [BeforeLoadContentEvent::class, 0], [LoadContentEvent::class, 0], ]); - $this->assertSame([], $traceableEventDispatcher->getNotCalledListeners()); + self::assertSame([], $traceableEventDispatcher->getNotCalledListeners()); } public function testLoadContentStopPropagationInBeforeEvents(): void @@ -1222,10 +1226,14 @@ public function testLoadContentStopPropagationInBeforeEvents(): void $innerServiceMock = $this->createMock(ContentServiceInterface::class); $innerServiceMock->method('loadContent')->willReturn($content); - $traceableEventDispatcher->addListener(BeforeLoadContentEvent::class, static function (BeforeLoadContentEvent $event) use ($eventContent) { - $event->setContent($eventContent); - $event->stopPropagation(); - }, 10); + $traceableEventDispatcher->addListener( + BeforeLoadContentEvent::class, + static function (BeforeLoadContentEvent $event) use ($eventContent) { + $event->setContent($eventContent); + $event->stopPropagation(); + }, + 10 + ); $service = new ContentService($innerServiceMock, $traceableEventDispatcher); $result = $service->loadContent(2, []); @@ -1233,11 +1241,11 @@ public function testLoadContentStopPropagationInBeforeEvents(): void $calledListeners = $this->getListenersStack($traceableEventDispatcher->getCalledListeners()); $notCalledListeners = $this->getListenersStack($traceableEventDispatcher->getNotCalledListeners()); - $this->assertSame($eventContent, $result); - $this->assertSame($calledListeners, [ + self::assertSame($eventContent, $result); + self::assertSame($calledListeners, [ [BeforeLoadContentEvent::class, 10], ]); - $this->assertSame($notCalledListeners, [ + self::assertSame($notCalledListeners, [ [BeforeLoadContentEvent::class, 0], [LoadContentEvent::class, 0], ]); From 0f06579ace7e52552952d4f08cfb3d434f9e81eb Mon Sep 17 00:00:00 2001 From: matx132 <mateusz@mateuszdebinski.pl> Date: Wed, 22 Jan 2025 12:54:54 +0100 Subject: [PATCH 11/11] Corrected CS --- .../Repository/Events/Content/BeforeLoadContentEvent.php | 2 +- src/contracts/Repository/Events/Content/LoadContentEvent.php | 2 +- src/lib/Event/ContentService.php | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/src/contracts/Repository/Events/Content/BeforeLoadContentEvent.php b/src/contracts/Repository/Events/Content/BeforeLoadContentEvent.php index c8910b5279..dfa12d96f1 100644 --- a/src/contracts/Repository/Events/Content/BeforeLoadContentEvent.php +++ b/src/contracts/Repository/Events/Content/BeforeLoadContentEvent.php @@ -30,7 +30,7 @@ final class BeforeLoadContentEvent extends BeforeEvent */ public function __construct( int $contentId, - array $languages = null, + ?array $languages = null, ?int $versionNo = null, bool $useAlwaysAvailable = true ) { diff --git a/src/contracts/Repository/Events/Content/LoadContentEvent.php b/src/contracts/Repository/Events/Content/LoadContentEvent.php index 4bf18cd089..71b6a4d9b0 100644 --- a/src/contracts/Repository/Events/Content/LoadContentEvent.php +++ b/src/contracts/Repository/Events/Content/LoadContentEvent.php @@ -30,7 +30,7 @@ final class LoadContentEvent extends AfterEvent public function __construct( Content $content, int $contentId, - array $languages = null, + ?array $languages = null, ?int $versionNo = null, bool $useAlwaysAvailable = true ) { diff --git a/src/lib/Event/ContentService.php b/src/lib/Event/ContentService.php index 2ed15452bd..1a744d9907 100644 --- a/src/lib/Event/ContentService.php +++ b/src/lib/Event/ContentService.php @@ -385,7 +385,7 @@ public function revealContent(ContentInfo $contentInfo): void public function loadContent( int $contentId, - array $languages = null, + ?array $languages = null, ?int $versionNo = null, bool $useAlwaysAvailable = true ): Content {