Completed
Push — 3.x-dev-kit ( cc4dbe )
by
unknown
03:15
created

BaseMessageTest   A

Complexity

Total Complexity 1

Size/Duplication

Total Lines 16
Duplicated Lines 0 %

Coupling/Cohesion

Components 0
Dependencies 2

Importance

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

1 Method

Rating   Name   Duplication   Size   Complexity  
A testClone() 0 13 1
1
<?php
2
3
/*
4
 * This file is part of the Sonata Project package.
5
 *
6
 * (c) Thomas Rabaix <[email protected]>
7
 *
8
 * For the full copyright and license information, please view the LICENSE
9
 * file that was distributed with this source code.
10
 */
11
12
namespace Sonata\NotificationBundle\Tests\Entity;
13
14
use Sonata\NotificationBundle\Entity\BaseMessage;
15
use Sonata\NotificationBundle\Model\MessageInterface;
16
17
class Message extends BaseMessage
18
{
19
    public function setId($id)
20
    {
21
        $this->id = $id;
22
    }
23
}
24
25
class BaseMessageTest extends \PHPUnit_Framework_TestCase
0 ignored issues
show
Coding Style Compatibility introduced by
PSR1 recommends that each class should be in its own file to aid autoloaders.

Having each class in a dedicated file usually plays nice with PSR autoloaders and is therefore a well established practice. If you use other autoloaders, you might not want to follow this rule.

Loading history...
26
{
27
    public function testClone()
28
    {
29
        $originalMessage = new Message();
30
        $originalMessage->setId(42);
31
        $originalMessage->setBody('body');
0 ignored issues
show
Documentation introduced by
'body' is of type string, but the function expects a array.

It seems like the type of the argument is not accepted by the function/method which you are calling.

In some cases, in particular if PHP’s automatic type-juggling kicks in this might be fine. In other cases, however this might be a bug.

We suggest to add an explicit type cast like in the following example:

function acceptsInteger($int) { }

$x = '123'; // string "123"

// Instead of
acceptsInteger($x);

// we recommend to use
acceptsInteger((integer) $x);
Loading history...
32
        $originalMessage->setState(MessageInterface::STATE_ERROR);
33
34
        $clonedMessage = clone $originalMessage;
35
36
        $this->assertEquals('body', $clonedMessage->getBody());
37
        $this->assertEquals(MessageInterface::STATE_ERROR, $clonedMessage->getState());
38
        $this->assertNull($clonedMessage->getId());
39
    }
40
}
41