BeanstalkTest   A
last analyzed

Complexity

Total Complexity 1

Size/Duplication

Total Lines 22
Duplicated Lines 0 %

Importance

Changes 1
Bugs 0 Features 1
Metric Value
eloc 14
dl 0
loc 22
rs 10
c 1
b 0
f 1
wmc 1

1 Method

Rating   Name   Duplication   Size   Complexity  
A testPut() 0 20 1
1
<?php
2
declare(strict_types=1);
3
4
namespace JCIT\jobqueue\tests\unit\components\jobQueues;
5
6
use Codeception\Test\Unit;
7
use JCIT\jobqueue\components\jobQueues\Beanstalk;
8
use JCIT\jobqueue\components\jobQueues\Synchronous;
9
use JCIT\jobqueue\factories\JobFactory;
10
use JCIT\jobqueue\interfaces\JobInterface;
11
use JCIT\jobqueue\jobs\HelloJob;
12
use League\Tactician\CommandBus;
13
use Pheanstalk\Connection;
14
15
class BeanstalkTest extends Unit
16
{
17
    public function testPut(): void
18
    {
19
        $connection = $this->createMock(Connection::class);
20
        $jobFactory = $this->createMock(JobFactory::class);
21
        $counter = 0;
22
        $beforePut = static function (JobInterface $job) use (&$counter) {
0 ignored issues
show
Unused Code introduced by
The parameter $job is not used and could be removed. ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-unused  annotation

22
        $beforePut = static function (/** @scrutinizer ignore-unused */ JobInterface $job) use (&$counter) {

This check looks for parameters that have been defined for a function or method, but which are not used in the method body.

Loading history...
23
            $counter++;
24
        };
25
26
        $jobQueue = $this->getMockBuilder(Beanstalk::class)
27
            ->setConstructorArgs([$connection, $jobFactory, $beforePut])
28
            ->onlyMethods(['put'])
29
            ->getMock();
30
        ;
31
32
        $jobQueue->expects($this->once())->method('put');
33
34
        $job = new HelloJob('Test');
35
        $jobQueue->putJob($job);
36
        $this->assertEquals(1, $counter);
37
    }
38
}
39