Code Duplication    Length = 34-37 lines in 3 locations

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

@@ 733-767 (lines=35) @@
730
     * @depends testCreateLocation
731
     * @dataProvider getNodeAssignmentValues
732
     */
733
    public function testCreateLocationNodeAssignmentCreation($field, $value)
734
    {
735
        $this->insertDatabaseFixture(__DIR__ . '/_fixtures/full_example_tree.php');
736
        $handler = $this->getLocationGateway();
737
        $handler->createNodeAssignment(
738
            new CreateStruct(
739
                [
740
                    'contentId' => 68,
741
                    'contentVersion' => 1,
742
                    'mainLocationId' => 1,
743
                    'priority' => 1,
744
                    'remoteId' => 'some_id',
745
                    'sortField' => 2,
746
                    'sortOrder' => 0,
747
                    'hidden' => 1,
748
                ]
749
            ),
750
            '77',
751
            DoctrineDatabase::NODE_ASSIGNMENT_OP_CODE_CREATE
752
        );
753
754
        $query = $this->handler->createSelectQuery();
755
        $this->assertQueryResult(
756
            [[$value]],
757
            $query
758
                ->select($field)
759
                ->from('eznode_assignment')
760
                ->where(
761
                    $query->expr->lAnd(
762
                        $query->expr->eq('contentobject_id', 68),
763
                        $query->expr->eq('parent_node', 77)
764
                    )
765
                )
766
        );
767
    }
768
769
    /**
770
     * @depends testCreateLocation
@@ 772-805 (lines=34) @@
769
    /**
770
     * @depends testCreateLocation
771
     */
772
    public function testCreateLocationNodeAssignmentCreationMainLocation()
773
    {
774
        $this->insertDatabaseFixture(__DIR__ . '/_fixtures/full_example_tree.php');
775
        $handler = $this->getLocationGateway();
776
        $handler->createNodeAssignment(
777
            new CreateStruct(
778
                [
779
                    'contentId' => 68,
780
                    'contentVersion' => 1,
781
                    'mainLocationId' => true,
782
                    'priority' => 1,
783
                    'remoteId' => 'some_id',
784
                    'sortField' => 1,
785
                    'sortOrder' => 1,
786
                ]
787
            ),
788
            '77',
789
            DoctrineDatabase::NODE_ASSIGNMENT_OP_CODE_CREATE
790
        );
791
792
        $query = $this->handler->createSelectQuery();
793
        $this->assertQueryResult(
794
            [[1]],
795
            $query
796
                ->select('is_main')
797
                ->from('eznode_assignment')
798
                ->where(
799
                    $query->expr->lAnd(
800
                        $query->expr->eq('contentobject_id', 68),
801
                        $query->expr->eq('parent_node', 77)
802
                    )
803
                )
804
        );
805
    }
806
807
    /**
808
     * @covers \eZ\Publish\Core\Persistence\Legacy\Content\Location\Gateway\DoctrineDatabase::updateLocationsContentVersionNo
@@ 1126-1162 (lines=37) @@
1123
    /**
1124
     * @depends testCreateLocationNodeAssignmentCreation
1125
     */
1126
    public function testConvertNodeAssignmentsUpdateAssignment()
1127
    {
1128
        $this->insertDatabaseFixture(__DIR__ . '/_fixtures/full_example_tree.php');
1129
1130
        $handler = $this->getLocationGateway();
1131
        $handler->createNodeAssignment(
1132
            new CreateStruct(
1133
                [
1134
                    'contentId' => 68,
1135
                    'contentVersion' => 1,
1136
                    'mainLocationId' => 1,
1137
                    'priority' => 1,
1138
                    'remoteId' => 'some_id',
1139
                    'sortField' => 1,
1140
                    'sortOrder' => 1,
1141
                ]
1142
            ),
1143
            '77',
1144
            DoctrineDatabase::NODE_ASSIGNMENT_OP_CODE_CREATE
1145
        );
1146
1147
        $handler->createLocationsFromNodeAssignments(68, 1);
1148
1149
        $query = $this->handler->createSelectQuery();
1150
        $this->assertQueryResult(
1151
            [[DoctrineDatabase::NODE_ASSIGNMENT_OP_CODE_CREATE_NOP]],
1152
            $query
1153
                ->select('op_code')
1154
                ->from('eznode_assignment')
1155
                ->where(
1156
                    $query->expr->lAnd(
1157
                        $query->expr->eq('contentobject_id', 68),
1158
                        $query->expr->eq('parent_node', 77)
1159
                    )
1160
                )
1161
        );
1162
    }
1163
1164
    /**
1165
     * Test for the setSectionForSubtree() method.