AMQPMessageFactoryTest   A
last analyzed

Complexity

Total Complexity 2

Size/Duplication

Total Lines 29
Duplicated Lines 0 %

Coupling/Cohesion

Components 0
Dependencies 2

Importance

Changes 1
Bugs 0 Features 0
Metric Value
wmc 2
c 1
b 0
f 0
lcom 0
cbo 2
dl 0
loc 29
rs 10

2 Methods

Rating   Name   Duplication   Size   Complexity  
A testCreate() 0 9 1
A testCreateWithWrongClass() 0 6 1
1
<?php
2
3
namespace Ajir\RabbitMqSqlBundle\Tests\DataStructure\Message;
4
5
use \PHPUnit_Framework_TestCase as BaseTestCase;
6
use Ajir\RabbitMqSqlBundle\DataStructure\Message\AMQPMessageFactory;
7
8
/**
9
 *
10
 */
11
class AMQPMessageFactoryTest extends BaseTestCase
12
{
13
    /**
14
     * Test creating a new AMQPMessage instance with the factory
15
     *
16
     * @return void
17
     */
18
    public function testCreate()
19
    {
20
        $factory = new AMQPMessageFactory();
21
22
        $this->assertInstanceof(
23
            AMQPMessageFactory::DEFAULT_CLASS,
24
            $factory->create()
25
        );
26
    }
27
28
    /**
29
     * Test using the factory with a wrong AMQPMessage class
30
     * 
31
     * @return void
32
     */
33
    public function testCreateWithWrongClass()
34
    {
35
        $this->setExpectedException('InvalidArgumentException');
36
37
        $factory = new AMQPMessageFactory('stdClass');
0 ignored issues
show
Unused Code introduced by
$factory is not used, you could remove the assignment.

This check looks for variable assignements that are either overwritten by other assignments or where the variable is not used subsequently.

$myVar = 'Value';
$higher = false;

if (rand(1, 6) > 3) {
    $higher = true;
} else {
    $higher = false;
}

Both the $myVar assignment in line 1 and the $higher assignment in line 2 are dead. The first because $myVar is never used and the second because $higher is always overwritten for every possible time line.

Loading history...
38
    }
39
}
40