Completed
Push — master ( 2adfbb...9718a0 )
by Kazi Mainuddin
09:48
created

test_it_has_proper_driver_instance()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 6

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
dl 0
loc 6
rs 10
c 0
b 0
f 0
cc 1
nc 1
nop 0
1
<?php
2
3
namespace Tzsk\Sms\Tests;
4
5
use Tzsk\Sms\Abstracts\Driver;
6
use Tzsk\Sms\Drivers\Textlocal;
7
use Tzsk\Sms\Tests\Mocks\MockSmsManager;
8
use Tzsk\Sms\Facade\Sms;
9
use Tzsk\Sms\Tests\Mocks\Drivers\BarDriver;
10
11
class SmsManagerTest 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...
12
{
13
    public function test_it_has_default_driver()
14
    {
15
        $manager = new MockSmsManager();
16
17
        $this->assertArraySubset(config('sms'), $manager->getConfig());
18
        $this->assertEquals(config('sms.default'), $manager->getDriver());
19
        $this->assertArraySubset($manager->getSettings(), config('sms.drivers.'.$manager->getDriver()));
20
    }
21
22
    public function test_it_wont_accespt_wrong_driver()
23
    {
24
        $this->expectException(\Exception::class);
25
        $manager = (new MockSmsManager())->via('foo');
0 ignored issues
show
Unused Code introduced by
$manager is not used, you could remove the assignment.

This check looks for variable assignements that are either overwritten by other assignments or where the variable is not used subsequently.

$myVar = 'Value';
$higher = false;

if (rand(1, 6) > 3) {
    $higher = true;
} else {
    $higher = false;
}

Both the $myVar assignment in line 1 and the $higher assignment in line 2 are dead. The first because $myVar is never used and the second because $higher is always overwritten for every possible time line.

Loading history...
26
    }
27
28
    public function test_driver_can_be_changed()
29
    {
30
        $gateway = 'twilio';
31
        $manager = (new MockSmsManager())->via($gateway);
32
33
        $this->assertEquals($gateway, $manager->getDriver());
34
        $this->assertArraySubset($manager->getSettings(), config('sms.drivers.'.$gateway));
35
    }
36
37
    public function test_it_has_proper_driver_instance()
38
    {
39
        $manager = (new MockSmsManager());
40
41
        $this->assertInstanceOf(Driver::class, $manager->driverInstance());
42
    }
43
44 View Code Duplication
    public function test_can_call_directly()
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...
45
    {
46
        $response = (new MockSmsManager())->via('bar')
47
            ->send('foo', function ($message) {
48
                $message->to(['baz']);
49
            });
50
        $this->assertInstanceOf(BarDriver::class, $response);
51
        $this->assertEquals('foo', $response->getBody());
52
        $this->assertContains('baz', $response->getRecipients());
53
    }
54
55 View Code Duplication
    public function test_can_call_from_facade()
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...
56
    {
57
        $response = Sms::via('bar')->send('foo', function ($m) {
58
            $m->to('baz');
59
        });
60
61
        $this->assertInstanceOf(BarDriver::class, $response);
62
        $this->assertEquals('foo', $response->getBody());
63
        $this->assertContains('baz', $response->getRecipients());
64
    }
65
}
66