Passed
Pull Request — master (#2)
by Victor
02:09
created

ViewTest   A

Complexity

Total Complexity 2

Size/Duplication

Total Lines 33
Duplicated Lines 0 %

Importance

Changes 0
Metric Value
eloc 14
dl 0
loc 33
rs 10
c 0
b 0
f 0
wmc 2

2 Methods

Rating   Name   Duplication   Size   Complexity  
A testShouldNotAllowEmptyNames() 0 10 1
A testShouldExecuteCallback() 0 13 1
1
<?php
2
declare(strict_types=1);
3
4
namespace Shoot\Shoot\Tests;
5
6
use InvalidArgumentException;
7
use PHPUnit\Framework\TestCase;
8
use Shoot\Shoot\PresentationModel;
9
use Shoot\Shoot\Tests\Fixtures\ViewFactory;
10
use Shoot\Shoot\View;
11
use stdClass;
12
13
final class ViewTest extends TestCase
14
{
15
    /**
16
     * @return void
17
     */
18
    public function testShouldNotAllowEmptyNames()
19
    {
20
        $presentationModel = new PresentationModel();
21
        $callback = function () {
22
            // noop
23
        };
24
25
        $this->expectException(InvalidArgumentException::class);
26
27
        new View('', $presentationModel, $callback);
28
    }
29
30
    /**
31
     * @return void
32
     */
33
    public function testShouldExecuteCallback()
34
    {
35
        $callback = $this
36
            ->getMockBuilder(stdClass::class)
37
            ->setMethods(['__invoke'])
38
            ->getMock();
39
40
        $callback
41
            ->expects($this->once())
42
            ->method('__invoke');
43
44
        $view = ViewFactory::createWithCallback($callback);
0 ignored issues
show
Bug introduced by
$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

44
        $view = ViewFactory::createWithCallback(/** @scrutinizer ignore-type */ $callback);
Loading history...
45
        $view->render();
46
    }
47
}
48