Code Duplication    Length = 40-42 lines in 2 locations

tests/unit/Domain/Blog/Post/MysqlPostRepositoryTest.php 2 locations

@@ 753-794 (lines=42) @@
750
        }
751
    }
752
753
    public function testGetActivePostsByCategoryInactive()
754
    {
755
        $testData = [
756
            [
757
                'id'       => rand(1, 100),
758
                'category' => 'test category',
759
                'display'  => 1,
760
            ],
761
            [
762
                'id'       => rand(101, 200),
763
                'category' => 'test category',
764
                'display'  => 1,
765
            ],
766
            [
767
                'id'       => rand(201, 300),
768
                'category' => 'test category',
769
                'display'  => 0,
770
            ],
771
        ];
772
773
        array_walk($testData, [$this, 'insertPostData']);
774
775
        $repository = new MysqlPostRepository(self::$connection);
776
        $data = $repository->getActivePostsByCategory(reset($testData)['category']);
777
778
        $this->assertNotFalse($data);
779
        $this->assertInternalType('array', $data);
780
781
        $testData = array_filter($testData, function ($row) {
782
            return ($row['display'] == 1);
783
        });
784
785
        $this->assertCount(count($testData), $data);
786
787
        $testIds = array_column($testData, 'ids');
788
        $dataIds = array_column($data, 'ids');
789
790
        $this->assertEmpty(array_merge(
791
            array_diff($testIds, $dataIds),
792
            array_diff($dataIds, $testIds)
793
        ));
794
    }
795
 
796
    public function testGetActivePostsByCategoryFailure()
797
    {
@@ 805-844 (lines=40) @@
802
        $this->assertInternalType('array', $data);
803
    }
804
805
    public function testGetActivePostsByCategoryRange()
806
    {
807
        $testData = [
808
            [
809
                'id'       => rand(1, 100),
810
                'category' => 'test category',
811
                'display'  => 1,
812
            ],
813
            [
814
                'id'       => rand(101, 200),
815
                'category' => 'test category',
816
                'display'  => 1,
817
            ],
818
            [
819
                'id'       => rand(201, 300),
820
                'category' => 'test category',
821
                'display'  => 1,
822
            ],
823
        ];
824
825
        array_walk($testData, [$this, 'insertPostData']);
826
827
        $repository = new MysqlPostRepository(self::$connection);
828
        $data = $repository->getActivePostsByCategory(reset($testData)['category'], 2, 1);
829
830
        $this->assertNotFalse($data);
831
        $this->assertInternalType('array', $data);
832
833
        $testData = array_slice($testData, 1, 2);
834
835
        $this->assertCount(count($testData), $data);
836
837
        $testIds = array_column($testData, 'ids');
838
        $dataIds = array_column($data, 'ids');
839
840
        $this->assertEmpty(array_merge(
841
            array_diff($testIds, $dataIds),
842
            array_diff($dataIds, $testIds)
843
        ));
844
    }
845
846
    public function testGetActivePostsByCategoryRangeFailure()
847
    {