-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathSwaggerUiControllerFactoryTest.php
More file actions
76 lines (63 loc) · 2.6 KB
/
SwaggerUiControllerFactoryTest.php
File metadata and controls
76 lines (63 loc) · 2.6 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
<?php
/**
* @see https://github.com/laminas-api-tools/api-tools-documentation-swagger for the canonical source repository
* @copyright https://github.com/laminas-api-tools/api-tools-documentation-swagger/blob/master/COPYRIGHT.md
* @license https://github.com/laminas-api-tools/api-tools-documentation-swagger/blob/master/LICENSE.md New BSD License
*/
namespace LaminasTest\ApiTools\Documentation\Swagger;
use Laminas\ApiTools\Configuration\ModuleUtils;
use Laminas\ApiTools\Documentation\ApiFactory;
use Laminas\ApiTools\Documentation\Swagger\SwaggerUiController;
use Laminas\ApiTools\Documentation\Swagger\SwaggerUiControllerFactory;
use Laminas\ApiTools\Provider\ApiToolsProviderInterface;
use Laminas\ModuleManager\ModuleManager;
use Laminas\ServiceManager\Exception\ServiceNotCreatedException;
use Laminas\ServiceManager\ServiceManager;
use PHPUnit\Framework\TestCase;
class SwaggerUiControllerFactoryTest extends TestCase
{
/**
* @var SwaggerUiControllerFactory
*/
protected $factory;
/**
* @var ServiceManager
*/
protected $services;
protected function setUp()
{
$this->factory = new SwaggerUiControllerFactory();
$this->services = $services = new ServiceManager();
}
/**
* @expectedException \Laminas\ServiceManager\Exception\ServiceNotCreatedException
*/
public function testExceptionThrownOnMissingApiCreatorClass()
{
$smFactory = $this->factory;
$this->expectException(ServiceNotCreatedException::class);
$factory = $smFactory($this->services, SwaggerUiController::class);
}
public function testCreatesServiceWithDefaults()
{
$mockModule = $this->prophesize(ApiToolsProviderInterface::class)->reveal();
$moduleManager = $this->prophesize(ModuleManager::class);
$moduleManager->getModules()->willReturn(['Test']);
$moduleManager->getModule('Test')->willReturn($mockModule);
$moduleUtils = $this->prophesize(ModuleUtils::class);
$moduleUtils
->getModuleConfigPath('Test')
->willReturn([]);
$apiFactory = new ApiFactory(
$moduleManager->reveal(),
[],
$moduleUtils->reveal()
);
$this->services->setService(ApiFactory::class, $apiFactory);
/** @var SwaggerUiControllerFactory $service */
$smFactory = $this->factory;
$this->assertInstanceOf(SwaggerUiControllerFactory::class, $smFactory);
$controller = $smFactory($this->services, SwaggerUiController::class);
$this->assertInstanceOf(SwaggerUiController::class, $controller);
}
}