Code Duplication    Length = 28-29 lines in 3 locations

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

@@ 963-991 (lines=29) @@
960
    /**
961
     * @covers eZ\Publish\Core\Persistence\Legacy\Content\Gateway\DoctrineDatabase::deleteRelations
962
     */
963
    public function testDeleteRelationsTo()
964
    {
965
        $this->insertDatabaseFixture(
966
            __DIR__ . '/../_fixtures/contentobjects.php'
967
        );
968
969
        $beforeCount = array(
970
            'all' => $this->countContentRelations(),
971
            'from' => $this->countContentRelations(149),
972
            'to' => $this->countContentRelations(null, 149),
973
        );
974
975
        $gateway = $this->getDatabaseGateway();
976
        $gateway->deleteRelations(149);
977
978
        $this->assertEquals(
979
            // yes, relates to itself!
980
            array(
981
                'all' => $beforeCount['all'] - 2,
982
                'from' => $beforeCount['from'] - 1,
983
                'to' => $beforeCount['to'] - 2,
984
            ),
985
            array(
986
                'all' => $this->countContentRelations(),
987
                'from' => $this->countContentRelations(149),
988
                'to' => $this->countContentRelations(null, 149),
989
            )
990
        );
991
    }
992
993
    /**
994
     * @covers eZ\Publish\Core\Persistence\Legacy\Content\Gateway\DoctrineDatabase::deleteRelations
@@ 996-1023 (lines=28) @@
993
    /**
994
     * @covers eZ\Publish\Core\Persistence\Legacy\Content\Gateway\DoctrineDatabase::deleteRelations
995
     */
996
    public function testDeleteRelationsFrom()
997
    {
998
        $this->insertDatabaseFixture(
999
            __DIR__ . '/../_fixtures/contentobjects.php'
1000
        );
1001
1002
        $beforeCount = array(
1003
            'all' => $this->countContentRelations(),
1004
            'from' => $this->countContentRelations(75),
1005
            'to' => $this->countContentRelations(null, 75),
1006
        );
1007
1008
        $gateway = $this->getDatabaseGateway();
1009
        $gateway->deleteRelations(75);
1010
1011
        $this->assertEquals(
1012
            array(
1013
                'all' => $beforeCount['all'] - 6,
1014
                'from' => $beforeCount['from'] - 6,
1015
                'to' => $beforeCount['to'],
1016
            ),
1017
            array(
1018
                'all' => $this->countContentRelations(),
1019
                'from' => $this->countContentRelations(75),
1020
                'to' => $this->countContentRelations(null, 75),
1021
            )
1022
        );
1023
    }
1024
1025
    /**
1026
     * @covers \eZ\Publish\Core\Persistence\Legacy\Content\Gateway\DoctrineDatabase::deleteRelations
@@ 1028-1055 (lines=28) @@
1025
    /**
1026
     * @covers \eZ\Publish\Core\Persistence\Legacy\Content\Gateway\DoctrineDatabase::deleteRelations
1027
     */
1028
    public function testDeleteRelationsWithSecondArgument()
1029
    {
1030
        $this->insertDatabaseFixture(
1031
            __DIR__ . '/../_fixtures/contentobjects.php'
1032
        );
1033
1034
        $beforeCount = array(
1035
            'all' => $this->countContentRelations(),
1036
            'from' => $this->countContentRelations(225),
1037
            'to' => $this->countContentRelations(null, 225),
1038
        );
1039
1040
        $gateway = $this->getDatabaseGateway();
1041
        $gateway->deleteRelations(225, 2);
1042
1043
        $this->assertEquals(
1044
            array(
1045
                'all' => $beforeCount['all'] - 1,
1046
                'from' => $beforeCount['from'] - 1,
1047
                'to' => $beforeCount['to'],
1048
            ),
1049
            array(
1050
                'all' => $this->countContentRelations(),
1051
                'from' => $this->countContentRelations(225),
1052
                'to' => $this->countContentRelations(null, 225),
1053
            )
1054
        );
1055
    }
1056
1057
    /**
1058
     * @covers eZ\Publish\Core\Persistence\Legacy\Content\Gateway\DoctrineDatabase::deleteField