Completed
Pull Request — master (#1)
by Gaël
01:15
created

NewsletterFacadeTest   A

Complexity

Total Complexity 3

Size/Duplication

Total Lines 33
Duplicated Lines 57.58 %

Coupling/Cohesion

Components 1
Dependencies 1

Importance

Changes 0
Metric Value
dl 19
loc 33
c 0
b 0
f 0
wmc 3
lcom 1
cbo 1
rs 10

3 Methods

Rating   Name   Duplication   Size   Complexity  
A should_instantiate_facade_with_null_driver() 0 5 1
A should_instantiate_facade_with_mailchimp_driver() 9 9 1
A should_instantiate_facade_with_mailjet_driver() 10 10 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 DansMaCulotte\Newsletter\Test;
4
5
use DansMaCulotte\Newsletter\Drivers\MailchimpDriver;
6
use DansMaCulotte\Newsletter\Drivers\MailjetDriver;
7
use DansMaCulotte\Newsletter\Drivers\NullDriver;
8
use DansMaCulotte\Newsletter\Newsletter;
9
10
class NewsletterFacadeTest extends TestCase
0 ignored issues
show
Bug introduced by
There is at least one abstract method in this class. Maybe declare it as abstract, or implement the remaining methods: artisan, be, call, seed
Loading history...
11
{
12
    /** @test */
13
    public function should_instantiate_facade_with_null_driver()
14
    {
15
        $newsletter = $this->app[Newsletter::class];
16
        $this->assertInstanceOf(NullDriver::class, $newsletter);
17
    }
18
19
    /** @test */
20 View Code Duplication
    public function should_instantiate_facade_with_mailchimp_driver()
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...
21
    {
22
        config()->set('newsletter.driver', 'mailchimp');
23
        config()->set('newsletter.mailchimp.apiKey', 'mailchimp-keytest');
24
25
        $newsletter = $this->app[Newsletter::class];
26
        $this->assertInstanceOf(Newsletter::class, $newsletter);
27
        $this->assertInstanceOf(MailchimpDriver::class, $newsletter->driver);
28
    }
29
30
    /** @test */
31 View Code Duplication
    public function should_instantiate_facade_with_mailjet_driver()
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...
32
    {
33
        config()->set('newsletter.driver', 'mailjet');
34
        config()->set('newsletter.mailjet.key', 'mailjet-keytest');
35
        config()->set('newsletter.mailjet.secret', 'mailjet-secrettest');
36
37
        $newsletter = $this->app[Newsletter::class];
38
        $this->assertInstanceOf(Newsletter::class, $newsletter);
39
        $this->assertInstanceOf(MailjetDriver::class, $newsletter->driver);
40
    }
41
42
}
43