Code Duplication    Length = 41-41 lines in 3 locations

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

@@ 905-945 (lines=41) @@
902
    /**
903
     * @depends testCreateLocationNodeAssignmentCreation
904
     */
905
    public function testConvertNodeAssignmentsMainLocation()
906
    {
907
        $this->insertDatabaseFixture(__DIR__ . '/_fixtures/full_example_tree.php');
908
909
        $handler = $this->getLocationGateway();
910
        $handler->createNodeAssignment(
911
            new CreateStruct(
912
                array(
913
                    'contentId' => 68,
914
                    'contentVersion' => 1,
915
                    'mainLocationId' => true,
916
                    'priority' => 101,
917
                    'remoteId' => 'some_id',
918
                    'sortField' => 1,
919
                    'sortOrder' => 1,
920
                    'hidden' => true,
921
                    // Note: not stored in node assignment, will be calculated from parent
922
                    // visibility upon Location creation from node assignment
923
                    'invisible' => false,
924
                )
925
            ),
926
            '77',
927
            DoctrineDatabase::NODE_ASSIGNMENT_OP_CODE_CREATE
928
        );
929
930
        $handler->createLocationsFromNodeAssignments(68, 1);
931
932
        $query = $this->handler->createSelectQuery();
933
        $this->assertQueryResult(
934
            array(array(228)),
935
            $query
936
                ->select('main_node_id')
937
                ->from('ezcontentobject_tree')
938
                ->where(
939
                    $query->expr->lAnd(
940
                        $query->expr->eq('contentobject_id', 68),
941
                        $query->expr->eq('parent_node_id', 77)
942
                    )
943
                )
944
        );
945
    }
946
947
    /**
948
     * @depends testCreateLocationNodeAssignmentCreation
@@ 950-990 (lines=41) @@
947
    /**
948
     * @depends testCreateLocationNodeAssignmentCreation
949
     */
950
    public function testConvertNodeAssignmentsParentHidden()
951
    {
952
        $this->insertDatabaseFixture(__DIR__ . '/_fixtures/full_example_tree.php');
953
954
        $handler = $this->getLocationGateway();
955
        $handler->createNodeAssignment(
956
            new CreateStruct(
957
                array(
958
                    'contentId' => 68,
959
                    'contentVersion' => 1,
960
                    'mainLocationId' => true,
961
                    'priority' => 101,
962
                    'remoteId' => 'some_id',
963
                    'sortField' => 1,
964
                    'sortOrder' => 1,
965
                    'hidden' => false,
966
                    // Note: not stored in node assignment, will be calculated from parent
967
                    // visibility upon Location creation from node assignment
968
                    'invisible' => false,
969
                )
970
            ),
971
            '224',
972
            DoctrineDatabase::NODE_ASSIGNMENT_OP_CODE_CREATE
973
        );
974
975
        $handler->createLocationsFromNodeAssignments(68, 1);
976
977
        $query = $this->handler->createSelectQuery();
978
        $this->assertQueryResult(
979
            array(array(0, 1)),
980
            $query
981
                ->select('is_hidden, is_invisible')
982
                ->from('ezcontentobject_tree')
983
                ->where(
984
                    $query->expr->lAnd(
985
                        $query->expr->eq('contentobject_id', 68),
986
                        $query->expr->eq('parent_node_id', 224)
987
                    )
988
                )
989
        );
990
    }
991
992
    /**
993
     * @depends testCreateLocationNodeAssignmentCreation
@@ 995-1035 (lines=41) @@
992
    /**
993
     * @depends testCreateLocationNodeAssignmentCreation
994
     */
995
    public function testConvertNodeAssignmentsParentInvisible()
996
    {
997
        $this->insertDatabaseFixture(__DIR__ . '/_fixtures/full_example_tree.php');
998
999
        $handler = $this->getLocationGateway();
1000
        $handler->createNodeAssignment(
1001
            new CreateStruct(
1002
                array(
1003
                    'contentId' => 68,
1004
                    'contentVersion' => 1,
1005
                    'mainLocationId' => true,
1006
                    'priority' => 101,
1007
                    'remoteId' => 'some_id',
1008
                    'sortField' => 1,
1009
                    'sortOrder' => 1,
1010
                    'hidden' => false,
1011
                    // Note: not stored in node assignment, will be calculated from parent
1012
                    // visibility upon Location creation from node assignment
1013
                    'invisible' => false,
1014
                )
1015
            ),
1016
            '225',
1017
            DoctrineDatabase::NODE_ASSIGNMENT_OP_CODE_CREATE
1018
        );
1019
1020
        $handler->createLocationsFromNodeAssignments(68, 1);
1021
1022
        $query = $this->handler->createSelectQuery();
1023
        $this->assertQueryResult(
1024
            array(array(0, 1)),
1025
            $query
1026
                ->select('is_hidden, is_invisible')
1027
                ->from('ezcontentobject_tree')
1028
                ->where(
1029
                    $query->expr->lAnd(
1030
                        $query->expr->eq('contentobject_id', 68),
1031
                        $query->expr->eq('parent_node_id', 225)
1032
                    )
1033
                )
1034
        );
1035
    }
1036
1037
    /**
1038
     * @depends testCreateLocationNodeAssignmentCreation