Passed
Push — master ( b0c833...45ab73 )
by Victor
54s
created

tests/Unit/ViewTest.php (1 issue)

Labels
Severity
1
<?php
2
declare(strict_types=1);
3
4
namespace Shoot\Shoot\Tests\Unit;
5
6
use InvalidArgumentException;
7
use PHPUnit\Framework\MockObject\MockObject;
8
use PHPUnit\Framework\TestCase;
9
use Shoot\Shoot\PresentationModel;
10
use Shoot\Shoot\Tests\Fixtures\ViewFactory;
11
use Shoot\Shoot\View;
12
use stdClass;
13
14
final class ViewTest extends TestCase
15
{
16
    public function testShouldNotAllowEmptyNames(): void
17
    {
18
        $presentationModel = new PresentationModel();
19
        $callback = function () {
20
            // noop
21
        };
22
23
        $this->expectException(InvalidArgumentException::class);
24
25
        new View('', $presentationModel, $callback);
26
    }
27
28
    public function testShouldExecuteCallback(): void
29
    {
30
        /** @var callable|MockObject $callback */
31
        $callback = $this
32
            ->getMockBuilder(stdClass::class)
33
            ->setMethods(['__invoke'])
34
            ->getMock();
35
36
        $callback
37
            ->expects($this->once())
38
            ->method('__invoke');
39
40
        $view = ViewFactory::createWithCallback($callback);
0 ignored issues
show
$callback of type PHPUnit\Framework\MockObject\MockObject is incompatible with the type callable expected by parameter $callback of Shoot\Shoot\Tests\Fixtur...y::createWithCallback(). ( Ignorable by Annotation )

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

40
        $view = ViewFactory::createWithCallback(/** @scrutinizer ignore-type */ $callback);
Loading history...
41
        $view->render();
42
    }
43
}
44