Completed
Push — master ( f92391...2b16eb )
by Jacob
03:12
created

MysqlPostRepositoryTest::tearDownAfterClass()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 5
Code Lines 3

Duplication

Lines 0
Ratio 0 %

Importance

Changes 2
Bugs 0 Features 1
Metric Value
c 2
b 0
f 1
dl 0
loc 5
rs 9.4285
cc 1
eloc 3
nc 1
nop 0
1
<?php
2
3
namespace Jacobemerick\Web\Domain\Blog\Post;
4
5
use Aura\Sql\ConnectionLocator;
6
use Aura\Sql\ExtendedPdo;
7
use DateTime;
8
use PHPUnit_Framework_TestCase;
9
10
class MysqlPostRepositoryTest extends PHPUnit_Framework_TestCase
11
{
12
13
    protected static $connection;
14
15 View Code Duplication
    public static function setUpBeforeClass()
0 ignored issues
show
Duplication introduced by
This method seems to be duplicated in your project.

Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.

You can also find more detailed suggestions in the “Code” section of your repository.

Loading history...
16
    {
17
        $extendedPdo = new ExtendedPdo('sqlite::memory:');
18
        $extendedPdo->exec('ATTACH DATABASE `jpemeric_blog.db` AS `jpemeric_blog`');
19
20
        $extendedPdo->exec("
21
            CREATE TABLE IF NOT EXISTS `jpemeric_blog`.`post` (
22
                `id` integer PRIMARY KEY AUTOINCREMENT,
23
                `title` varchar(60) NOT NULL,
24
                `path` varchar(60) NOT NULL,
25
                `category` varchar(15) NOT NULL,
26
                `date` datetime,
27
                `body` text,
28
                `display` integer(1) NOT NULL
29
            )"
30
        );
31
        $extendedPdo->exec("
32
            CREATE TABLE IF NOT EXISTS `jpemeric_blog`.`ptlink` (
33
                `post_id` integer NOT NULL,
34
                `tag_id` integer NOT NULL
35
            )"
36
        );
37
        $extendedPdo->exec("
38
            CREATE TABLE IF NOT EXISTS `jpemeric_blog`.`series_post` (
39
                `series` integer NOT NULL,
40
                `post` integer NOT NULL,
41
                `order` integer(1) NOT NULL
42
            )"
43
        );
44
        $extendedPdo->exec("
45
            CREATE TABLE IF NOT EXISTS `jpemeric_blog`.`tag` (
46
                `id` integer PRIMARY KEY AUTOINCREMENT,
47
                `tag` varchar(25) NOT NULL
48
            )"
49
        );
50
51
        self::$connection = new ConnectionLocator(function () use ($extendedPdo) {
52
            return $extendedPdo;
53
        });
54
    }
55
56
    public function testIsInstanceOfPostRepository()
57
    {
58
        $repository = new MysqlPostRepository(self::$connection);
59
60
        $this->assertInstanceOf(
61
            'Jacobemerick\Web\Domain\Blog\Post\MysqlPostRepository',
62
            $repository
63
        );
64
    }
65
66
    public function testImplementsPostInterface()
67
    {
68
        $repository = new MysqlPostRepository(self::$connection);
69
70
        $this->assertInstanceOf(
71
            'Jacobemerick\Web\Domain\Blog\Post\PostRepositoryInterface',
72
            $repository
73
        );
74
    }
75
76
    public function testConstructSetsConnections()
77
    {
78
        $respository = new MysqlPostRepository(self::$connection);
79
80
        $this->assertAttributeSame(
81
            self::$connection,
82
            'connections',
83
            $respository
84
        );
85
    }
86
87
    public function testFindPostByPath()
88
    {
89
        $testData = [
90
            'id'       => rand(1, 100),
91
            'title'    => 'test title',
92
            'path'     => 'test-path',
93
            'category' => 'test category',
94
            'date'     => (new DateTime())->format('Y-m-d H:i:s'),
95
            'body'     => 'test body',
96
            'display'  => 1
97
        ];
98
99
        $this->insertPostData($testData);
100
101
        $repository = new MysqlPostRepository(self::$connection);
102
        $data = $repository->findPostByPath($testData['category'], $testData['path']);
103
104
        $this->assertNotFalse($data);
105
        $this->assertInternalType('array', $data);
106
        $this->assertArrayHasKey('id', $data);
107
        $this->assertEquals($testData['id'], $data['id']);
108
        $this->assertArrayHasKey('title', $data);
109
        $this->assertEquals($testData['title'], $data['title']);
110
        $this->assertArrayHasKey('path', $data);
111
        $this->assertEquals($testData['path'], $data['path']);
112
        $this->assertArrayHasKey('date', $data);
113
        $this->assertEquals($testData['date'], $data['date']);
114
        $this->assertArrayHasKey('body', $data);
115
        $this->assertEquals($testData['body'], $data['body']);
116
        $this->assertArrayHasKey('category', $data);
117
        $this->assertEquals($testData['category'], $data['category']);
118
    }
119
120
    public function testFindPostByPathInactive()
121
    {
122
        $testData = [
123
            'id'       => rand(1, 100),
124
            'path'     => 'test-path',
125
            'category' => 'test category',
126
            'display'  => 0
127
        ];
128
129
        $this->insertPostData($testData);
130
131
        $repository = new MysqlPostRepository(self::$connection);
132
        $data = $repository->findPostByPath($testData['category'], $testData['path']);
133
134
        $this->assertFalse($data);
135
    }
136
137
    public function testFindPostByPathFailure()
138
    {
139
        $repository = new MysqlPostRepository(self::$connection);
140
        $data = $repository->findPostByPath('', '');
141
142
        $this->assertFalse($data);
143
    }
144
145
    public function testGetActivePosts()
146
    {
147
        $testData = [
148
            [
149
                'id'       => rand(1, 100),
150
                'title'    => 'title one',
151
                'path'     => 'path-one',
152
                'category' => 'test category',
153
                'date'     => (new DateTime('-1 day'))->format('Y-m-d H:i:s'),
154
                'body'     => 'body one',
155
                'display'  => 1,
156
            ],
157
            [
158
                'id'       => rand(101, 200),
159
                'title'    => 'title two',
160
                'path'     => 'path-two',
161
                'category' => 'test category',
162
                'date'     => (new DateTime())->format('Y-m-d H:i:s'),
163
                'body'     => 'body one',
164
                'display'  => 1,
165
            ],
166
        ];
167
168
        array_walk($testData, [$this, 'insertPostData']);
169
170
        $repository = new MysqlPostRepository(self::$connection);
171
        $data = $repository->getActivePosts();
172
173
        $this->assertNotFalse($data);
174
        $this->assertInternalType('array', $data);
175
        $this->assertCount(count($testData), $data);
176
177
        usort($testData, function ($rowA, $rowB) {
178
            return ((new DateTime($rowA['date'])) < (new DateTime($rowB['date'])));
179
        });
180
181 View Code Duplication
        foreach ($testData as $key => $testRow) {
0 ignored issues
show
Duplication introduced by
This code seems to be duplicated across your project.

Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.

You can also find more detailed suggestions in the “Code” section of your repository.

Loading history...
182
            $this->assertArrayHasKey('id', $data[$key]);
183
            $this->assertEquals($testRow['id'], $data[$key]['id']);
184
            $this->assertArrayHasKey('title', $data[$key]);
185
            $this->assertEquals($testRow['title'], $data[$key]['title']);
186
            $this->assertArrayHasKey('path', $data[$key]);
187
            $this->assertEquals($testRow['path'], $data[$key]['path']);
188
            $this->assertArrayHasKey('date', $data[$key]);
189
            $this->assertEquals($testRow['date'], $data[$key]['date']);
190
            $this->assertArrayHasKey('body', $data[$key]);
191
            $this->assertEquals($testRow['body'], $data[$key]['body']);
192
            $this->assertArrayHasKey('category', $data[$key]);
193
            $this->assertEquals($testRow['category'], $data[$key]['category']);
194
        }
195
    }
196
 
197
    public function testGetActivePostsInactive()
198
    {
199
        $testData = [
200
            [
201
                'id'      => rand(1, 100),
202
                'display' => 1,
203
            ],
204
            [
205
                'id'      => rand(101, 200),
206
                'display' => 0,
207
            ],
208
            [
209
                'id'      => rand(201, 300),
210
                'display' => 1,
211
            ],
212
        ];
213
214
        array_walk($testData, [$this, 'insertPostData']);
215
216
        $repository = new MysqlPostRepository(self::$connection);
217
        $data = $repository->getActivePosts();
218
219
        $this->assertNotFalse($data);
220
        $this->assertInternalType('array', $data);
221
222
        $testData = array_filter($testData, function ($row) {
223
            return ($row['display'] == 1);
224
        });
225
226
        $this->assertCount(count($testData), $data);
227
228
        $testIds = array_column($testData, 'ids');
229
        $dataIds = array_column($data, 'ids');
230
231
        $this->assertEmpty(array_merge(
232
            array_diff($testIds, $dataIds),
233
            array_diff($dataIds, $testIds)
234
        ));
235
    }
236
 
237 View Code Duplication
    public function testGetActivePostsFailure()
0 ignored issues
show
Duplication introduced by
This method seems to be duplicated in your project.

Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.

You can also find more detailed suggestions in the “Code” section of your repository.

Loading history...
238
    {
239
        $repository = new MysqlPostRepository(self::$connection);
240
        $data = $repository->getActivePosts();
241
242
        $this->assertEmpty($data);
243
        $this->assertInternalType('array', $data);
244
    }
245
246
    public function testGetActivePostsRange()
247
    {
248
        $testData = [
249
            [
250
                'id'      => rand(1, 100),
251
                'display' => 1,
252
            ],
253
            [
254
                'id'      => rand(101, 200),
255
                'display' => 1,
256
            ],
257
            [
258
                'id'      => rand(201, 300),
259
                'display' => 1,
260
            ],
261
        ];
262
263
        array_walk($testData, [$this, 'insertPostData']);
264
265
        $repository = new MysqlPostRepository(self::$connection);
266
        $data = $repository->getActivePosts(2, 1);
267
268
        $this->assertNotFalse($data);
269
        $this->assertInternalType('array', $data);
270
        $this->assertCount(2, $data);
271
272
        $testData = array_slice($testData, 2, 1);
273
274
        $testIds = array_column($testData, 'ids');
275
        $dataIds = array_column($data, 'ids');
276
277
        $this->assertEmpty(array_merge(
278
            array_diff($testIds, $dataIds),
279
            array_diff($dataIds, $testIds)
280
        ));
281
    }
282
283 View Code Duplication
    public function testGetActivePostsRangeFailure()
0 ignored issues
show
Duplication introduced by
This method seems to be duplicated in your project.

Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.

You can also find more detailed suggestions in the “Code” section of your repository.

Loading history...
284
    {
285
        $testData = [
286
            [
287
                'id'      => rand(1, 100),
288
                'display' => 1,
289
            ],
290
            [
291
                'id'      => rand(101, 200),
292
                'display' => 1,
293
            ],
294
            [
295
                'id'      => rand(201, 300),
296
                'display' => 1,
297
            ],
298
        ];
299
300
        array_walk($testData, [$this, 'insertPostData']);
301
302
        $repository = new MysqlPostRepository(self::$connection);
303
        $data = $repository->getActivePosts(1, 3);
304
305
        $this->assertEmpty($data);
306
        $this->assertInternalType('array', $data);
307
    }
308
309 View Code Duplication
    public function testGetActivePostsCount()
0 ignored issues
show
Duplication introduced by
This method seems to be duplicated in your project.

Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.

You can also find more detailed suggestions in the “Code” section of your repository.

Loading history...
310
    {
311
        $testData = [
312
            [
313
                'id'      => rand(1, 100),
314
                'display' => 1,
315
            ],
316
            [
317
                'id'      => rand(101, 200),
318
                'display' => 1,
319
            ],
320
        ];
321
322
        array_walk($testData, [$this, 'insertPostData']);
323
324
        $repository = new MysqlPostRepository(self::$connection);
325
        $data = $repository->getActivePostsCount();
326
327
        $this->assertNotFalse($data);
328
        $this->assertStringMatchesFormat('%d', $data);
329
        $this->assertEquals(count($testData), $data);
330
    }
331
332
    public function testGetActivePostsCountInactive()
333
    {
334
        $testData = [
335
            [
336
                'id'      => rand(1, 100),
337
                'display' => 1,
338
            ],
339
            [
340
                'id'      => rand(101, 200),
341
                'display' => 1,
342
            ],
343
            [
344
                'id'      => rand(201, 300),
345
                'display' => 0,
346
            ],
347
        ];
348
349
        array_walk($testData, [$this, 'insertPostData']);
350
351
        $repository = new MysqlPostRepository(self::$connection);
352
        $data = $repository->getActivePostsCount();
353
354
        $this->assertNotFalse($data);
355
        $this->assertStringMatchesFormat('%d', $data);
356
357
        $testData = array_filter($testData, function ($row) {
358
            return ($row['display'] == 1);
359
        });
360
361
        $this->assertEquals(count($testData), $data);
362
    }
363
364 View Code Duplication
    public function testGetActivePostsCountFailure()
0 ignored issues
show
Duplication introduced by
This method seems to be duplicated in your project.

Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.

You can also find more detailed suggestions in the “Code” section of your repository.

Loading history...
365
    {
366
        $repository = new MysqlPostRepository(self::$connection);
367
        $data = $repository->getActivePostsCount();
368
369
        $this->assertNotFalse($data);
370
        $this->assertStringMatchesFormat('%d', $data);
371
        $this->assertEquals('0', $data);
372
    }
373
374
    public function testGetActivePostsByTag()
375
    {
376
        $testPostData = [
377
            [
378
                'id'       => rand(1, 100),
379
                'title'    => 'title one',
380
                'path'     => 'path-one',
381
                'category' => 'test category',
382
                'date'     => (new DateTime('-1 day'))->format('Y-m-d H:i:s'),
383
                'body'     => 'body one',
384
                'display'  => 1,
385
            ],
386
            [
387
                'id'       => rand(101, 200),
388
                'title'    => 'title two',
389
                'path'     => 'path-two',
390
                'category' => 'test category',
391
                'date'     => (new DateTime())->format('Y-m-d H:i:s'),
392
                'body'     => 'body one',
393
                'display'  => 1,
394
            ],
395
        ];
396
397
        $testTagData = [
398
            'id' => rand(1, 100),
399
        ];
400
401
        $testPTLinkData = [];
402
        foreach ($testPostData as $testPostRow) {
403
            array_push($testPTLinkData, [
404
                'post_id' => $testPostRow['id'],
405
                'tag_id' => $testTagData['id'],
406
            ]);
407
        }
408
409
        array_walk($testPostData, [$this, 'insertPostData']);
410
        array_walk($testPTLinkData, [$this, 'insertPTLinkData']);
411
        $this->insertTagData($testTagData);
412
413
        $repository = new MysqlPostRepository(self::$connection);
414
        $data = $repository->getActivePostsByTag($testTagData['id']);
415
416
        $this->assertNotFalse($data);
417
        $this->assertInternalType('array', $data);
418
        $this->assertCount(count($testPostData), $data);
419 View Code Duplication
        foreach ($testPostData as $key => $testPostRow) {
0 ignored issues
show
Duplication introduced by
This code seems to be duplicated across your project.

Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.

You can also find more detailed suggestions in the “Code” section of your repository.

Loading history...
420
            $this->assertArrayHasKey('id', $data[$key]);
421
            $this->assertEquals($testPostRow['id'], $data[$key]['id']);
422
            $this->assertArrayHasKey('title', $data[$key]);
423
            $this->assertEquals($testPostRow['title'], $data[$key]['title']);
424
            $this->assertArrayHasKey('path', $data[$key]);
425
            $this->assertEquals($testPostRow['path'], $data[$key]['path']);
426
            $this->assertArrayHasKey('date', $data[$key]);
427
            $this->assertEquals($testPostRow['date'], $data[$key]['date']);
428
            $this->assertArrayHasKey('body', $data[$key]);
429
            $this->assertEquals($testPostRow['body'], $data[$key]['body']);
430
            $this->assertArrayHasKey('category', $data[$key]);
431
            $this->assertEquals($testPostRow['category'], $data[$key]['category']);
432
        }
433
    }
434
435 View Code Duplication
    public function testGetActivePostsByTagInactive()
0 ignored issues
show
Duplication introduced by
This method seems to be duplicated in your project.

Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.

You can also find more detailed suggestions in the “Code” section of your repository.

Loading history...
436
    {
437
        $testPostData = [
438
            [
439
                'id'      => rand(1, 100),
440
                'display' => 1,
441
            ],
442
            [
443
                'id'      => rand(101, 200),
444
                'display' => 0,
445
            ],
446
            [
447
                'id'      => rand(201, 300),
448
                'display' => 1,
449
            ],
450
        ];
451
452
        $testTagData = [
453
            'id' => rand(1, 100),
454
        ];
455
456
        $testPTLinkData = [];
457
        foreach ($testPostData as $testPostRow) {
458
            array_push($testPTLinkData, [
459
                'post_id' => $testPostRow['id'],
460
                'tag_id' => $testTagData['id'],
461
            ]);
462
        }
463
464
        array_walk($testPostData, [$this, 'insertPostData']);
465
        array_walk($testPTLinkData, [$this, 'insertPTLinkData']);
466
        $this->insertTagData($testTagData);
467
468
        $repository = new MysqlPostRepository(self::$connection);
469
        $data = $repository->getActivePostsByTag($testTagData['id']);
470
471
        $this->assertNotFalse($data);
472
        $this->assertInternalType('array', $data);
473
474
        $testPostData = array_filter($testPostData, function ($row) {
475
            return ($row['display'] == 1);
476
        });
477
478
        $this->assertCount(count($testPostData), $data);
479
480
        $testIds = array_column($testPostData, 'ids');
481
        $dataIds = array_column($data, 'ids');
482
483
        $this->assertEmpty(array_merge(
484
            array_diff($testIds, $dataIds),
485
            array_diff($dataIds, $testIds)
486
        ));
487
    }
488
 
489
    public function testGetActivePostsByTagFailure()
490
    {
491
        $testTagData = [
492
            'id' => rand(1, 100),
493
        ];
494
495
        $repository = new MysqlPostRepository(self::$connection);
496
        $data = $repository->getActivePostsByTag($testTagData['id']);
497
498
        $this->assertEmpty($data);
499
        $this->assertInternalType('array', $data);
500
    }
501
502 View Code Duplication
    public function testGetActivePostsByTagRange()
0 ignored issues
show
Duplication introduced by
This method seems to be duplicated in your project.

Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.

You can also find more detailed suggestions in the “Code” section of your repository.

Loading history...
503
    {
504
        $testPostData = [
505
            [
506
                'id'      => rand(1, 100),
507
                'display' => 1,
508
            ],
509
            [
510
                'id'      => rand(101, 200),
511
                'display' => 1,
512
            ],
513
            [
514
                'id'      => rand(201, 300),
515
                'display' => 1,
516
            ],
517
        ];
518
519
        $testTagData = [
520
            'id' => rand(1, 100),
521
        ];
522
523
        $testPTLinkData = [];
524
        foreach ($testPostData as $testPostRow) {
525
            array_push($testPTLinkData, [
526
                'post_id' => $testPostRow['id'],
527
                'tag_id' => $testTagData['id'],
528
            ]);
529
        }
530
531
        array_walk($testPostData, [$this, 'insertPostData']);
532
        array_walk($testPTLinkData, [$this, 'insertPTLinkData']);
533
        $this->insertTagData($testTagData);
534
535
        $repository = new MysqlPostRepository(self::$connection);
536
        $data = $repository->getActivePostsByTag($testTagData['id'], 2, 1);
537
538
        $this->assertNotFalse($data);
539
        $this->assertInternalType('array', $data);
540
541
        $testPostData = array_slice($testPostData, 1, 2);
542
543
        $this->assertCount(count($testPostData), $data);
544
545
        $testIds = array_column($testPostData, 'ids');
546
        $dataIds = array_column($data, 'ids');
547
548
        $this->assertEmpty(array_merge(
549
            array_diff($testIds, $dataIds),
550
            array_diff($dataIds, $testIds)
551
        ));
552
    }
553
554
    public function testGetActivePostsByTagRangeFailure()
555
    {
556
        $testPostData = [
557
            [
558
                'id'      => rand(1, 100),
559
                'display' => 1,
560
            ],
561
            [
562
                'id'      => rand(101, 200),
563
                'display' => 1,
564
            ],
565
            [
566
                'id'      => rand(201, 300),
567
                'display' => 1,
568
            ],
569
        ];
570
571
        $testTagData = [
572
            'id' => rand(1, 100),
573
        ];
574
575
        $testPTLinkData = [];
576
        foreach ($testPostData as $testPostRow) {
577
            array_push($testPTLinkData, [
578
                'post_id' => $testPostRow['id'],
579
                'tag_id' => $testTagData['id'],
580
            ]);
581
        }
582
583
        array_walk($testPostData, [$this, 'insertPostData']);
584
        array_walk($testPTLinkData, [$this, 'insertPTLinkData']);
585
        $this->insertTagData($testTagData);
586
587
        $repository = new MysqlPostRepository(self::$connection);
588
        $data = $repository->getActivePostsByTag($testTagData['id'], 1, 3);
589
590
        $this->assertEmpty($data);
591
        $this->assertInternalType('array', $data);
592
    }
593
594
    public function testGetActivePostsCountByTag()
595
    {
596
        $testPostData = [
597
            [
598
                'id'      => rand(1, 100),
599
                'display' => 1,
600
            ],
601
            [
602
                'id'      => rand(101, 200),
603
                'display' => 1,
604
            ],
605
            [
606
                'id'      => rand(201, 300),
607
                'display' => 1,
608
            ],
609
        ];
610
611
        $testTagData = [
612
            'id' => rand(1, 100),
613
        ];
614
615
        $testPTLinkData = [];
616
        foreach ($testPostData as $testPostRow) {
617
            array_push($testPTLinkData, [
618
                'post_id' => $testPostRow['id'],
619
                'tag_id' => $testTagData['id'],
620
            ]);
621
        }
622
623
        array_walk($testPostData, [$this, 'insertPostData']);
624
        array_walk($testPTLinkData, [$this, 'insertPTLinkData']);
625
        $this->insertTagData($testTagData);
626
627
        $repository = new MysqlPostRepository(self::$connection);
628
        $data = $repository->getActivePostsCountByTag($testTagData['id']);
629
630
        $this->assertNotFalse($data);
631
        $this->assertStringMatchesFormat('%d', $data);
632
        $this->assertEquals(count($testPostData), $data);
633
    }
634
635
    public function testGetActivePostsCountByTagInactive()
636
    {
637
        $testPostData = [
638
            [
639
                'id'      => rand(1, 100),
640
                'display' => 1,
641
            ],
642
            [
643
                'id'      => rand(101, 200),
644
                'display' => 0,
645
            ],
646
            [
647
                'id'      => rand(201, 300),
648
                'display' => 1,
649
            ],
650
        ];
651
652
        $testTagData = [
653
            'id' => rand(1, 100),
654
        ];
655
656
        $testPTLinkData = [];
657
        foreach ($testPostData as $testPostRow) {
658
            array_push($testPTLinkData, [
659
                'post_id' => $testPostRow['id'],
660
                'tag_id' => $testTagData['id'],
661
            ]);
662
        }
663
664
        array_walk($testPostData, [$this, 'insertPostData']);
665
        array_walk($testPTLinkData, [$this, 'insertPTLinkData']);
666
        $this->insertTagData($testTagData);
667
668
        $repository = new MysqlPostRepository(self::$connection);
669
        $data = $repository->getActivePostsCountByTag($testTagData['id']);
670
671
        $this->assertNotFalse($data);
672
        $this->assertStringMatchesFormat('%d', $data);
673
674
        $testPostData = array_filter($testPostData, function ($row) {
675
            return ($row['display'] == 1);
676
        });
677
678
        $this->assertEquals(count($testPostData), $data);
679
    }
680
 
681
    public function testGetActivePostsCountByTagFailure()
682
    {
683
        $testTagData = [
684
            'id' => rand(1, 100),
685
        ];
686
687
        $this->insertTagData($testTagData);
688
689
        $repository = new MysqlPostRepository(self::$connection);
690
        $data = $repository->getActivePostsCountByTag($testTagData['id']);
691
692
        $this->assertNotFalse($data);
693
        $this->assertStringMatchesFormat('%d', $data);
694
        $this->assertEquals('0', $data);
695
    }
696
 
697
    public function testGetActivePostsByCategory()
698
    {
699
        $testData = [
700
            [
701
                'id'       => rand(1, 100),
702
                'title'    => 'title one',
703
                'path'     => 'path-one',
704
                'category' => 'test category',
705
                'date'     => (new DateTime('-1 day'))->format('Y-m-d H:i:s'),
706
                'body'     => 'body one',
707
                'display'  => 1,
708
            ],
709
            [
710
                'id'       => rand(101, 200),
711
                'title'    => 'title two',
712
                'path'     => 'path-two',
713
                'category' => 'test category',
714
                'date'     => (new DateTime())->format('Y-m-d H:i:s'),
715
                'body'     => 'body one',
716
                'display'  => 1,
717
            ],
718
        ];
719
720
        array_walk($testData, [$this, 'insertPostData']);
721
722
        $repository = new MysqlPostRepository(self::$connection);
723
        $data = $repository->getActivePostsByCategory(reset($testData)['category']);
724
725
        $this->assertNotFalse($data);
726
        $this->assertInternalType('array', $data);
727
        $this->assertCount(count($testData), $data);
728 View Code Duplication
        foreach ($testData as $key => $testDataRow) {
0 ignored issues
show
Duplication introduced by
This code seems to be duplicated across your project.

Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.

You can also find more detailed suggestions in the “Code” section of your repository.

Loading history...
729
            $this->assertArrayHasKey('id', $data[$key]);
730
            $this->assertEquals($testDataRow['id'], $data[$key]['id']);
731
            $this->assertArrayHasKey('title', $data[$key]);
732
            $this->assertEquals($testDataRow['title'], $data[$key]['title']);
733
            $this->assertArrayHasKey('path', $data[$key]);
734
            $this->assertEquals($testDataRow['path'], $data[$key]['path']);
735
            $this->assertArrayHasKey('date', $data[$key]);
736
            $this->assertEquals($testDataRow['date'], $data[$key]['date']);
737
            $this->assertArrayHasKey('body', $data[$key]);
738
            $this->assertEquals($testDataRow['body'], $data[$key]['body']);
739
            $this->assertArrayHasKey('category', $data[$key]);
740
            $this->assertEquals($testDataRow['category'], $data[$key]['category']);
741
        }
742
    }
743
744 View Code Duplication
    public function testGetActivePostsByCategoryInactive()
0 ignored issues
show
Duplication introduced by
This method seems to be duplicated in your project.

Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.

You can also find more detailed suggestions in the “Code” section of your repository.

Loading history...
745
    {
746
        $testData = [
747
            [
748
                'id'       => rand(1, 100),
749
                'category' => 'test category',
750
                'display'  => 1,
751
            ],
752
            [
753
                'id'       => rand(101, 200),
754
                'category' => 'test category',
755
                'display'  => 1,
756
            ],
757
            [
758
                'id'       => rand(201, 300),
759
                'category' => 'test category',
760
                'display'  => 0,
761
            ],
762
        ];
763
764
        array_walk($testData, [$this, 'insertPostData']);
765
766
        $repository = new MysqlPostRepository(self::$connection);
767
        $data = $repository->getActivePostsByCategory(reset($testData)['category']);
768
769
        $this->assertNotFalse($data);
770
        $this->assertInternalType('array', $data);
771
772
        $testData = array_filter($testData, function ($row) {
773
            return ($row['display'] == 1);
774
        });
775
776
        $this->assertCount(count($testData), $data);
777
778
        $testIds = array_column($testData, 'ids');
779
        $dataIds = array_column($data, 'ids');
780
781
        $this->assertEmpty(array_merge(
782
            array_diff($testIds, $dataIds),
783
            array_diff($dataIds, $testIds)
784
        ));
785
    }
786
 
787 View Code Duplication
    public function testGetActivePostsByCategoryFailure()
0 ignored issues
show
Duplication introduced by
This method seems to be duplicated in your project.

Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.

You can also find more detailed suggestions in the “Code” section of your repository.

Loading history...
788
    {
789
        $repository = new MysqlPostRepository(self::$connection);
790
        $data = $repository->getActivePostsByCategory('');
791
792
        $this->assertEmpty($data);
793
        $this->assertInternalType('array', $data);
794
    }
795
796 View Code Duplication
    public function testGetActivePostsByCategoryRange()
0 ignored issues
show
Duplication introduced by
This method seems to be duplicated in your project.

Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.

You can also find more detailed suggestions in the “Code” section of your repository.

Loading history...
797
    {
798
        $testData = [
799
            [
800
                'id'       => rand(1, 100),
801
                'category' => 'test category',
802
                'display'  => 1,
803
            ],
804
            [
805
                'id'       => rand(101, 200),
806
                'category' => 'test category',
807
                'display'  => 1,
808
            ],
809
            [
810
                'id'       => rand(201, 300),
811
                'category' => 'test category',
812
                'display'  => 1,
813
            ],
814
        ];
815
816
        array_walk($testData, [$this, 'insertPostData']);
817
818
        $repository = new MysqlPostRepository(self::$connection);
819
        $data = $repository->getActivePostsByCategory(reset($testData)['category'], 2, 1);
820
821
        $this->assertNotFalse($data);
822
        $this->assertInternalType('array', $data);
823
824
        $testData = array_slice($testData, 1, 2);
825
826
        $this->assertCount(count($testData), $data);
827
828
        $testIds = array_column($testData, 'ids');
829
        $dataIds = array_column($data, 'ids');
830
831
        $this->assertEmpty(array_merge(
832
            array_diff($testIds, $dataIds),
833
            array_diff($dataIds, $testIds)
834
        ));
835
    }
836
837 View Code Duplication
    public function testGetActivePostsByCategoryRangeFailure()
0 ignored issues
show
Duplication introduced by
This method seems to be duplicated in your project.

Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.

You can also find more detailed suggestions in the “Code” section of your repository.

Loading history...
838
    {
839
        $testData = [
840
            [
841
                'id'       => rand(1, 100),
842
                'category' => 'test category',
843
                'display'  => 1,
844
            ],
845
            [
846
                'id'       => rand(101, 200),
847
                'category' => 'test category',
848
                'display'  => 1,
849
            ],
850
            [
851
                'id'       => rand(201, 300),
852
                'category' => 'test category',
853
                'display'  => 1,
854
            ],
855
        ];
856
857
        array_walk($testData, [$this, 'insertPostData']);
858
859
        $repository = new MysqlPostRepository(self::$connection);
860
        $data = $repository->getActivePostsByCategory(reset($testData)['category'], 1, 3);
861
862
        $this->assertEmpty($data);
863
        $this->assertInternalType('array', $data);
864
    }
865
866
    public function testGetActivePostsCountByCategory()
867
    {
868
        $testData = [
869
            [
870
                'id'       => rand(1, 100),
871
                'category' => 'test category',
872
                'display'  => 1,
873
            ],
874
            [
875
                'id'       => rand(101, 200),
876
                'category' => 'test category',
877
                'display'  => 1,
878
            ],
879
            [
880
                'id'       => rand(201, 300),
881
                'category' => 'test category',
882
                'display'  => 1,
883
            ],
884
        ];
885
886
        array_walk($testData, [$this, 'insertPostData']);
887
888
        $repository = new MysqlPostRepository(self::$connection);
889
        $data = $repository->getActivePostsCountByCategory(reset($testData)['category']);
890
891
        $this->assertNotFalse($data);
892
        $this->assertStringMatchesFormat('%d', $data);
893
        $this->assertEquals(count($testData), $data);
894
    }
895
896 View Code Duplication
    public function testGetActivePostsCountByCategoryInactive()
0 ignored issues
show
Duplication introduced by
This method seems to be duplicated in your project.

Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.

You can also find more detailed suggestions in the “Code” section of your repository.

Loading history...
897
    {
898
        $testData = [
899
            [
900
                'id'       => rand(1, 100),
901
                'category' => 'test category',
902
                'display'  => 0,
903
            ],
904
            [
905
                'id'       => rand(101, 200),
906
                'category' => 'test category',
907
                'display'  => 1,
908
            ],
909
            [
910
                'id'       => rand(201, 300),
911
                'category' => 'test category',
912
                'display'  => 1,
913
            ],
914
        ];
915
916
        array_walk($testData, [$this, 'insertPostData']);
917
918
        $repository = new MysqlPostRepository(self::$connection);
919
        $data = $repository->getActivePostsCountByCategory(reset($testData)['category']);
920
921
        $this->assertNotFalse($data);
922
        $this->assertStringMatchesFormat('%d', $data);
923
924
        $testData = array_filter($testData, function ($row) {
925
            return ($row['display'] == 1);
926
        });
927
928
        $this->assertEquals(count($testData), $data);
929
    }
930
931 View Code Duplication
    public function testGetActivePostsCountByCategoryFailure()
0 ignored issues
show
Duplication introduced by
This method seems to be duplicated in your project.

Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.

You can also find more detailed suggestions in the “Code” section of your repository.

Loading history...
932
    {
933
        $repository = new MysqlPostRepository(self::$connection);
934
        $data = $repository->getActivePostsCountByCategory('');
935
936
        $this->assertNotFalse($data);
937
        $this->assertStringMatchesFormat('%d', $data);
938
        $this->assertEquals('0', $data);
939
    }
940
941
    public function testGetActivePostsByRelatedTags()
942
    {
943
        $testPostData = [
944
            [
945
                'id'       => rand(1, 100),
946
                'title'    => 'title one',
947
                'path'     => 'path-one',
948
                'category' => 'test category',
949
                'date'     => (new DateTime('-1 day'))->format('Y-m-d H:i:s'),
950
                'body'     => 'body one',
951
                'display'  => 1,
952
            ],
953
            [
954
                'id'       => rand(101, 200),
955
                'title'    => 'title two',
956
                'path'     => 'path-two',
957
                'category' => 'test category',
958
                'date'     => (new DateTime('-2 days'))->format('Y-m-d H:i:s'),
959
                'body'     => 'body two',
960
                'display'  => 1,
961
            ],
962
            [
963
                'id'       => rand(201, 300),
964
                'title'    => 'title three',
965
                'path'     => 'path-three',
966
                'category' => 'test category',
967
                'date'     => (new DateTime('-3 days'))->format('Y-m-d H:i:s'),
968
                'body'     => 'body three',
969
                'display'  => 1,
970
            ],
971
        ];
972
973
        $testTagData = [
974
            'id' => rand(1, 100),
975
        ];
976
977
        $testPTLinkData = [];
978
        foreach ($testPostData as $testPostRow) {
979
            array_push($testPTLinkData, [
980
                'post_id' => $testPostRow['id'],
981
                'tag_id' => $testTagData['id'],
982
            ]);
983
        }
984
985
        array_walk($testPostData, [$this, 'insertPostData']);
986
        array_walk($testPTLinkData, [$this, 'insertPTLinkData']);
987
        $this->insertTagData($testTagData);
988
989
        $repository = new MysqlPostRepository(self::$connection);
990
        $data = $repository->getActivePostsByRelatedTags(reset($testPostData)['id']);
991
992
        $this->assertNotFalse($data);
993
        $this->assertInternalType('array', $data);
994
995
        array_shift($testPostData);
996
997
        $this->assertCount(count($testPostData), $data);
998
        foreach ($testPostData as $key => $testPostRow) {
999
            $this->assertArrayHasKey('id', $data[$key]);
1000
            $this->assertEquals($testPostRow['id'], $data[$key]['id']);
1001
            $this->assertArrayHasKey('title', $data[$key]);
1002
            $this->assertEquals($testPostRow['title'], $data[$key]['title']);
1003
            $this->assertArrayHasKey('path', $data[$key]);
1004
            $this->assertEquals($testPostRow['path'], $data[$key]['path']);
1005
            $this->assertArrayHasKey('date', $data[$key]);
1006
            $this->assertEquals($testPostRow['date'], $data[$key]['date']);
1007
            $this->assertArrayHasKey('body', $data[$key]);
1008
            $this->assertEquals($testPostRow['body'], $data[$key]['body']);
1009
            $this->assertArrayHasKey('category', $data[$key]);
1010
            $this->assertEquals($testPostRow['category'], $data[$key]['category']);
1011
            $this->assertArrayHasKey('count', $data[$key]);
1012
            $this->assertEquals(count($testTagData), $data[$key]['count']);
1013
        }
1014
    }
1015
1016 View Code Duplication
    public function testGetActivePostsByRelatedTagsLimit()
0 ignored issues
show
Duplication introduced by
This method seems to be duplicated in your project.

Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.

You can also find more detailed suggestions in the “Code” section of your repository.

Loading history...
1017
    {
1018
        $testPostData = [
1019
            [
1020
                'id'      => rand(1, 100),
1021
                'display' => 1,
1022
            ],
1023
            [
1024
                'id'      => rand(101, 200),
1025
                'display' => 1,
1026
            ],
1027
            [
1028
                'id'      => rand(201, 300),
1029
                'display' => 1,
1030
            ],
1031
        ];
1032
1033
        $testTagData = [
1034
            'id' => rand(1, 100),
1035
        ];
1036
1037
        $testPTLinkData = [];
1038
        foreach ($testPostData as $testPostRow) {
1039
            array_push($testPTLinkData, [
1040
                'post_id' => $testPostRow['id'],
1041
                'tag_id' => $testTagData['id'],
1042
            ]);
1043
        }
1044
1045
        array_walk($testPostData, [$this, 'insertPostData']);
1046
        array_walk($testPTLinkData, [$this, 'insertPTLinkData']);
1047
        $this->insertTagData($testTagData);
1048
1049
        $repository = new MysqlPostRepository(self::$connection);
1050
        $data = $repository->getActivePostsByRelatedTags(reset($testPostData)['id'], 1);
1051
1052
        $this->assertNotFalse($data);
1053
        $this->assertInternalType('array', $data);
1054
1055
        $testPostData = array_slice($testPostData, 1, 1);
1056
1057
        $this->assertCount(count($testPostData), $data);
1058
1059
        $testIds = array_column($testPostData, 'ids');
1060
        $dataIds = array_column($data, 'ids');
1061
1062
        $this->assertEmpty(array_merge(
1063
            array_diff($testIds, $dataIds),
1064
            array_diff($dataIds, $testIds)
1065
        ));
1066
    }
1067
 
1068
    public function testGetActivePostsByRelatedTagsInactive()
1069
    {
1070
        $testPostData = [
1071
            [
1072
                'id'      => rand(1, 100),
1073
                'display' => 1,
1074
            ],
1075
            [
1076
                'id'      => rand(101, 200),
1077
                'display' => 1,
1078
            ],
1079
            [
1080
                'id'      => rand(201, 300),
1081
                'display' => 0,
1082
            ],
1083
            [
1084
                'id'      => rand(301, 400),
1085
                'display' => 1,
1086
            ],
1087
        ];
1088
1089
        $testTagData = [
1090
            'id' => rand(1, 100),
1091
        ];
1092
1093
        $testPTLinkData = [];
1094
        foreach ($testPostData as $testPostRow) {
1095
            array_push($testPTLinkData, [
1096
                'post_id' => $testPostRow['id'],
1097
                'tag_id' => $testTagData['id'],
1098
            ]);
1099
        }
1100
1101
        array_walk($testPostData, [$this, 'insertPostData']);
1102
        array_walk($testPTLinkData, [$this, 'insertPTLinkData']);
1103
        $this->insertTagData($testTagData);
1104
1105
        $repository = new MysqlPostRepository(self::$connection);
1106
        $data = $repository->getActivePostsByRelatedTags(reset($testPostData)['id']);
1107
1108
        $this->assertNotFalse($data);
1109
        $this->assertInternalType('array', $data);
1110
1111
        array_shift($testPostData);
1112
        $testPostData = array_filter($testPostData, function ($row) {
1113
            return ($row['display'] == 1);
1114
        });
1115
1116
        $this->assertCount(count($testPostData), $data);
1117
1118
        $testIds = array_column($testPostData, 'ids');
1119
        $dataIds = array_column($data, 'ids');
1120
1121
        $this->assertEmpty(array_merge(
1122
            array_diff($testIds, $dataIds),
1123
            array_diff($dataIds, $testIds)
1124
        ));
1125
    }
1126
 
1127
    public function testGetActivePostsByRelatedTagsExcludeSeries()
1128
    {
1129
        $testPostData = [
1130
            [
1131
                'id'      => rand(1, 100),
1132
                'display' => 1,
1133
            ],
1134
            [
1135
                'id'      => rand(101, 200),
1136
                'display' => 1,
1137
            ],
1138
            [
1139
                'id'      => rand(201, 300),
1140
                'display' => 1,
1141
            ],
1142
            [
1143
                'id'      => rand(301, 400),
1144
                'display' => 1,
1145
            ],
1146
        ];
1147
1148
        $testTagData = [
1149
            'id' => rand(1, 100),
1150
        ];
1151
1152
        $testPTLinkData = [];
1153
        foreach ($testPostData as $testPostRow) {
1154
            array_push($testPTLinkData, [
1155
                'post_id' => $testPostRow['id'],
1156
                'tag_id' => $testTagData['id'],
1157
            ]);
1158
        }
1159
1160
        $seriesPostKey = rand(1, 3);
1161
        $testSeriesPostData = [
1162
            [
1163
                'series' => 1,
1164
                'post' => reset($testPostData)['id'],
1165
            ],
1166
            [
1167
                'series' => 1,
1168
                'post' => $testPostData[$seriesPostKey]['id'],
1169
            ],
1170
        ];
1171
1172
        array_walk($testPostData, [$this, 'insertPostData']);
1173
        array_walk($testPTLinkData, [$this, 'insertPTLinkData']);
1174
        array_walk($testSeriesPostData, [$this, 'insertSeriesPostData']);
1175
        $this->insertTagData($testTagData);
1176
1177
        $repository = new MysqlPostRepository(self::$connection);
1178
        $data = $repository->getActivePostsByRelatedTags(reset($testPostData)['id']);
1179
1180
        $this->assertNotFalse($data);
1181
        $this->assertInternalType('array', $data);
1182
1183
        array_shift($testPostData);
1184
        $testPostData = array_filter($testPostData, function ($row) use ($testSeriesPostData) {
1185
            return (!in_array($row['id'], array_column($testSeriesPostData, 'post')));
1186
        });
1187
1188
        $this->assertCount(count($testPostData), $data);
1189
1190
        $testIds = array_column($testPostData, 'ids');
1191
        $dataIds = array_column($data, 'ids');
1192
1193
        $this->assertEmpty(array_merge(
1194
            array_diff($testIds, $dataIds),
1195
            array_diff($dataIds, $testIds)
1196
        ));
1197
    }
1198
1199 View Code Duplication
    public function testGetActivePostsByRelatedTagsFailure()
0 ignored issues
show
Duplication introduced by
This method seems to be duplicated in your project.

Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.

You can also find more detailed suggestions in the “Code” section of your repository.

Loading history...
1200
    {
1201
        $repository = new MysqlPostRepository(self::$connection);
1202
        $data = $repository->getActivePostsByRelatedTags('');
1203
1204
        $this->assertEmpty($data);
1205
        $this->assertInternalType('array', $data);
1206
    }
1207
1208 View Code Duplication
    protected function insertPostData(array $data)
0 ignored issues
show
Duplication introduced by
This method seems to be duplicated in your project.

Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.

You can also find more detailed suggestions in the “Code” section of your repository.

Loading history...
1209
    {
1210
        $defaultData = [
1211
            'id' => null,
1212
            'title' => '',
1213
            'path' => '',
1214
            'category' => '',
1215
            'date' => '',
1216
            'body' => '',
1217
            'display' => 0,
1218
        ];
1219
1220
        $data = array_merge($defaultData, $data);
1221
1222
        return self::$connection->getDefault()->perform("
1223
            INSERT INTO `jpemeric_blog`.`post`
1224
                (id, title, path, category, date, body, display)
1225
            VALUES
1226
                (:id, :title, :path, :category, :date, :body, :display)",
1227
            $data
1228
        );
1229
    }
1230
1231 View Code Duplication
    protected function insertPTLinkData(array $data)
0 ignored issues
show
Duplication introduced by
This method seems to be duplicated in your project.

Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.

You can also find more detailed suggestions in the “Code” section of your repository.

Loading history...
1232
    {
1233
        $defaultData = [
1234
            'post' => null,
1235
            'tag' => null,
1236
        ];
1237
1238
        $data = array_merge($defaultData, $data);
1239
1240
        return self::$connection->getDefault()->perform("
1241
            INSERT INTO `jpemeric_blog`.`ptlink`
1242
                (post_id, tag_id)
1243
            VALUES
1244
                (:post_id, :tag_id)",
1245
            $data
1246
        );
1247
    }
1248
1249 View Code Duplication
    protected function insertSeriesPostData(array $data)
0 ignored issues
show
Duplication introduced by
This method seems to be duplicated in your project.

Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.

You can also find more detailed suggestions in the “Code” section of your repository.

Loading history...
1250
    {
1251
        $defaultData = [
1252
            'series' => '',
1253
            'post' => '',
1254
            'order' => 0,
1255
        ];
1256
1257
        $data = array_merge($defaultData, $data);
1258
1259
        return self::$connection->getDefault()->perform("
1260
            INSERT INTO `jpemeric_blog`.`series_post`
1261
                (series, post, `order`)
1262
            VALUES
1263
                (:series, :post, :order)",
1264
            $data
1265
        );
1266
    }
1267
1268 View Code Duplication
    protected function insertTagData(array $data)
0 ignored issues
show
Duplication introduced by
This method seems to be duplicated in your project.

Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.

You can also find more detailed suggestions in the “Code” section of your repository.

Loading history...
1269
    {
1270
        $defaultData = [
1271
            'id' => null,
1272
            'tag' => '',
1273
        ];
1274
1275
        $data = array_merge($defaultData, $data);
1276
1277
        return self::$connection->getDefault()->perform("
1278
            INSERT INTO `jpemeric_blog`.`tag`
1279
                (id, tag)
1280
            VALUES
1281
                (:id, :tag)",
1282
            $data
1283
        );
1284
    }
1285
1286
    protected function tearDown()
1287
    {
1288
        self::$connection->getDefault()->perform("DELETE FROM `jpemeric_blog`.`post`");
1289
        self::$connection->getDefault()->perform("DELETE FROM `jpemeric_blog`.`ptlink`");
1290
        self::$connection->getDefault()->perform("DELETE FROM `jpemeric_blog`.`series_post`");
1291
        self::$connection->getDefault()->perform("DELETE FROM `jpemeric_blog`.`tag`");
1292
    }
1293
1294
    public static function tearDownAfterClass()
1295
    {
1296
        self::$connection->getDefault()->disconnect();
0 ignored issues
show
Bug introduced by
The method disconnect() does not exist on Aura\Sql\ExtendedPdoInterface. Did you maybe mean connect()?

This check marks calls to methods that do not seem to exist on an object.

This is most likely the result of a method being renamed without all references to it being renamed likewise.

Loading history...
1297
        unlink('jpemeric_blog.db');
1298
    }
1299
}
1300