Passed
Pull Request — master (#11)
by Victor
02:42
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')
0 ignored issues
show
Bug introduced by
The method method() does not exist on PHPUnit\Framework\MockObject\MockObject. ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-call  annotation

48
            ->/** @scrutinizer ignore-call */ 
49
              method('getAttribute')

This check looks for calls to methods that do not seem to exist on a given type. It looks for the method on the type itself as well as in inherited classes or implemented interfaces.

This is most likely a typographical error or the method has been renamed.

Loading history...
Bug introduced by
The method method() does not exist on Psr\Http\Message\ServerRequestInterface. ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-call  annotation

48
            ->/** @scrutinizer ignore-call */ 
49
              method('getAttribute')

This check looks for calls to methods that do not seem to exist on a given type. It looks for the method on the type itself as well as in inherited classes or implemented interfaces.

This is most likely a typographical error or the method has been renamed.

Loading history...
49
            ->with('throw_logic_exception')
50
            ->willReturn('y');
51
52
        $this->renderTemplate('page.twig');
53
    }
54
}
55