Completed
Pull Request — 3.x (#241)
by
unknown
03:55 queued 01:47
created

MessageManagerBackendDispatcherTest::testCreate()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 23
Code Lines 13

Duplication

Lines 0
Ratio 0 %

Importance

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