NewMessageManagerTest   A
last analyzed

Complexity

Total Complexity 3

Size/Duplication

Total Lines 53
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 1

Importance

Changes 0
Metric Value
wmc 3
lcom 1
cbo 1
dl 0
loc 53
rs 10
c 0
b 0
f 0

3 Methods

Rating   Name   Duplication   Size   Complexity  
A setUp() 0 6 1
A testSaveNewThread() 0 12 1
A testSaveNewReply() 0 13 1
1
<?php
2
3
/*
4
 * This file is part of the MilioooMessageBundle package.
5
 *
6
 * (c) Michiel boeckaert <[email protected]>
7
 * This source file is subject to the MIT license that is bundled
8
 * with this source code in the file LICENSE.
9
 */
10
11
namespace Miliooo\Messaging\Tests\Manager;
12
13
use Miliooo\Messaging\Manager\NewMessageManager;
14
15
/**
16
 * Test file for Miliooo\Messaging\Manager\NewMessageManager
17
 *
18
 * @author Michiel Boeckaert <[email protected]>
19
 */
20
class NewMessageManagerTest extends \PHPUnit_Framework_TestCase
21
{
22
    /**
23
     * The class under test
24
     *
25
     * @var NewMessageManager
26
     */
27
    private $manager;
28
29
    /**
30
     * @var \PHPUnit_Framework_MockObject_MockObject
31
     */
32
    private $msgRepo;
33
34
    /**
35
     * @var \PHPUnit_Framework_MockObject_MockObject
36
     */
37
    private $threadRepo;
38
39
    public function setUp()
40
    {
41
        $this->msgRepo = $this->getMock('Miliooo\Messaging\Repository\MessageRepositoryInterface');
42
        $this->threadRepo = $this->getMock('Miliooo\Messaging\Repository\ThreadRepositoryInterface');
43
        $this->manager = new NewMessageManager($this->msgRepo, $this->threadRepo);
44
    }
45
46
    public function testSaveNewThread()
47
    {
48
        $message = $this->getMock('Miliooo\Messaging\Model\MessageInterface');
49
        $thread = $this->getMock('Miliooo\Messaging\Model\ThreadInterface');
50
        $message->expects($this->once())->method('getThread')->will($this->returnValue($thread));
51
        $this->msgRepo->expects($this->once())->method('save')
52
            ->with($message, false);
53
        $this->threadRepo->expects($this->once())->method('save')
54
            ->with($thread, true);
55
56
        $this->manager->saveNewThread($message);
57
    }
58
59
    public function testSaveNewReply()
60
    {
61
        $message = $this->getMock('Miliooo\Messaging\Model\MessageInterface');
62
        $thread = $this->getMock('Miliooo\Messaging\Model\ThreadInterface');
63
64
        $message->expects($this->once())->method('getThread')->will($this->returnValue($thread));
65
        $this->msgRepo->expects($this->once())->method('save')
66
            ->with($message, false);
67
        $this->threadRepo->expects($this->once())->method('save')
68
            ->with($thread, true);
69
70
        $this->manager->saveNewReply($message, $thread);
0 ignored issues
show
Unused Code introduced by
The call to NewMessageManager::saveNewReply() has too many arguments starting with $thread.

This check compares calls to functions or methods with their respective definitions. If the call has more arguments than are defined, it raises an issue.

If a function is defined several times with a different number of parameters, the check may pick up the wrong definition and report false positives. One codebase where this has been known to happen is Wordpress.

In this case you can add the @ignore PhpDoc annotation to the duplicate definition and it will be ignored.

Loading history...
71
    }
72
}
73