Code Duplication    Length = 36-38 lines in 2 locations

tests/unit/Service/QueueRepublishServiceTest.php 1 location

@@ 25-60 (lines=36) @@
22
     *
23
     * @dataProvider dataRestoreQueues
24
     */
25
    public function testRestoreQueues(array $queueMessages): void
26
    {
27
        $mockQueueService = $this->getMockQueueService(
28
            [
29
                'getToRepublish',
30
                'beginTransaction',
31
                'commit',
32
                'flush',
33
                'isTransactionActive',
34
            ]
35
        );
36
        $mockQueueService
37
            ->expects($this->once())
38
            ->method('beginTransaction');
39
        $mockQueueService
40
            ->expects($this->once())
41
            ->method('commit');
42
        $mockQueueService
43
            ->expects($this->once())
44
            ->method('flush');
45
        $mockQueueService
46
            ->expects($this->once())
47
            ->method('getToRepublish')
48
            ->willReturn($queueMessages);
49
        $mockPublisherFactory = $this->getMockPublisherFactory(['republish', 'releaseAll']);
50
        $mockPublisherFactory
51
            ->expects($this->exactly(count($queueMessages)))
52
            ->method('republish');
53
        $mockPublisherFactory
54
            ->expects($this->once())
55
            ->method('releaseAll');
56
57
        $queueRepublishService = $this->createService($mockPublisherFactory, $mockQueueService);
58
59
        $this->assertTrue($queueRepublishService->republishQueues(5));
60
    }
61
62
    /**
63
     * @throws \Exception

tests/unit/Service/QueueRequeueServiceTest.php 1 location

@@ 25-62 (lines=38) @@
22
     *
23
     * @dataProvider dataRestoreQueues
24
     */
25
    public function testRestoreQueues(array $queueMessages): void
26
    {
27
        $mockQueueService = $this->getMockQueueService(
28
            [
29
                'getToRestore',
30
                'beginTransaction',
31
                'commit',
32
                'flush',
33
                'isTransactionActive',
34
            ]
35
        );
36
37
        $mockQueueService
38
            ->expects($this->once())
39
            ->method('beginTransaction');
40
        $mockQueueService
41
            ->expects($this->once())
42
            ->method('commit');
43
        $mockQueueService
44
            ->expects($this->exactly(count($queueMessages)))
45
            ->method('flush');
46
        $mockQueueService
47
            ->expects($this->once())
48
            ->method('getToRestore')
49
            ->willReturn($queueMessages);
50
51
        $mockPublisherFactory = $this->getMockPublisherFactory(['requeue', 'releaseAll']);
52
        $mockPublisherFactory
53
            ->expects($this->exactly(count($queueMessages)))
54
            ->method('requeue');
55
        $mockPublisherFactory
56
            ->expects($this->once())
57
            ->method('releaseAll');
58
59
        $queueRequeueService = $this->createService($mockPublisherFactory, $mockQueueService);
60
61
        $this->assertTrue($queueRequeueService->restoreQueues(5));
62
    }
63
64
    public function dataRestoreQueues(): array
65
    {