Code Duplication    Length = 41-41 lines in 3 locations

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

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