Passed
Pull Request — master (#17)
by Alexander
04:23
created

OptionsRequestBehaviorTest::testNotExit()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 7
Code Lines 5

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
c 0
b 0
f 0
dl 0
loc 7
rs 9.4285
cc 1
eloc 5
nc 1
nop 0
1
<?php
2
3
namespace Horat1us\Yii\Tests\Behaviors;
4
5
use Horat1us\Yii\Behaviors\OptionsRequestBehavior;
6
use Horat1us\Yii\Tests\AbstractTestCase;
7
use Horat1us\Yii\Tests\Mocks\ResponseMock;
8
use yii\base\ExitException;
9
10
/**
11
 * Class OptionsRequestBehaviorTest
12
 * @package Horat1us\Yii\Tests\Behaviors
13
 */
14
class OptionsRequestBehaviorTest extends AbstractTestCase
15
{
16
    /**
17
     * @expectedException \yii\base\ExitException
18
     */
19
    public function testExit(): void
20
    {
21
        $_SERVER['REQUEST_METHOD'] = 'OPTIONS';
22
        $response = new ResponseMock();
23
24
        $behavior = new OptionsRequestBehavior([
25
            'response' => $response
26
        ]);
27
        try {
28
            $behavior->check();
29
        } catch (ExitException $exception) {
30
            $this->assertTrue($response->triggered);
31
            throw $exception;
32
        }
33
    }
34
35
    public function testNotExit(): void
36
    {
37
        $_SERVER['REQUEST_METHOD'] = 'GET';
38
        $behavior = new OptionsRequestBehavior();
39
        $behavior->check();
40
        $this->assertTrue(true);
41
    }
42
}
43