NewSingleThreadDefaultProcessorTest   A
last analyzed

Complexity

Total Complexity 2

Size/Duplication

Total Lines 46
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 1

Importance

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

2 Methods

Rating   Name   Duplication   Size   Complexity  
A setUp() 0 7 1
A testProcess() 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\Form\FormModelProcessor;
12
13
use Miliooo\Messaging\Form\FormModelProcessor\NewSingleThreadDefaultProcessor;
14
15
/**
16
 * Test file for Miliooo\Messaging\Form\FormModelProcessor\NewSingleThreadDefaultProcesser
17
 *
18
 * @author Michiel Boeckaert <[email protected]>
19
 */
20
class NewSingleThreadDefaultProcessorTest extends \PHPUnit_Framework_TestCase
21
{
22
    /**
23
     * The class under test
24
     *
25
     * @var NewSingleThreadDefaultProcessor
26
     */
27
    private $processor;
28
29
    /**
30
     * @var \PHPUnit_Framework_MockObject_MockObject
31
     */
32
    private $newThreadBuilder;
33
34
    /**
35
     * @var \PHPUnit_Framework_MockObject_MockObject
36
     */
37
    private $newMessageManager;
38
39
    /**
40
     * @var \PHPUnit_Framework_MockObject_MockObject
41
     */
42
    private $newThreadModel;
43
44
    public function setUp()
45
    {
46
        $this->newThreadBuilder = $this->getMockBuilder('Miliooo\Messaging\Builder\Message\NewThreadBuilder')->disableOriginalConstructor()->getMock();
47
        $this->newMessageManager = $this->getMock('Miliooo\Messaging\Manager\NewMessageManagerInterface');
48
        $this->newThreadModel = $this->getMock('Miliooo\Messaging\Form\FormModel\NewThreadInterface');
49
        $this->processor = new NewSingleThreadDefaultProcessor($this->newThreadBuilder, $this->newMessageManager);
50
    }
51
52
    public function testProcess()
53
    {
54
        $newThread = $this->getMock('Miliooo\Messaging\Model\ThreadInterface');
55
        $this->newThreadBuilder->expects($this->once())
56
            ->method('build')
57
            ->will($this->returnValue($newThread));
58
59
        $message = $this->getMock('Miliooo\Messaging\Model\MessageInterface');
60
        $newThread->expects($this->once())->method('getLastMessage')->will($this->returnValue($message));
61
62
        $this->newMessageManager->expects($this->once())->method('saveNewThread')->with($message);
63
        $this->processor->process($this->newThreadModel);
64
    }
65
}
66