Code Duplication    Length = 33-33 lines in 3 locations

tests/Doctrine/Tests/DBAL/Functional/ExceptionTest.php 3 locations

@@ 53-85 (lines=33) @@
50
        $schemaManager->createTable($table);
51
    }
52
53
    public function testForeignKeyConstraintViolationExceptionOnInsert()
54
    {
55
        if ( ! $this->_conn->getDatabasePlatform()->supportsForeignKeyConstraints()) {
56
            $this->markTestSkipped("Only fails on platforms with foreign key constraints.");
57
        }
58
59
        $this->setUpForeignKeyConstraintViolationExceptionTest();
60
61
        try {
62
            $this->_conn->insert("constraint_error_table", array('id' => 1));
63
            $this->_conn->insert("owning_table", array('id' => 1, 'constraint_id' => 1));
64
        } catch (\Exception $exception) {
65
            $this->tearDownForeignKeyConstraintViolationExceptionTest();
66
67
            throw $exception;
68
        }
69
70
        $this->expectException(Exception\ForeignKeyConstraintViolationException::class);
71
72
        try {
73
            $this->_conn->insert('owning_table', array('id' => 2, 'constraint_id' => 2));
74
        } catch (Exception\ForeignKeyConstraintViolationException $exception) {
75
            $this->tearDownForeignKeyConstraintViolationExceptionTest();
76
77
            throw $exception;
78
        } catch (\Exception $exception) {
79
            $this->tearDownForeignKeyConstraintViolationExceptionTest();
80
81
            throw $exception;
82
        }
83
84
        $this->tearDownForeignKeyConstraintViolationExceptionTest();
85
    }
86
87
    public function testForeignKeyConstraintViolationExceptionOnUpdate()
88
    {
@@ 87-119 (lines=33) @@
84
        $this->tearDownForeignKeyConstraintViolationExceptionTest();
85
    }
86
87
    public function testForeignKeyConstraintViolationExceptionOnUpdate()
88
    {
89
        if ( ! $this->_conn->getDatabasePlatform()->supportsForeignKeyConstraints()) {
90
            $this->markTestSkipped("Only fails on platforms with foreign key constraints.");
91
        }
92
93
        $this->setUpForeignKeyConstraintViolationExceptionTest();
94
95
        try {
96
            $this->_conn->insert("constraint_error_table", array('id' => 1));
97
            $this->_conn->insert("owning_table", array('id' => 1, 'constraint_id' => 1));
98
        } catch (\Exception $exception) {
99
            $this->tearDownForeignKeyConstraintViolationExceptionTest();
100
101
            throw $exception;
102
        }
103
104
        $this->expectException(Exception\ForeignKeyConstraintViolationException::class);
105
106
        try {
107
            $this->_conn->update('constraint_error_table', array('id' => 2), array('id' => 1));
108
        } catch (Exception\ForeignKeyConstraintViolationException $exception) {
109
            $this->tearDownForeignKeyConstraintViolationExceptionTest();
110
111
            throw $exception;
112
        } catch (\Exception $exception) {
113
            $this->tearDownForeignKeyConstraintViolationExceptionTest();
114
115
            throw $exception;
116
        }
117
118
        $this->tearDownForeignKeyConstraintViolationExceptionTest();
119
    }
120
121
    public function testForeignKeyConstraintViolationExceptionOnDelete()
122
    {
@@ 121-153 (lines=33) @@
118
        $this->tearDownForeignKeyConstraintViolationExceptionTest();
119
    }
120
121
    public function testForeignKeyConstraintViolationExceptionOnDelete()
122
    {
123
        if ( ! $this->_conn->getDatabasePlatform()->supportsForeignKeyConstraints()) {
124
            $this->markTestSkipped("Only fails on platforms with foreign key constraints.");
125
        }
126
127
        $this->setUpForeignKeyConstraintViolationExceptionTest();
128
129
        try {
130
            $this->_conn->insert("constraint_error_table", array('id' => 1));
131
            $this->_conn->insert("owning_table", array('id' => 1, 'constraint_id' => 1));
132
        } catch (\Exception $exception) {
133
            $this->tearDownForeignKeyConstraintViolationExceptionTest();
134
135
            throw $exception;
136
        }
137
138
        $this->expectException(Exception\ForeignKeyConstraintViolationException::class);
139
140
        try {
141
            $this->_conn->delete('constraint_error_table', array('id' => 1));
142
        } catch (Exception\ForeignKeyConstraintViolationException $exception) {
143
            $this->tearDownForeignKeyConstraintViolationExceptionTest();
144
145
            throw $exception;
146
        } catch (\Exception $exception) {
147
            $this->tearDownForeignKeyConstraintViolationExceptionTest();
148
149
            throw $exception;
150
        }
151
152
        $this->tearDownForeignKeyConstraintViolationExceptionTest();
153
    }
154
155
    public function testForeignKeyConstraintViolationExceptionOnTruncate()
156
    {