Completed
Push — master ( 645d45...16f10a )
by David
02:00
created

PostCreatedEventTest   A

Complexity

Total Complexity 3

Size/Duplication

Total Lines 27
Duplicated Lines 100 %

Coupling/Cohesion

Components 1
Dependencies 3

Importance

Changes 1
Bugs 0 Features 0
Metric Value
wmc 3
c 1
b 0
f 0
lcom 1
cbo 3
dl 27
loc 27
rs 10

3 Methods

Rating   Name   Duplication   Size   Complexity  
A setUp() 7 7 1
A testEventCanBeInstantiated() 6 6 1
A testEventPublishesOnTheCorrectChannel() 7 7 1

How to fix   Duplicated Code   

Duplicated Code

Duplicate code is one of the most pungent code smells. A rule that is often used is to re-structure code once it is duplicated in three or more places.

Common duplication problems, and corresponding solutions are:

1
<?php
2
3
namespace Test\Unit\Events;
4
5
use Test\Unit\TestCase;
6
use Taskforcedev\LaravelForum\Models\ForumPost;
7
use Taskforcedev\LaravelForum\Events\PostCreated;
8
9 View Code Duplication
class PostCreatedEventTest extends TestCase
0 ignored issues
show
Duplication introduced by
This class 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...
10
{
11
    protected $event;
12
13
    public function setUp()
14
    {
15
        $post = new ForumPost();
16
        $post->id = 1;
17
        $user = 'Test';
18
        $this->event = new PostCreated($post, $user);
19
    }
20
21
    public function testEventCanBeInstantiated()
22
    {
23
        $class = get_class($this->event);
24
        $this->assertEquals('Taskforcedev\LaravelForum\Events\PostCreated', $class,
25
            'Event should be of the correct class.');
26
    }
27
28
    public function testEventPublishesOnTheCorrectChannel()
29
    {
30
        $event = $this->event;
31
        $broadcast = $event->broadcastOn();
32
        $channels = array_values($broadcast);
33
        $this->assertEquals('laravel-forum', $channels[0]);
34
    }
35
}