|
1
|
|
|
<?php |
|
2
|
|
|
declare(strict_types=1); |
|
3
|
|
|
|
|
4
|
|
|
namespace InvoiceNinjaModuleTest\Options; |
|
5
|
|
|
|
|
6
|
|
|
use Interop\Container\ContainerInterface; |
|
7
|
|
|
use InvoiceNinjaModule\Module; |
|
8
|
|
|
use InvoiceNinjaModule\Options\AuthOptions; |
|
9
|
|
|
use InvoiceNinjaModule\Options\AuthOptionsFactory; |
|
10
|
|
|
use InvoiceNinjaModule\Options\Interfaces\AuthOptionsInterface; |
|
11
|
|
|
use InvoiceNinjaModule\Options\ModuleOptions; |
|
12
|
|
|
use InvoiceNinjaModule\Options\ModuleOptionsFactory; |
|
13
|
|
|
|
|
14
|
|
|
class ModuleOptionsFactoryTest extends \PHPUnit_Framework_TestCase |
|
15
|
|
|
{ |
|
16
|
|
|
public function testCreate() :void |
|
17
|
|
|
{ |
|
18
|
|
|
$config = [ |
|
19
|
|
|
Module::INVOICE_NINJA_CONFIG => [ |
|
20
|
|
|
Module::API_TIMEOUT => 100, |
|
21
|
|
|
Module::TOKEN_TYPE => 'X-Ninja-Token', |
|
22
|
|
|
Module::TOKEN => 'YOURTOKEN', |
|
23
|
|
|
Module::HOST_URL => 'http://ninja.dev/api/v1', |
|
24
|
|
|
] |
|
25
|
|
|
]; |
|
26
|
|
|
|
|
27
|
|
|
$authMock = $this->createMock(AuthOptionsInterface::class); |
|
28
|
|
|
$containerMock = $this->createMock(ContainerInterface::class); |
|
29
|
|
|
|
|
30
|
|
|
$containerMock->expects(self::at(0)) |
|
31
|
|
|
->method('get') |
|
32
|
|
|
->with(self::stringContains('Config')) |
|
33
|
|
|
->willReturn($config); |
|
34
|
|
|
|
|
35
|
|
|
$containerMock->expects(self::at(1)) |
|
36
|
|
|
->method('get') |
|
37
|
|
|
->with(self::stringContains(AuthOptions::class)) |
|
38
|
|
|
->willReturn($authMock); |
|
39
|
|
|
|
|
40
|
|
|
$factory = new ModuleOptionsFactory(); |
|
41
|
|
|
self::assertInstanceOf(ModuleOptionsFactory::class, $factory); |
|
42
|
|
|
|
|
43
|
|
|
$options = $factory($containerMock, 'test'); |
|
44
|
|
|
self::assertInstanceOf(ModuleOptions::class, $options); |
|
45
|
|
|
} |
|
46
|
|
|
} |
|
47
|
|
|
|