Code Duplication    Length = 34-37 lines in 3 locations

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

@@ 647-681 (lines=35) @@
644
     * @depends testCreateLocation
645
     * @dataProvider getNodeAssignmentValues
646
     */
647
    public function testCreateLocationNodeAssignmentCreation($field, $value)
648
    {
649
        $this->insertDatabaseFixture(__DIR__ . '/_fixtures/full_example_tree.php');
650
        $handler = $this->getLocationGateway();
651
        $handler->createNodeAssignment(
652
            new CreateStruct(
653
                array(
654
                    'contentId' => 68,
655
                    'contentVersion' => 1,
656
                    'mainLocationId' => 1,
657
                    'priority' => 1,
658
                    'remoteId' => 'some_id',
659
                    'sortField' => 2,
660
                    'sortOrder' => 0,
661
                    'hidden' => 1,
662
                )
663
            ),
664
            '77',
665
            DoctrineDatabase::NODE_ASSIGNMENT_OP_CODE_CREATE
666
        );
667
668
        $query = $this->handler->createSelectQuery();
669
        $this->assertQueryResult(
670
            array(array($value)),
671
            $query
672
                ->select($field)
673
                ->from('eznode_assignment')
674
                ->where(
675
                    $query->expr->lAnd(
676
                        $query->expr->eq('contentobject_id', 68),
677
                        $query->expr->eq('parent_node', 77)
678
                    )
679
                )
680
        );
681
    }
682
683
    /**
684
     * @depends testCreateLocation
@@ 686-719 (lines=34) @@
683
    /**
684
     * @depends testCreateLocation
685
     */
686
    public function testCreateLocationNodeAssignmentCreationMainLocation()
687
    {
688
        $this->insertDatabaseFixture(__DIR__ . '/_fixtures/full_example_tree.php');
689
        $handler = $this->getLocationGateway();
690
        $handler->createNodeAssignment(
691
            new CreateStruct(
692
                array(
693
                    'contentId' => 68,
694
                    'contentVersion' => 1,
695
                    'mainLocationId' => true,
696
                    'priority' => 1,
697
                    'remoteId' => 'some_id',
698
                    'sortField' => 1,
699
                    'sortOrder' => 1,
700
                )
701
            ),
702
            '77',
703
            DoctrineDatabase::NODE_ASSIGNMENT_OP_CODE_CREATE
704
        );
705
706
        $query = $this->handler->createSelectQuery();
707
        $this->assertQueryResult(
708
            array(array(1)),
709
            $query
710
                ->select('is_main')
711
                ->from('eznode_assignment')
712
                ->where(
713
                    $query->expr->lAnd(
714
                        $query->expr->eq('contentobject_id', 68),
715
                        $query->expr->eq('parent_node', 77)
716
                    )
717
                )
718
        );
719
    }
720
721
    /**
722
     * @covers eZ\Publish\Core\Persistence\Legacy\Content\Location\Gateway\DoctrineDatabase::updateLocationsContentVersionNo
@@ 1040-1076 (lines=37) @@
1037
    /**
1038
     * @depends testCreateLocationNodeAssignmentCreation
1039
     */
1040
    public function testConvertNodeAssignmentsUpdateAssignment()
1041
    {
1042
        $this->insertDatabaseFixture(__DIR__ . '/_fixtures/full_example_tree.php');
1043
1044
        $handler = $this->getLocationGateway();
1045
        $handler->createNodeAssignment(
1046
            new CreateStruct(
1047
                array(
1048
                    'contentId' => 68,
1049
                    'contentVersion' => 1,
1050
                    'mainLocationId' => 1,
1051
                    'priority' => 1,
1052
                    'remoteId' => 'some_id',
1053
                    'sortField' => 1,
1054
                    'sortOrder' => 1,
1055
                )
1056
            ),
1057
            '77',
1058
            DoctrineDatabase::NODE_ASSIGNMENT_OP_CODE_CREATE
1059
        );
1060
1061
        $handler->createLocationsFromNodeAssignments(68, 1);
1062
1063
        $query = $this->handler->createSelectQuery();
1064
        $this->assertQueryResult(
1065
            array(array(DoctrineDatabase::NODE_ASSIGNMENT_OP_CODE_CREATE_NOP)),
1066
            $query
1067
                ->select('op_code')
1068
                ->from('eznode_assignment')
1069
                ->where(
1070
                    $query->expr->lAnd(
1071
                        $query->expr->eq('contentobject_id', 68),
1072
                        $query->expr->eq('parent_node', 77)
1073
                    )
1074
                )
1075
        );
1076
    }
1077
1078
    /**
1079
     * Test for the setSectionForSubtree() method.