ControllerActionCallTest   A
last analyzed

Complexity

Total Complexity 2

Size/Duplication

Total Lines 19
Duplicated Lines 0 %

Importance

Changes 0
Metric Value
wmc 2
eloc 9
c 0
b 0
f 0
dl 0
loc 19
rs 10

2 Methods

Rating   Name   Duplication   Size   Complexity  
A testCallActionEmptyMethod() 0 6 1
A testBeforeAndAfterCalls() 0 9 1
1
<?php
2
3
namespace Nip\Controllers\Tests\Traits;
4
5
use Nip\Controllers\Tests\AbstractTest;
6
use Nip\Controllers\Tests\Fixtures\Controllers\BaseControllerWithUtilityMethods;
7
use Nip\Http\Response\Response;
8
9
/**
10
 * Class ControllerActionCallTest
11
 * @package Nip\Controllers\Tests\Traits
12
 */
13
class ControllerActionCallTest extends AbstractTest
14
{
15
    public function testCallActionEmptyMethod()
16
    {
17
        $controller = new BaseControllerWithUtilityMethods();
18
19
        self::expectException(\Exception::class);
0 ignored issues
show
Bug Best Practice introduced by
The method PHPUnit\Framework\TestCase::expectException() is not static, but was called statically. ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-call  annotation

19
        self::/** @scrutinizer ignore-call */ 
20
              expectException(\Exception::class);
Loading history...
20
        $controller->callAction();
21
    }
22
23
    public function testBeforeAndAfterCalls()
24
    {
25
        $controller = new BaseControllerWithUtilityMethods();
26
        $response = $controller->callAction('index');
0 ignored issues
show
Bug introduced by
'index' of type string is incompatible with the type boolean expected by parameter $method of Nip\Controllers\Tests\Fi...tyMethods::callAction(). ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-type  annotation

26
        $response = $controller->callAction(/** @scrutinizer ignore-type */ 'index');
Loading history...
27
28
        self::assertInstanceOf(Response::class, $response);
29
//        var_dump($response);die();
30
        self::assertTrue($response->hasHeader('beforeAction'));
31
        self::assertTrue($response->hasHeader('afterAction'));
32
    }
33
}
34