SMSFactorManagerTest::testCreateConnection()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 17
Code Lines 9

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
dl 0
loc 17
rs 9.4285
c 0
b 0
f 0
cc 1
eloc 9
nc 1
nop 0
1
<?php
2
3
/*
4
 * This file is part of Laravel SMSFactor.
5
 *
6
 * (c) Filippo Galante <[email protected]>
7
 *
8
 * For the full copyright and license information, please view the LICENSE
9
 * file that was distributed with this source code.
10
 */
11
12
namespace IlGala\Tests\SMSFactor;
13
14
use IlGala\SMSFactor\SMSFactor;
15
use IlGala\SMSFactor\SMSFactorFactory;
16
use IlGala\SMSFactor\SMSFactorManager;
17
use GrahamCampbell\TestBench\AbstractTestCase as AbstractTestBenchTestCase;
18
use Illuminate\Contracts\Config\Repository;
19
use Mockery;
20
21
/**
22
 * This is the smsfactor manager test class.
23
 *
24
 * @author Filippo Galante <[email protected]>
25
 */
26
class SMSFactorManagerTest extends AbstractTestBenchTestCase
27
{
28
    public function testCreateConnection()
29
    {
30
        $config = ['username' => 'your-username', 'password' => 'your-password', 'accept' => 'application/json'];
31
32
        $manager = $this->getManager($config);
33
34
        $manager->getConfig()->shouldReceive('get')->once()
0 ignored issues
show
Bug introduced by
The method shouldReceive() does not seem to exist on object<Illuminate\Contracts\Config\Repository>.

This check looks for calls to methods that do not seem to exist on a given type. It looks for the method on the type itself as well as in inherited classes or implemented interfaces.

This is most likely a typographical error or the method has been renamed.

Loading history...
35
                ->with('smsfactor.default')->andReturn('main');
36
37
        $this->assertSame([], $manager->getConnections());
38
39
        $return = $manager->connection();
40
41
        $this->assertInstanceOf(SMSFactor::class, $return);
42
43
        $this->assertArrayHasKey('main', $manager->getConnections());
44
    }
45
46
    protected function getManager(array $config)
47
    {
48
        $repo = Mockery::mock(Repository::class);
49
50
        $factory = Mockery::mock(SMSFactorFactory::class);
51
52
        $manager = new SMSFactorManager($repo, $factory);
53
54
        $manager->getConfig()->shouldReceive('get')->once()
0 ignored issues
show
Bug introduced by
The method shouldReceive() does not seem to exist on object<Illuminate\Contracts\Config\Repository>.

This check looks for calls to methods that do not seem to exist on a given type. It looks for the method on the type itself as well as in inherited classes or implemented interfaces.

This is most likely a typographical error or the method has been renamed.

Loading history...
55
                ->with('smsfactor.connections')->andReturn(['main' => $config]);
56
57
        $config['name'] = 'main';
58
59
        $manager->getFactory()->shouldReceive('make')->once()
0 ignored issues
show
Bug introduced by
The method shouldReceive() does not seem to exist on object<IlGala\SMSFactor\SMSFactorFactory>.

This check looks for calls to methods that do not seem to exist on a given type. It looks for the method on the type itself as well as in inherited classes or implemented interfaces.

This is most likely a typographical error or the method has been renamed.

Loading history...
60
                ->with($config)->andReturn(Mockery::mock(SMSFactor::class));
61
62
        return $manager;
63
    }
64
}
65