Passed
Pull Request — master (#2)
by Victor
03:19
created

ViewTest::testWithPresentationModelShouldReturnNewInstance()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 8
Code Lines 4

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
dl 0
loc 8
rs 9.4285
c 0
b 0
f 0
cc 1
eloc 4
nc 1
nop 0
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\ViewCallback;
10
use Shoot\Shoot\Tests\Fixtures\ViewFactory;
11
use Shoot\Shoot\View;
12
13
final class ViewTest extends TestCase
14
{
15
    /**
16
     * @return void
17
     */
18
    public function testConstructorShouldNotAllowEmptyNames()
19
    {
20
        $this->expectException(InvalidArgumentException::class);
21
22
        $name = '';
23
        $presentationModel = new PresentationModel();
24
        $callback = new ViewCallback();
25
26
        new View($name, $presentationModel, $callback);
27
    }
28
29
    /**
30
     * @return void
31
     */
32
    public function testRenderShouldExecuteCallback()
33
    {
34
        $wasCalled = false;
35
36
        $callback = function () use (&$wasCalled) {
37
            $wasCalled = true;
38
        };
39
40
        $view = ViewFactory::create(null, $callback);
41
42
        $view->render();
43
44
        $this->assertTrue($wasCalled);
45
    }
46
}
47