Completed
Pull Request — master (#40)
by Harry
10:25
created

MessageTest::testIsValidIsTrue()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 8
Code Lines 4

Duplication

Lines 8
Ratio 100 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
dl 8
loc 8
rs 9.4285
c 1
b 0
f 0
cc 1
eloc 4
nc 1
nop 0
1
<?php
2
3
/**
4
 * This file is part of graze/queue.
5
 *
6
 * Copyright (c) 2015 Nature Delivered Ltd. <https://www.graze.com>
7
 *
8
 * For the full copyright and license information, please view the LICENSE
9
 * file that was distributed with this source code.
10
 *
11
 * @license https://github.com/graze/queue/blob/master/LICENSE MIT
12
 *
13
 * @link    https://github.com/graze/queue
14
 */
15
16
namespace Graze\Queue\Message;
17
18
use Graze\DataStructure\Container\ContainerInterface;
19
use Mockery as m;
20
use Mockery\MockInterface;
21
use PHPUnit_Framework_TestCase as TestCase;
22
23
class MessageTest extends TestCase
24
{
25
    /** @var ContainerInterface|MockInterface */
26
    private $metadata;
27
28
    public function setUp()
29
    {
30
        $this->metadata = m::mock(ContainerInterface::class);
31
    }
32
33
    public function testInterface()
34
    {
35
        $this->assertInstanceOf(
36
            MessageInterface::class,
37
            new Message('foo', $this->metadata, function () {
38
            })
39
        );
40
    }
41
42 View Code Duplication
    public function testGetBody()
0 ignored issues
show
Duplication introduced by
This method seems to be duplicated in your project.

Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.

You can also find more detailed suggestions in the “Code” section of your repository.

Loading history...
43
    {
44
        $message = new Message('foo', $this->metadata, function () {
45
        });
46
47
        assertThat($message->getBody(), is(identicalTo('foo')));
48
    }
49
50 View Code Duplication
    public function testGetMetadata()
0 ignored issues
show
Duplication introduced by
This method seems to be duplicated in your project.

Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.

You can also find more detailed suggestions in the “Code” section of your repository.

Loading history...
51
    {
52
        $message = new Message('foo', $this->metadata, function () {
53
        });
54
55
        assertThat($message->getMetadata(), is(identicalTo($this->metadata)));
56
    }
57
58 View Code Duplication
    public function testIsValidIsFalse()
0 ignored issues
show
Duplication introduced by
This method seems to be duplicated in your project.

Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.

You can also find more detailed suggestions in the “Code” section of your repository.

Loading history...
59
    {
60
        $message = new Message('foo', $this->metadata, function () {
61
            return false;
62
        });
63
64
        assertThat($message->isValid(), is(identicalTo(false)));
65
    }
66
67 View Code Duplication
    public function testIsValidIsTrue()
0 ignored issues
show
Duplication introduced by
This method seems to be duplicated in your project.

Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.

You can also find more detailed suggestions in the “Code” section of your repository.

Loading history...
68
    {
69
        $message = new Message('foo', $this->metadata, function () {
70
            return true;
71
        });
72
73
        assertThat($message->isValid(), is(identicalTo(true)));
74
    }
75
76
    public function testIsValidIsCalledWithMessage()
77
    {
78
        $seen = null;
79
        $message = new Message('foo', $this->metadata, function ($msg) use (&$seen) {
80
            $seen = $msg;
81
        });
82
83
        $message->isValid();
84
85
        assertThat($seen, is(identicalTo($message)));
86
    }
87
}
88