Code Duplication    Length = 27-31 lines in 3 locations

tests/BaseDatabase.php 3 locations

@@ 139-169 (lines=31) @@
136
     * @throws \ByJG\DbMigration\Exception\DatabaseDoesNotRegistered
137
     * @throws \ByJG\Serializer\Exception\InvalidArgumentException
138
     */
139
    protected function assertVersion0()
140
    {
141
        $version = $this->migrate->getDbDriver()->getScalar('select version from '. $this->migrationTable);
142
        $this->assertEquals(0, $version);
143
        $status = $this->migrate->getDbDriver()->getScalar('select status from '. $this->migrationTable);
144
        $this->assertEquals(Migration::VERSION_STATUS_COMPLETE, $status);
145
146
        $iterator = $this->migrate->getDbDriver()->getIterator('select * from users');
147
148
        $this->assertTrue($iterator->hasNext());
149
        $row = $iterator->moveNext();
150
        $this->assertEquals(
151
            $this->getExpectedUsersVersion0()[0],
152
            $row->toArray()
153
        );
154
155
        $this->assertTrue($iterator->hasNext());
156
        $row = $iterator->moveNext();
157
        $this->assertEquals(
158
            $this->getExpectedUsersVersion0()[1],
159
            $row->toArray()
160
        );
161
162
        $this->assertFalse($iterator->hasNext());
163
164
        try {
165
            $this->migrate->getDbDriver()->getIterator('select * from roles');
166
        } catch (PDOException $ex) {
167
            $this->assertTrue(true);
168
        }
169
    }
170
171
    /**
172
     * @throws \ByJG\DbMigration\Exception\DatabaseDoesNotRegistered
@@ 175-205 (lines=31) @@
172
     * @throws \ByJG\DbMigration\Exception\DatabaseDoesNotRegistered
173
     * @throws \ByJG\Serializer\Exception\InvalidArgumentException
174
     */
175
    protected function assertVersion1()
176
    {
177
        $version = $this->migrate->getDbDriver()->getScalar('select version from '. $this->migrationTable);
178
        $this->assertEquals(1, $version);
179
        $status = $this->migrate->getDbDriver()->getScalar('select status from '. $this->migrationTable);
180
        $this->assertEquals(Migration::VERSION_STATUS_COMPLETE, $status);
181
182
        $iterator = $this->migrate->getDbDriver()->getIterator('select * from users');
183
184
        $this->assertTrue($iterator->hasNext());
185
        $row = $iterator->moveNext();
186
        $this->assertEquals(
187
            $this->getExpectedUsersVersion1()[0],
188
            $row->toArray()
189
        );
190
191
        $this->assertTrue($iterator->hasNext());
192
        $row = $iterator->moveNext();
193
        $this->assertEquals(
194
            $this->getExpectedUsersVersion1()[1],
195
            $row->toArray()
196
        );
197
198
        $this->assertFalse($iterator->hasNext());
199
200
        try {
201
            $this->migrate->getDbDriver()->getIterator('select * from roles');
202
        } catch (PDOException $ex) {
203
            $this->assertTrue(true);
204
        }
205
    }
206
207
    /**
208
     * @throws \ByJG\DbMigration\Exception\DatabaseDoesNotRegistered
@@ 211-237 (lines=27) @@
208
     * @throws \ByJG\DbMigration\Exception\DatabaseDoesNotRegistered
209
     * @throws \ByJG\Serializer\Exception\InvalidArgumentException
210
     */
211
    protected function assertVersion2()
212
    {
213
        $version = $this->migrate->getDbDriver()->getScalar('select version from '. $this->migrationTable);
214
        $this->assertEquals(2, $version);
215
        $status = $this->migrate->getDbDriver()->getScalar('select status from '. $this->migrationTable);
216
        $this->assertEquals(Migration::VERSION_STATUS_COMPLETE, $status);
217
218
        $iterator = $this->migrate->getDbDriver()->getIterator('select * from users');
219
220
        $this->assertTrue($iterator->hasNext());
221
        $row = $iterator->moveNext();
222
        $this->assertEquals(
223
            $this->getExpectedUsersVersion1()[0],
224
            $row->toArray()
225
        );
226
227
        $this->assertTrue($iterator->hasNext());
228
        $row = $iterator->moveNext();
229
        $this->assertEquals(
230
            $this->getExpectedUsersVersion1()[1],
231
            $row->toArray()
232
        );
233
234
        $this->assertFalse($iterator->hasNext());
235
236
        $this->migrate->getDbDriver()->getIterator('select * from roles');
237
    }
238
239
    /**
240
     * @throws \ByJG\DbMigration\Exception\DatabaseDoesNotRegistered