testCanMessageRecipientSpecReturnsFalse()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 8
Code Lines 5

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
dl 0
loc 8
rs 9.4285
c 0
b 0
f 0
cc 1
eloc 5
nc 1
nop 0
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\CanMessageRecipientManager;
14
use Miliooo\Messaging\TestHelpers\ParticipantTestHelper;
15
use Miliooo\Messaging\User\ParticipantInterface;
16
17
/**
18
 * Class CanMessageRecipientManagerTest
19
 *
20
 * @author Michiel Boeckaert <[email protected]>
21
 */
22
class CanMessageRecipientManagerTest extends \PHPUnit_Framework_TestCase
23
{
24
    /**
25
     * The class under test.
26
     *
27
     * @var CanMessageRecipientManager
28
     */
29
    private $manager;
30
    /**
31
     * @var \PHPUnit_Framework_MockObject_MockObject
32
     */
33
    private $specification;
34
35
    /**
36
     * @var ParticipantInterface
37
     */
38
    private $loggedInUser;
39
40
    /**
41
     * @var ParticipantInterface
42
     */
43
    private $recipient;
44
45
    public function setUp()
46
    {
47
        $this->loggedInUser = new ParticipantTestHelper('1');
48
        $this->recipient = new ParticipantTestHelper('2');
49
        $this->specification = $this->getMock('Miliooo\Messaging\Specifications\CanMessageRecipientInterface');
50
        $this->manager = new CanMessageRecipientManager($this->specification);
51
    }
52
53
    public function testInterface()
54
    {
55
        $this->assertInstanceOf('Miliooo\Messaging\Manager\CanMessageRecipientManagerInterface', $this->manager);
56
    }
57
58
    public function testCanMessageRecipientSpecReturnsFalse()
59
    {
60
        $this->specification->expects($this->once())->method('isSatisfiedBy')
61
            ->with($this->loggedInUser, $this->recipient)
62
            ->will($this->returnValue(false));
63
64
        $this->assertFalse($this->manager->canMessageRecipient($this->loggedInUser, $this->recipient));
65
    }
66
67
    public function testCanMessageRecipientSpecReturnsTrue()
68
    {
69
        $this->specification->expects($this->once())->method('isSatisfiedBy')
70
            ->with($this->loggedInUser, $this->recipient)
71
            ->will($this->returnValue(true));
72
73
        $this->assertTrue($this->manager->canMessageRecipient($this->loggedInUser, $this->recipient));
74
    }
75
}
76