Code Duplication    Length = 28-29 lines in 3 locations

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

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