ThreadModelTestHelper::getSender()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 4
Code Lines 2

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 1 Features 0
Metric Value
dl 0
loc 4
rs 10
c 1
b 1
f 0
cc 1
eloc 2
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\TestHelpers;
12
13
use Miliooo\Messaging\Builder\Message\NewThreadBuilder;
14
use Miliooo\Messaging\Form\FormModel\NewThreadSingleRecipient;
15
use Miliooo\Messaging\Builder\Model\ThreadBuilderModel;
16
use Miliooo\Messaging\Model\ThreadInterface;
17
use Miliooo\Messaging\User\ParticipantInterface;
18
19
/**
20
 * Description of ThreadModelTestHelper
21
 *
22
 * @author Michiel Boeckaert <[email protected]>
23
 */
24
class ThreadModelTestHelper
25
{
26
    protected $sender;
27
    protected $recipient;
28
29
    const MESSAGE_BODY = "the body of the message";
30
    const SENDER_ID = "sender";
31
    const RECIPIENT_ID = "recipient";
32
    const DATE_TIME_VALUE = "2011-10-13 00:00:00";
33
    const THREAD_SUBJECT = "The subject of the message";
34
35
    /**
36
     * Builds a thread.
37
     *
38
     * @return ThreadInterface
39
     */
40
    public function getModelThread()
41
    {
42
        $this->sender = new ParticipantTestHelper(self::SENDER_ID);
43
        $this->recipient = new ParticipantTestHelper(self::RECIPIENT_ID);
44
45
        $builder = new NewThreadBuilder();
46
        $builder->setMessageClass('\Miliooo\Messaging\TestHelpers\Model\Message');
47
        $builder->setThreadClass('\Miliooo\Messaging\TestHelpers\Model\Thread');
48
        $builder->setMessageMetaClass('\Miliooo\Messaging\TestHelpers\Model\MessageMeta');
49
        $builder->setThreadMetaClass('\Miliooo\Messaging\TestHelpers\Model\ThreadMeta');
50
51
        $newThreadModel = new NewThreadSingleRecipient();
52
        $newThreadModel->setSender($this->sender);
53
        $newThreadModel->setRecipient($this->recipient);
54
        $newThreadModel->setSubject(self::THREAD_SUBJECT);
55
        $newThreadModel->setBody(self::MESSAGE_BODY);
56
        $newThreadModel->setCreatedAt(new \DateTime(self::DATE_TIME_VALUE));
57
58
        $builderModel = new ThreadBuilderModel($newThreadModel);
59
60
        return $builder->build($builderModel);
61
    }
62
63
    /**
64
     * Returns the sender of the first message in the model thread.
65
     *
66
     * @return ParticipantInterface the sender of the first message in the model thread
67
     */
68
    public function getSender()
69
    {
70
        return $this->sender;
71
    }
72
73
    /**
74
     * Returns the recipient of the first message in the model thread.
75
     *
76
     * @return ParticipantInterface the recipient of the first message in the model thread
77
     */
78
    public function getRecipient()
79
    {
80
        return $this->recipient;
81
    }
82
}
83