Code Duplication    Length = 34-37 lines in 3 locations

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

@@ 719-753 (lines=35) @@
716
     * @depends testCreateLocation
717
     * @dataProvider getNodeAssignmentValues
718
     */
719
    public function testCreateLocationNodeAssignmentCreation($field, $value)
720
    {
721
        $this->insertDatabaseFixture(__DIR__ . '/_fixtures/full_example_tree.php');
722
        $handler = $this->getLocationGateway();
723
        $handler->createNodeAssignment(
724
            new CreateStruct(
725
                array(
726
                    'contentId' => 68,
727
                    'contentVersion' => 1,
728
                    'mainLocationId' => 1,
729
                    'priority' => 1,
730
                    'remoteId' => 'some_id',
731
                    'sortField' => 2,
732
                    'sortOrder' => 0,
733
                    'hidden' => 1,
734
                )
735
            ),
736
            '77',
737
            DoctrineDatabase::NODE_ASSIGNMENT_OP_CODE_CREATE
738
        );
739
740
        $query = $this->handler->createSelectQuery();
741
        $this->assertQueryResult(
742
            array(array($value)),
743
            $query
744
                ->select($field)
745
                ->from('eznode_assignment')
746
                ->where(
747
                    $query->expr->lAnd(
748
                        $query->expr->eq('contentobject_id', 68),
749
                        $query->expr->eq('parent_node', 77)
750
                    )
751
                )
752
        );
753
    }
754
755
    /**
756
     * @depends testCreateLocation
@@ 758-791 (lines=34) @@
755
    /**
756
     * @depends testCreateLocation
757
     */
758
    public function testCreateLocationNodeAssignmentCreationMainLocation()
759
    {
760
        $this->insertDatabaseFixture(__DIR__ . '/_fixtures/full_example_tree.php');
761
        $handler = $this->getLocationGateway();
762
        $handler->createNodeAssignment(
763
            new CreateStruct(
764
                array(
765
                    'contentId' => 68,
766
                    'contentVersion' => 1,
767
                    'mainLocationId' => true,
768
                    'priority' => 1,
769
                    'remoteId' => 'some_id',
770
                    'sortField' => 1,
771
                    'sortOrder' => 1,
772
                )
773
            ),
774
            '77',
775
            DoctrineDatabase::NODE_ASSIGNMENT_OP_CODE_CREATE
776
        );
777
778
        $query = $this->handler->createSelectQuery();
779
        $this->assertQueryResult(
780
            array(array(1)),
781
            $query
782
                ->select('is_main')
783
                ->from('eznode_assignment')
784
                ->where(
785
                    $query->expr->lAnd(
786
                        $query->expr->eq('contentobject_id', 68),
787
                        $query->expr->eq('parent_node', 77)
788
                    )
789
                )
790
        );
791
    }
792
793
    /**
794
     * @covers \eZ\Publish\Core\Persistence\Legacy\Content\Location\Gateway\DoctrineDatabase::updateLocationsContentVersionNo
@@ 1112-1148 (lines=37) @@
1109
    /**
1110
     * @depends testCreateLocationNodeAssignmentCreation
1111
     */
1112
    public function testConvertNodeAssignmentsUpdateAssignment()
1113
    {
1114
        $this->insertDatabaseFixture(__DIR__ . '/_fixtures/full_example_tree.php');
1115
1116
        $handler = $this->getLocationGateway();
1117
        $handler->createNodeAssignment(
1118
            new CreateStruct(
1119
                array(
1120
                    'contentId' => 68,
1121
                    'contentVersion' => 1,
1122
                    'mainLocationId' => 1,
1123
                    'priority' => 1,
1124
                    'remoteId' => 'some_id',
1125
                    'sortField' => 1,
1126
                    'sortOrder' => 1,
1127
                )
1128
            ),
1129
            '77',
1130
            DoctrineDatabase::NODE_ASSIGNMENT_OP_CODE_CREATE
1131
        );
1132
1133
        $handler->createLocationsFromNodeAssignments(68, 1);
1134
1135
        $query = $this->handler->createSelectQuery();
1136
        $this->assertQueryResult(
1137
            array(array(DoctrineDatabase::NODE_ASSIGNMENT_OP_CODE_CREATE_NOP)),
1138
            $query
1139
                ->select('op_code')
1140
                ->from('eznode_assignment')
1141
                ->where(
1142
                    $query->expr->lAnd(
1143
                        $query->expr->eq('contentobject_id', 68),
1144
                        $query->expr->eq('parent_node', 77)
1145
                    )
1146
                )
1147
        );
1148
    }
1149
1150
    /**
1151
     * Test for the setSectionForSubtree() method.