Passed
Pull Request — master (#11)
by Victor
02:42
created

ViewTest   A

Complexity

Total Complexity 2

Size/Duplication

Total Lines 34
Duplicated Lines 0 %

Importance

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

2 Methods

Rating   Name   Duplication   Size   Complexity  
A testShouldExecuteCallback() 0 14 1
A testShouldNotAllowEmptyNames() 0 10 1
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
    /**
17
     * @return void
18
     */
19
    public function testShouldNotAllowEmptyNames()
20
    {
21
        $presentationModel = new PresentationModel();
22
        $callback = function () {
23
            // noop
24
        };
25
26
        $this->expectException(InvalidArgumentException::class);
27
28
        new View('', $presentationModel, $callback);
29
    }
30
31
    /**
32
     * @return void
33
     */
34
    public function testShouldExecuteCallback()
35
    {
36
        /** @var callable|MockObject $callback */
37
        $callback = $this
38
            ->getMockBuilder(stdClass::class)
39
            ->setMethods(['__invoke'])
40
            ->getMock();
41
42
        $callback
43
            ->expects($this->once())
44
            ->method('__invoke');
45
46
        $view = ViewFactory::createWithCallback($callback);
47
        $view->render();
48
    }
49
}
50