Code Duplication    Length = 41-41 lines in 3 locations

eZ/Publish/Core/Persistence/Legacy/Tests/Content/Location/Gateway/DoctrineDatabaseTest.php 3 locations

@@ 991-1031 (lines=41) @@
988
    /**
989
     * @depends testCreateLocationNodeAssignmentCreation
990
     */
991
    public function testConvertNodeAssignmentsMainLocation()
992
    {
993
        $this->insertDatabaseFixture(__DIR__ . '/_fixtures/full_example_tree.php');
994
995
        $handler = $this->getLocationGateway();
996
        $handler->createNodeAssignment(
997
            new CreateStruct(
998
                [
999
                    'contentId' => 68,
1000
                    'contentVersion' => 1,
1001
                    'mainLocationId' => true,
1002
                    'priority' => 101,
1003
                    'remoteId' => 'some_id',
1004
                    'sortField' => 1,
1005
                    'sortOrder' => 1,
1006
                    'hidden' => true,
1007
                    // Note: not stored in node assignment, will be calculated from parent
1008
                    // visibility upon Location creation from node assignment
1009
                    'invisible' => false,
1010
                ]
1011
            ),
1012
            '77',
1013
            DoctrineDatabase::NODE_ASSIGNMENT_OP_CODE_CREATE
1014
        );
1015
1016
        $handler->createLocationsFromNodeAssignments(68, 1);
1017
1018
        $query = $this->handler->createSelectQuery();
1019
        $this->assertQueryResult(
1020
            [[228]],
1021
            $query
1022
                ->select('main_node_id')
1023
                ->from('ezcontentobject_tree')
1024
                ->where(
1025
                    $query->expr->lAnd(
1026
                        $query->expr->eq('contentobject_id', 68),
1027
                        $query->expr->eq('parent_node_id', 77)
1028
                    )
1029
                )
1030
        );
1031
    }
1032
1033
    /**
1034
     * @depends testCreateLocationNodeAssignmentCreation
@@ 1036-1076 (lines=41) @@
1033
    /**
1034
     * @depends testCreateLocationNodeAssignmentCreation
1035
     */
1036
    public function testConvertNodeAssignmentsParentHidden()
1037
    {
1038
        $this->insertDatabaseFixture(__DIR__ . '/_fixtures/full_example_tree.php');
1039
1040
        $handler = $this->getLocationGateway();
1041
        $handler->createNodeAssignment(
1042
            new CreateStruct(
1043
                [
1044
                    'contentId' => 68,
1045
                    'contentVersion' => 1,
1046
                    'mainLocationId' => true,
1047
                    'priority' => 101,
1048
                    'remoteId' => 'some_id',
1049
                    'sortField' => 1,
1050
                    'sortOrder' => 1,
1051
                    'hidden' => false,
1052
                    // Note: not stored in node assignment, will be calculated from parent
1053
                    // visibility upon Location creation from node assignment
1054
                    'invisible' => false,
1055
                ]
1056
            ),
1057
            '224',
1058
            DoctrineDatabase::NODE_ASSIGNMENT_OP_CODE_CREATE
1059
        );
1060
1061
        $handler->createLocationsFromNodeAssignments(68, 1);
1062
1063
        $query = $this->handler->createSelectQuery();
1064
        $this->assertQueryResult(
1065
            [[0, 1]],
1066
            $query
1067
                ->select('is_hidden, is_invisible')
1068
                ->from('ezcontentobject_tree')
1069
                ->where(
1070
                    $query->expr->lAnd(
1071
                        $query->expr->eq('contentobject_id', 68),
1072
                        $query->expr->eq('parent_node_id', 224)
1073
                    )
1074
                )
1075
        );
1076
    }
1077
1078
    /**
1079
     * @depends testCreateLocationNodeAssignmentCreation
@@ 1081-1121 (lines=41) @@
1078
    /**
1079
     * @depends testCreateLocationNodeAssignmentCreation
1080
     */
1081
    public function testConvertNodeAssignmentsParentInvisible()
1082
    {
1083
        $this->insertDatabaseFixture(__DIR__ . '/_fixtures/full_example_tree.php');
1084
1085
        $handler = $this->getLocationGateway();
1086
        $handler->createNodeAssignment(
1087
            new CreateStruct(
1088
                [
1089
                    'contentId' => 68,
1090
                    'contentVersion' => 1,
1091
                    'mainLocationId' => true,
1092
                    'priority' => 101,
1093
                    'remoteId' => 'some_id',
1094
                    'sortField' => 1,
1095
                    'sortOrder' => 1,
1096
                    'hidden' => false,
1097
                    // Note: not stored in node assignment, will be calculated from parent
1098
                    // visibility upon Location creation from node assignment
1099
                    'invisible' => false,
1100
                ]
1101
            ),
1102
            '225',
1103
            DoctrineDatabase::NODE_ASSIGNMENT_OP_CODE_CREATE
1104
        );
1105
1106
        $handler->createLocationsFromNodeAssignments(68, 1);
1107
1108
        $query = $this->handler->createSelectQuery();
1109
        $this->assertQueryResult(
1110
            [[0, 1]],
1111
            $query
1112
                ->select('is_hidden, is_invisible')
1113
                ->from('ezcontentobject_tree')
1114
                ->where(
1115
                    $query->expr->lAnd(
1116
                        $query->expr->eq('contentobject_id', 68),
1117
                        $query->expr->eq('parent_node_id', 225)
1118
                    )
1119
                )
1120
        );
1121
    }
1122
1123
    /**
1124
     * @depends testCreateLocationNodeAssignmentCreation