Code Duplication    Length = 41-41 lines in 3 locations

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

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