| @@ 363-395 (lines=33) @@ | ||
| 360 | $this->assertInternalType('array', $data); |
|
| 361 | } |
|
| 362 | ||
| 363 | public function testGetActivitiesByTypeCount() |
|
| 364 | { |
|
| 365 | $testData = [ |
|
| 366 | [ |
|
| 367 | 'id' => rand(1, 100), |
|
| 368 | 'message' => 'test one', |
|
| 369 | 'type' => 'type one', |
|
| 370 | ], |
|
| 371 | [ |
|
| 372 | 'id' => rand(101, 200), |
|
| 373 | 'message' => 'test two', |
|
| 374 | 'type' => 'type two', |
|
| 375 | ], |
|
| 376 | [ |
|
| 377 | 'id' => rand(201, 300), |
|
| 378 | 'message' => 'test three', |
|
| 379 | 'type' => 'type one', |
|
| 380 | ], |
|
| 381 | ]; |
|
| 382 | ||
| 383 | array_walk($testData, [$this, 'insertData']); |
|
| 384 | ||
| 385 | $repository = new MysqlActivityRepository(self::$connection); |
|
| 386 | $data = $repository->getActivitiesByTypeCount('type one'); |
|
| 387 | ||
| 388 | $testData = array_filter($testData, function ($row) { |
|
| 389 | return ($row['type'] == 'type one'); |
|
| 390 | }); |
|
| 391 | ||
| 392 | $this->assertNotFalse($data); |
|
| 393 | $this->assertStringMatchesFormat('%d', $data); |
|
| 394 | $this->assertEquals(count($testData), $data); |
|
| 395 | } |
|
| 396 | ||
| 397 | public function testGetActivitiesByTypeCountEmpty() |
|
| 398 | { |
|
| @@ 905-938 (lines=34) @@ | ||
| 902 | $this->assertEquals(count($testData), $data); |
|
| 903 | } |
|
| 904 | ||
| 905 | public function testGetActivePostsCountByCategoryInactive() |
|
| 906 | { |
|
| 907 | $testData = [ |
|
| 908 | [ |
|
| 909 | 'id' => rand(1, 100), |
|
| 910 | 'category' => 'test category', |
|
| 911 | 'display' => 0, |
|
| 912 | ], |
|
| 913 | [ |
|
| 914 | 'id' => rand(101, 200), |
|
| 915 | 'category' => 'test category', |
|
| 916 | 'display' => 1, |
|
| 917 | ], |
|
| 918 | [ |
|
| 919 | 'id' => rand(201, 300), |
|
| 920 | 'category' => 'test category', |
|
| 921 | 'display' => 1, |
|
| 922 | ], |
|
| 923 | ]; |
|
| 924 | ||
| 925 | array_walk($testData, [$this, 'insertPostData']); |
|
| 926 | ||
| 927 | $repository = new MysqlPostRepository(self::$connection); |
|
| 928 | $data = $repository->getActivePostsCountByCategory(reset($testData)['category']); |
|
| 929 | ||
| 930 | $this->assertNotFalse($data); |
|
| 931 | $this->assertStringMatchesFormat('%d', $data); |
|
| 932 | ||
| 933 | $testData = array_filter($testData, function ($row) { |
|
| 934 | return ($row['display'] == 1); |
|
| 935 | }); |
|
| 936 | ||
| 937 | $this->assertEquals(count($testData), $data); |
|
| 938 | } |
|
| 939 | ||
| 940 | public function testGetActivePostsCountByCategoryFailure() |
|
| 941 | { |
|