Passed
Pull Request — master (#11)
by Victor
01:49
created

ErrorSuppressionTest::setUp()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 3
Code Lines 1

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
eloc 1
dl 0
loc 3
rs 10
c 0
b 0
f 0
cc 1
nc 1
nop 0
1
<?php
2
declare(strict_types=1);
3
4
namespace Shoot\Shoot\Tests\Integration\ErrorSuppression;
5
6
use Shoot\Shoot\Tests\Integration\IntegrationTestCase;
7
8
final class ErrorSuppressionTest extends IntegrationTestCase
9
{
10
    /** @var string */
11
    protected $templateDirectory = __DIR__ . '/Templates';
12
13
    protected function setUp()
14
    {
15
        parent::setUp();
16
    }
17
18
    /**
19
     * @return void
20
     */
21
    public function testIncludedTemplateShouldThrowAnException()
22
    {
23
        $this->expectExceptionMessage('item_exception');
24
25
        $this->renderTemplate('item.twig');
26
    }
27
28
    /**
29
     * @return void
30
     */
31
    public function testOptionalBlocksShouldDiscardTheirContentsOnRuntimeExceptions()
32
    {
33
        $output = $this->renderTemplate('page.twig');
34
35
        $this->assertContains('<h1>page_title</h1>', $output);
36
        $this->assertNotContains('<!-- hidden -->', $output);
37
        $this->assertContains('<p>page_footer</p>', $output);
38
    }
39
40
    /**
41
     * @return void
42
     */
43
    public function testOptionalBlocksShouldNotSuppressLogicExceptions()
44
    {
45
        $this->expectExceptionMessage('Variable "unknown_variable" does not exist');
46
47
        $this->request
48
            ->method('getAttribute')
49
            ->with('throw_logic_exception')
50
            ->willReturn('y');
51
52
        $this->renderTemplate('page.twig');
53
    }
54
}
55