Skip to content

Commit 924abba

Browse files
committed
Test contstructor
1 parent 8b27af9 commit 924abba

File tree

2 files changed

+51
-1
lines changed

2 files changed

+51
-1
lines changed

src/Cors.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@ class Cors implements HttpKernelInterface
3737
'supportsCredentials' => false,
3838
];
3939

40-
public function __construct(HttpKernelInterface $app, array $options = null)
40+
public function __construct(HttpKernelInterface $app, array $options = [])
4141
{
4242
$this->app = $app;
4343
$this->cors = new CorsService(array_merge($this->defaultOptions, $options));

tests/CorsServiceTest.php

Lines changed: 50 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,50 @@
1+
<?php
2+
3+
/*
4+
* This file is part of asm89/stack-cors.
5+
*
6+
* (c) Alexander <iam.asm89@gmail.com>
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 Asm89\Stack\Tests;
13+
14+
use Asm89\Stack\CorsService;
15+
use PHPUnit\Framework\TestCase;
16+
17+
class CorsServiceTest extends TestCase
18+
{
19+
/**
20+
* @test
21+
*/
22+
public function it_can_have_options()
23+
{
24+
$service = new CorsService([
25+
'allowedOrigins' => ['*']
26+
]);
27+
28+
$this->assertInstanceOf(CorsService::class, $service);
29+
}
30+
31+
/**
32+
* @test
33+
*/
34+
public function it_can_have_no_options()
35+
{
36+
$service = new CorsService();
37+
$this->assertInstanceOf(CorsService::class, $service);
38+
39+
}
40+
41+
/**
42+
* @test
43+
*/
44+
public function it_can_have_empty_options()
45+
{
46+
$service = new CorsService([]);
47+
$this->assertInstanceOf(CorsService::class, $service);
48+
49+
}
50+
}

0 commit comments

Comments
 (0)