testIsSatisfiedByReturnsTrueWhenParticipant()   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\MessagingBundle\Tests\Specifications;
12
13
use Miliooo\Messaging\Specifications\CanSeeThreadSpecification;
14
use Miliooo\Messaging\TestHelpers\ParticipantTestHelper;
15
use Miliooo\Messaging\User\ParticipantInterface;
16
17
/**
18
 * Test file for Miliooo\Messaging\Specifications\CanSeeThreadSpecification
19
 *
20
 * @author Michiel Boeckaert <[email protected]>
21
 */
22
class CanSeeThreadSpecificationTest extends \PHPUnit_Framework_TestCase
23
{
24
    /**
25
     * Class under test.
26
     *
27
     * @var CanSeeThreadSpecification|\PHPUnit_Framework_MockObject_MockObject
28
     */
29
    private $specification;
30
31
    /**
32
     * @var \PHPUnit_Framework_MockObject_MockObject
33
     */
34
    private $thread;
35
36
    /**
37
     * @var ParticipantInterface
38
     */
39
    private $participant;
40
41
    /**
42
     * @var \PHPUnit_Framework_MockObject_MockObject
43
     */
44
    private $isParticipantThreadSpecification;
45
46
    public function setUp()
47
    {
48
        $this->thread = $this->getMock('Miliooo\Messaging\Model\ThreadInterface');
49
        $this->participant = new ParticipantTestHelper(1);
50
51
        $this->specification = $this->getMockBuilder('Miliooo\Messaging\Specifications\CanSeeThreadSpecification')
52
            ->setMethods(['getIsParticipantThreadSpecification'])
53
            ->getMock();
54
        $this->isParticipantThreadSpecification = $this->getMock('Miliooo\Messaging\Specifications\IsParticipantThreadSpecification');
55
        $this->specification->expects($this->once())->method('getIsParticipantThreadSpecification')
56
            ->will($this->returnValue($this->isParticipantThreadSpecification));
57
    }
58
59
    public function testIsSatisfiedByReturnsTrueWhenParticipant()
60
    {
61
        $this->isParticipantThreadSpecification->expects($this->once())->method('isSatisfiedBy')
62
            ->with($this->participant, $this->thread)
63
            ->will($this->returnValue(true));
64
65
        $this->assertTrue($this->specification->isSatisfiedBy($this->participant, $this->thread));
66
    }
67
68
    public function testIsSatisfiedByReturnsFalseWhenNotParticipant()
69
    {
70
        $this->isParticipantThreadSpecification->expects($this->once())->method('isSatisfiedBy')
71
            ->with($this->participant, $this->thread)
72
            ->will($this->returnValue(false));
73
74
        $this->assertFalse($this->specification->isSatisfiedBy($this->participant, $this->thread));
75
    }
76
}
77