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
Bug
introduced
by
Loading history...
|
|||
41 | $view->render(); |
||
42 | } |
||
43 | } |
||
44 |