|
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\Adapters\AdapterInterface; |
|
15
|
|
|
use IlGala\SMSFactor\SMSFactor; |
|
16
|
|
|
use IlGala\SMSFactor\Connectors\ConnectionFactory; |
|
17
|
|
|
use IlGala\SMSFactor\SMSFactorFactory; |
|
18
|
|
|
use IlGala\SMSFactor\SMSFactorManager; |
|
19
|
|
|
use GrahamCampbell\TestBench\AbstractTestCase as AbstractTestBenchTestCase; |
|
20
|
|
|
use Mockery; |
|
21
|
|
|
|
|
22
|
|
|
/** |
|
23
|
|
|
* This is the smsfactor factory test class. |
|
24
|
|
|
* |
|
25
|
|
|
* @author Filippo Galante <[email protected]> |
|
26
|
|
|
*/ |
|
27
|
|
|
class SMSFactorFactoryTest extends AbstractTestBenchTestCase |
|
28
|
|
|
{ |
|
29
|
|
|
public function testMake() |
|
30
|
|
|
{ |
|
31
|
|
|
$config = ['driver' => 'guzzlehttp', 'username' => 'your-username', 'password' => 'your-password', 'accept' => 'application/json']; |
|
32
|
|
|
|
|
33
|
|
|
$manager = Mockery::mock(SMSFactorManager::class); |
|
34
|
|
|
|
|
35
|
|
|
$factory = $this->getMockedFactory($config, $manager); |
|
36
|
|
|
|
|
37
|
|
|
$return = $factory->make($config, $manager); |
|
|
|
|
|
|
38
|
|
|
|
|
39
|
|
|
$this->assertInstanceOf(SMSFactor::class, $return); |
|
40
|
|
|
} |
|
41
|
|
|
|
|
42
|
|
|
public function testAdapter() |
|
43
|
|
|
{ |
|
44
|
|
|
$factory = $this->getSMSFactorFactory(); |
|
45
|
|
|
|
|
46
|
|
|
$config = ['driver' => 'guzzlehttp', 'username' => 'your-username', 'password' => 'your-password', 'accept' => 'application/json']; |
|
47
|
|
|
|
|
48
|
|
|
$factory->getAdapter()->shouldReceive('make')->once() |
|
49
|
|
|
->with($config)->andReturn(Mockery::mock(AdapterInterface::class)); |
|
50
|
|
|
|
|
51
|
|
|
$return = $factory->createAdapter($config); |
|
52
|
|
|
|
|
53
|
|
|
$this->assertInstanceOf(AdapterInterface::class, $return); |
|
54
|
|
|
} |
|
55
|
|
|
|
|
56
|
|
|
protected function getSMSFactorFactory() |
|
57
|
|
|
{ |
|
58
|
|
|
$adapter = Mockery::mock(ConnectionFactory::class); |
|
59
|
|
|
|
|
60
|
|
|
return new SMSFactorFactory($adapter); |
|
61
|
|
|
} |
|
62
|
|
|
|
|
63
|
|
|
protected function getMockedFactory($config, $manager) |
|
|
|
|
|
|
64
|
|
|
{ |
|
65
|
|
|
$adapter = Mockery::mock(ConnectionFactory::class); |
|
66
|
|
|
|
|
67
|
|
|
$mock = Mockery::mock(SMSFactorFactory::class . '[createAdapter]', [$adapter]); |
|
68
|
|
|
|
|
69
|
|
|
$mock->shouldReceive('createAdapter')->once() |
|
70
|
|
|
->with($config)->andReturn(Mockery::mock(AdapterInterface::class)); |
|
71
|
|
|
|
|
72
|
|
|
return $mock; |
|
73
|
|
|
} |
|
74
|
|
|
} |
|
75
|
|
|
|
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.