Issues (59)

tests/Proxy/SSViewerProxyTest.php (1 issue)

Labels
Severity
1
<?php
2
3
namespace LeKoala\DebugBar\Test\Proxy;
4
5
use LeKoala\DebugBar\DebugBar;
6
use SilverStripe\View\SSViewer;
7
use SilverStrpe\Forms\TextField;
0 ignored issues
show
The type SilverStrpe\Forms\TextField was not found. Maybe you did not declare it correctly or list all dependencies?

The issue could also be caused by a filter entry in the build configuration. If the path has been excluded in your configuration, e.g. excluded_paths: ["lib/*"], you can move it to the dependency path list as follows:

filter:
    dependency_paths: ["lib/*"]

For further information see https://scrutinizer-ci.com/docs/tools/php/php-scrutinizer/#list-dependency-paths

Loading history...
8
use SilverStripe\Dev\FunctionalTest;
9
use SilverStripe\Core\Injector\Injector;
10
use LeKoala\DebugBar\Proxy\SSViewerProxy;
11
12
class SSViewerProxyTest extends FunctionalTest
13
{
14
    public function setUp(): void
15
    {
16
        parent::setUp();
17
18
        // Init manually because we are running tests
19
        DebugBar::initDebugBar();
20
    }
21
22
    public function testOverloadsSSViewer()
23
    {
24
        $templateParser = Injector::inst()->create(SSViewer::class, ['SilverStripe/Forms/Includes/Form']);
25
        $this->assertInstanceOf(SSViewerProxy::class, $templateParser);
26
        $this->assertInstanceOf(SSViewer::class, $templateParser);
27
    }
28
29
    public function testTrackTemplatesUsed()
30
    {
31
        $this->get('/Security/login');
32
33
        if (!DebugBar::getDebugBar()) {
34
            $this->markTestSkipped("No instance available");
35
            return;
36
        }
37
38
        $templates = SSViewerProxy::getTemplatesUsed();
39
40
        $formPath = '/vendor/silverstripe/framework/templates/SilverStripe/Forms/Includes/Form.ss';
41
        $textfieldPath = '/vendor/silverstripe/framework/templates/SilverStripe/Forms/TextField.ss';
42
43
        // Normalize path based on OS
44
        $formPath = str_replace('/', DIRECTORY_SEPARATOR, $formPath);
45
        $textfieldPath = str_replace('/', DIRECTORY_SEPARATOR, $textfieldPath);
46
47
        $this->assertNotEmpty($templates);
48
        $this->assertContains($formPath, $templates);
49
        $this->assertContains($textfieldPath, $templates);
50
    }
51
}
52