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

MessageManagerBackendDispatcherTest::testCreate()   B

Complexity

Conditions 1
Paths 1

Size

Total Lines 26
Code Lines 15

Duplication

Lines 0
Ratio 0 %

Importance

Changes 3
Bugs 0 Features 2
Metric Value
c 3
b 0
f 2
dl 0
loc 26
rs 8.8571
cc 1
eloc 15
nc 1
nop 0
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\Backend;
13
14
use Sonata\NotificationBundle\Backend\MessageManagerBackendDispatcher;
15
use Sonata\NotificationBundle\Model\Message;
16
17
/**
18
 * @author Hugo Briand <[email protected]>
19
 */
20
class MessageManagerBackendDispatcherTest extends \PHPUnit_Framework_TestCase
21
{
22
    public function testCreate()
23
    {
24
        $testBackend = $this->getMockBuilder('Sonata\NotificationBundle\Backend\MessageManagerBackend')
25
            ->disableOriginalConstructor()
26
            ->getMock()
27
        ;
28
29
        $testBackend->expects($this->once())
30
            ->method('setDispatcher')
31
        ;
32
33
        $message = new Message();
34
        $message->setType('test');
35
        $message->setBody(array());
36
37
        $testBackend->expects($this->once())
38
            ->method('create')
39
            ->will($this->returnValue($message))
40
        ;
41
42
        $mMgr = $this->getMock('Sonata\NotificationBundle\Model\MessageManagerInterface');
43
44
        $mMgrBackend = new MessageManagerBackendDispatcher($mMgr, array(), '', array(array('types' => array('test'), 'backend' => $testBackend)));
45
46
        $this->assertEquals($message, $mMgrBackend->create('test', array()));
47
    }
48
}
49