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); |
|
|
|
|
71
|
|
|
} |
72
|
|
|
} |
73
|
|
|
|
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.