Passed
Push — master ( 20ba69...1ea7e6 )
by Victor
47s queued 11s
created

ErrorSuppressionTest   A

Complexity

Total Complexity 4

Size/Duplication

Total Lines 45
Duplicated Lines 0 %

Importance

Changes 0
Metric Value
wmc 4
eloc 15
dl 0
loc 45
rs 10
c 0
b 0
f 0

4 Methods

Rating   Name   Duplication   Size   Complexity  
A setUp() 0 3 1
A testOptionalBlocksShouldDiscardTheirContentsOnRuntimeExceptions() 0 7 1
A testIncludedTemplateShouldThrowAnException() 0 5 1
A testOptionalBlocksShouldNotSuppressLogicExceptions() 0 10 1
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