|
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\IsParticipantThreadSpecification; |
|
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 IsParticipantThreadSpecificationTest extends \PHPUnit_Framework_TestCase |
|
23
|
|
|
{ |
|
24
|
|
|
/** |
|
25
|
|
|
* Class under test. |
|
26
|
|
|
* |
|
27
|
|
|
* @var IsParticipantThreadSpecification |
|
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
|
|
|
public function setUp() |
|
42
|
|
|
{ |
|
43
|
|
|
$this->thread = $this->getMock('Miliooo\Messaging\Model\ThreadInterface'); |
|
44
|
|
|
$this->participant = new ParticipantTestHelper(1); |
|
45
|
|
|
$this->specification = new IsParticipantThreadSpecification(); |
|
46
|
|
|
} |
|
47
|
|
|
|
|
48
|
|
|
public function testIsSatisfiedByReturnsTrueWhenParticipant() |
|
49
|
|
|
{ |
|
50
|
|
|
$this->thread->expects($this->once())->method('isParticipant') |
|
51
|
|
|
->with($this->participant)->will($this->returnValue(true)); |
|
52
|
|
|
$this->assertTrue($this->specification->isSatisfiedBy($this->participant, $this->thread)); |
|
53
|
|
|
} |
|
54
|
|
|
|
|
55
|
|
|
public function testIsSatisfiedByReturnsFalseWhenNotParticipant() |
|
56
|
|
|
{ |
|
57
|
|
|
$this->thread->expects($this->once())->method('isParticipant') |
|
58
|
|
|
->with($this->participant)->will($this->returnValue(false)); |
|
59
|
|
|
$this->assertFalse($this->specification->isSatisfiedBy($this->participant, $this->thread)); |
|
60
|
|
|
} |
|
61
|
|
|
} |
|
62
|
|
|
|