Passed
Push — master ( 4f415b...b6b0b7 )
by Gabriel
03:01
created

HasResponseTraitTest   A

Complexity

Total Complexity 1

Size/Duplication

Total Lines 14
Duplicated Lines 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
wmc 1
eloc 8
dl 0
loc 14
rs 10
c 1
b 0
f 0

1 Method

Rating   Name   Duplication   Size   Complexity  
A test_newResponse() 0 12 1
1
<?php
2
3
namespace Nip\Controllers\Tests\Traits;
4
5
use Nip\Controllers\Tests\AbstractTest;
6
use Nip\Controllers\Tests\Fixtures\Controllers\ViewController;
7
use Nip\Http\Response\Response;
8
9
/**
10
 * Class HasResponseTraitTest
11
 * @package Nip\Controllers\Tests\Traits
12
 */
13
class HasResponseTraitTest extends AbstractTest
14
{
15
    public function test_newResponse()
16
    {
17
        $controller = new ViewController();
18
        $controller->setName('base');
19
        $controller->payload()->withDefaultFormat('view');
0 ignored issues
show
Bug introduced by
Are you sure the usage of $controller->payload() targeting Nip\Controllers\Controller::payload() seems to always return null.

This check looks for function or method calls that always return null and whose return value is used.

class A
{
    function getObject()
    {
        return null;
    }

}

$a = new A();
if ($a->getObject()) {

The method getObject() can return nothing but null, so it makes no sense to use the return value.

The reason is most likely that a function or method is imcomplete or has been reduced for debug purposes.

Loading history...
20
21
        /** @var Response $response */
22
        $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\Controller::callAction(). ( Ignorable by Annotation )

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

22
        $response = $controller->callAction(/** @scrutinizer ignore-type */ 'index');
Loading history...
23
        self::assertInstanceOf(Response::class, $response);
24
25
        $content = $response->getContent();
26
        self::assertStringContainsString('BASE-INDEX-CONTENT', $content);
27
    }
28
}
29