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() |
|
|
|
|
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() |
|
|
|
|
55
|
|
|
->with('smsfactor.connections')->andReturn(['main' => $config]); |
56
|
|
|
|
57
|
|
|
$config['name'] = 'main'; |
58
|
|
|
|
59
|
|
|
$manager->getFactory()->shouldReceive('make')->once() |
|
|
|
|
60
|
|
|
->with($config)->andReturn(Mockery::mock(SMSFactor::class)); |
61
|
|
|
|
62
|
|
|
return $manager; |
63
|
|
|
} |
64
|
|
|
} |
65
|
|
|
|
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.