From 73ca3e2fd8dd2f1af1caecd5d65441e0222b9a8c Mon Sep 17 00:00:00 2001 From: chris cnizzardini Date: Sun, 4 Oct 2020 11:50:32 -0400 Subject: [PATCH] tests swagger and redoc index --- tests/TestCase/ControllerTest.php | 36 ++++++++++++++++++++++++++++++ tests/test_app/src/Application.php | 17 +++++++++++++- 2 files changed, 52 insertions(+), 1 deletion(-) create mode 100644 tests/TestCase/ControllerTest.php diff --git a/tests/TestCase/ControllerTest.php b/tests/TestCase/ControllerTest.php new file mode 100644 index 00000000..507e3f1d --- /dev/null +++ b/tests/TestCase/ControllerTest.php @@ -0,0 +1,36 @@ +get('/'); + $this->assertResponseOk(); + } + + public function testRedocIndex() + { + $this->get('/?doctype=redoc'); + $this->assertResponseOk(); + } +} \ No newline at end of file diff --git a/tests/test_app/src/Application.php b/tests/test_app/src/Application.php index 0e9260ed..b207db93 100644 --- a/tests/test_app/src/Application.php +++ b/tests/test_app/src/Application.php @@ -6,14 +6,16 @@ use Bake\Command\EntryCommand; use Cake\Console\CommandCollection; use Cake\Http\BaseApplication; +use Cake\Http\Middleware\BodyParserMiddleware; use Cake\Http\MiddlewareQueue; +use Cake\Routing\Middleware\RoutingMiddleware; use Cake\Routing\RouteBuilder; class Application extends BaseApplication { public function middleware(MiddlewareQueue $middleware): MiddlewareQueue { - return $middleware; + return $middleware->add(new RoutingMiddleware($this))->add(new BodyParserMiddleware()); } public function bootstrap(): void @@ -27,4 +29,17 @@ public function console(CommandCollection $commands): CommandCollection $commands->add('bake', EntryCommand::class); return $commands; } + + public function routes(RouteBuilder $routes): void + { + $routes->scope('/', function (RouteBuilder $builder) { + $builder->fallbacks(); + $builder->setExtensions(['json','xml']); + $builder->resources('Departments'); + $builder->connect('/', [ + 'plugin' => 'SwaggerBake', 'controller' => 'Swagger', 'action' => 'index' + ]); + }); + parent::routes($routes); + } }