Issues (16)

Security Analysis    no request data  

This project does not seem to handle request data directly as such no vulnerable execution paths were found.

  Cross-Site Scripting
Cross-Site Scripting enables an attacker to inject code into the response of a web-request that is viewed by other users. It can for example be used to bypass access controls, or even to take over other users' accounts.
  File Exposure
File Exposure allows an attacker to gain access to local files that he should not be able to access. These files can for example include database credentials, or other configuration files.
  File Manipulation
File Manipulation enables an attacker to write custom data to files. This potentially leads to injection of arbitrary code on the server.
  Object Injection
Object Injection enables an attacker to inject an object into PHP code, and can lead to arbitrary code execution, file exposure, or file manipulation attacks.
  Code Injection
Code Injection enables an attacker to execute arbitrary code on the server.
  Response Splitting
Response Splitting can be used to send arbitrary responses.
  File Inclusion
File Inclusion enables an attacker to inject custom files into PHP's file loading mechanism, either explicitly passed to include, or for example via PHP's auto-loading mechanism.
  Command Injection
Command Injection enables an attacker to inject a shell command that is execute with the privileges of the web-server. This can be used to expose sensitive data, or gain access of your server.
  SQL Injection
SQL Injection enables an attacker to execute arbitrary SQL code on your database server gaining access to user data, or manipulating user data.
  XPath Injection
XPath Injection enables an attacker to modify the parts of XML document that are read. If that XML document is for example used for authentication, this can lead to further vulnerabilities similar to SQL Injection.
  LDAP Injection
LDAP Injection enables an attacker to inject LDAP statements potentially granting permission to run unauthorized queries, or modify content inside the LDAP tree.
  Header Injection
  Other Vulnerability
This category comprises other attack vectors such as manipulating the PHP runtime, loading custom extensions, freezing the runtime, or similar.
  Regex Injection
Regex Injection enables an attacker to execute arbitrary code in your PHP process.
  XML Injection
XML Injection enables an attacker to read files on your local filesystem including configuration files, or can be abused to freeze your web-server process.
  Variable Injection
Variable Injection enables an attacker to overwrite program variables with custom data, and can lead to further vulnerabilities.
Unfortunately, the security analysis is currently not available for your project. If you are a non-commercial open-source project, please contact support to gain access.

Tests/Render/FrontRenderTest.php (13 issues)

Upgrade to new PHP Analysis Engine

These results are based on our legacy PHP analysis, consider migrating to our new PHP analysis engine instead. Learn more

1
<?php
2
3
namespace Chris\Bundle\FrontRenderBundle\Tests\Render;
4
5
use Chris\Bundle\FrontRenderBundle\Render\FrontRender;
6
use Chris\Bundle\FrontRenderBundle\Subscriber\RenderSubscriber;
7
use Chris\Bundle\FrontRenderBundle\Twig\LexerManager;
8
use InvalidArgumentException;
9
use Phake;
10
use PHPUnit_Framework_TestCase;
11
use Symfony\Bundle\TwigBundle\TwigEngine;
12
use Symfony\Component\Config\FileLocator;
13
use Symfony\Component\EventDispatcher\EventDispatcher;
14
use Symfony\Component\Templating\TemplateNameParser;
15
use Twig_Environment;
16
use Twig_Error_Syntax;
17
use Twig_Loader_Filesystem;
18
19
class FrontRenderTest extends PHPUnit_Framework_TestCase
20
{
21
    /**
22
     * @var string TEMPLATE_PATH
23
     */
24
    const TEMPLATE_PATH = 'Template';
25
26
    /**
27
     * @var string TEMPLATE
28
     */
29
    const TEMPLATE = 'index.html.twig';
30
31
    /**
32
     * @var string FAILED_TEMPLATE
33
     */
34
    const FAILED_TEMPLATE = 'failed.html.twig';
35
36
    /**
37
     * @var string FAILED_PATH
38
     */
39
    const FAILED_PATH = 'failedPath.html.twig';
40
41
    /**
42
     * @var EventDispatcher
43
     */
44
    protected $eventDispatcher;
45
46
    /**
47
     * @var Twig_Loader_Filesystem
48
     */
49
    protected $twigLoader;
50
51
    /**
52
     * @var Twig_Environment
53
     */
54
    protected $twigEnvironment;
55
56
    /**
57
     * @var RenderSubscriber
58
     */
59
    protected $renderSubscriber;
60
61
    /**
62
     * @var TemplateNameParser
63
     */
64
    protected $templateNameParser;
65
66
    /**
67
     * @var FileLocator
68
     */
69
    protected $fileLocator;
70
71
    /**
72
     * @var TwigEngine
73
     */
74
    protected $engine;
75
76
    /**
77
     * @var FrontRender
78
     */
79
    protected $frontRender;
80
81
    /**
82
     * @var LexerManager
83
     */
84
    protected $lexerManager;
85
86
    /**
87
     * Set up the front render test
88
     */
89
    public function setUp()
90
    {
91
        parent::setUp();
92
93
        $this->eventDispatcher  = Phake::mock(EventDispatcher::class);
0 ignored issues
show
Documentation Bug introduced by
It seems like \Phake::mock(\Symfony\Co...EventDispatcher::class) of type object<Phake_IMock> is incompatible with the declared type object<Symfony\Component...atcher\EventDispatcher> of property $eventDispatcher.

Our type inference engine has found an assignment to a property that is incompatible with the declared type of that property.

Either this assignment is in error or the assigned type should be added to the documentation/type hint for that property..

Loading history...
94
        $this->twigLoader       = Phake::partialMock(Twig_Loader_Filesystem::class, [__DIR__ . DIRECTORY_SEPARATOR . '..' . DIRECTORY_SEPARATOR . self::TEMPLATE_PATH]);
0 ignored issues
show
Documentation Bug introduced by
It seems like \Phake::partialMock(\Twi.... self::TEMPLATE_PATH)) of type object<Phake_IMock> is incompatible with the declared type object<Twig_Loader_Filesystem> of property $twigLoader.

Our type inference engine has found an assignment to a property that is incompatible with the declared type of that property.

Either this assignment is in error or the assigned type should be added to the documentation/type hint for that property..

Loading history...
95
        $this->twigEnvironment  = Phake::partialMock(Twig_Environment::class, $this->twigLoader);
0 ignored issues
show
Documentation Bug introduced by
It seems like \Phake::partialMock(\Twi...ass, $this->twigLoader) of type object<Phake_IMock> is incompatible with the declared type object<Twig_Environment> of property $twigEnvironment.

Our type inference engine has found an assignment to a property that is incompatible with the declared type of that property.

Either this assignment is in error or the assigned type should be added to the documentation/type hint for that property..

Loading history...
96
        $this->lexerManager     = Phake::partialMock(LexerManager::class, $this->twigEnvironment);
0 ignored issues
show
Documentation Bug introduced by
It seems like \Phake::partialMock(\Chr...$this->twigEnvironment) of type object<Phake_IMock> is incompatible with the declared type object<Chris\Bundle\Fron...ndle\Twig\LexerManager> of property $lexerManager.

Our type inference engine has found an assignment to a property that is incompatible with the declared type of that property.

Either this assignment is in error or the assigned type should be added to the documentation/type hint for that property..

Loading history...
97
        $this->renderSubscriber = Phake::partialMock(RenderSubscriber::class, $this->lexerManager);
0 ignored issues
show
Documentation Bug introduced by
It seems like \Phake::partialMock(\Chr...s, $this->lexerManager) of type object<Phake_IMock> is incompatible with the declared type object<Chris\Bundle\Fron...riber\RenderSubscriber> of property $renderSubscriber.

Our type inference engine has found an assignment to a property that is incompatible with the declared type of that property.

Either this assignment is in error or the assigned type should be added to the documentation/type hint for that property..

Loading history...
98
99
        $this->templateNameParser = Phake::mock(TemplateNameParser::class);
0 ignored issues
show
Documentation Bug introduced by
It seems like \Phake::mock(\Symfony\Co...plateNameParser::class) of type object<Phake_IMock> is incompatible with the declared type object<Symfony\Component...ing\TemplateNameParser> of property $templateNameParser.

Our type inference engine has found an assignment to a property that is incompatible with the declared type of that property.

Either this assignment is in error or the assigned type should be added to the documentation/type hint for that property..

Loading history...
100
        $this->fileLocator        = Phake::mock(FileLocator::class);
0 ignored issues
show
Documentation Bug introduced by
It seems like \Phake::mock(\Symfony\Co...fig\FileLocator::class) of type object<Phake_IMock> is incompatible with the declared type object<Symfony\Component\Config\FileLocator> of property $fileLocator.

Our type inference engine has found an assignment to a property that is incompatible with the declared type of that property.

Either this assignment is in error or the assigned type should be added to the documentation/type hint for that property..

Loading history...
101
        $this->engine             = Phake::partialMock(TwigEngine::class, $this->twigEnvironment, $this->templateNameParser, $this->fileLocator);
0 ignored issues
show
Documentation Bug introduced by
It seems like \Phake::partialMock(\Sym...er, $this->fileLocator) of type object<Phake_IMock> is incompatible with the declared type object<Symfony\Bundle\TwigBundle\TwigEngine> of property $engine.

Our type inference engine has found an assignment to a property that is incompatible with the declared type of that property.

Either this assignment is in error or the assigned type should be added to the documentation/type hint for that property..

Loading history...
102
103
        $lexer = $this->lexerManager->getNewLexer();
0 ignored issues
show
The method getNewLexer() does not seem to exist on object<Phake_IMock>.

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...
104
        $this->twigEnvironment->setLexer($lexer);
0 ignored issues
show
The method setLexer() does not seem to exist on object<Phake_IMock>.

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...
105
    }
106
107
    /**
108
     * Test render of the template with parameter
109
     */
110 View Code Duplication
    public function testTemplateRenderWithParameter()
0 ignored issues
show
This method seems to be duplicated in your project.

Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.

You can also find more detailed suggestions in the “Code” section of your repository.

Loading history...
111
    {
112
        $this->frontRender = new FrontRender($this->engine, $this->eventDispatcher, self::TEMPLATE);
113
114
        $this->frontRender->setParameters(
115
            [
116
                'applicationName' => 'Test Render',
117
            ]
118
        );
119
120
        $this->assertContains(
121
            'Welcome on Test Render',
122
            $this->frontRender->render()
123
        );
124
    }
125
126
    /**
127
     * Test render of the template without parameter
128
     */
129 View Code Duplication
    public function testTemplateRenderWithoutParameter()
0 ignored issues
show
This method seems to be duplicated in your project.

Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.

You can also find more detailed suggestions in the “Code” section of your repository.

Loading history...
130
    {
131
        $this->frontRender = new FrontRender($this->engine, $this->eventDispatcher, self::TEMPLATE);
132
133
        $this->assertNotContains(
134
            'Test Render',
135
            $this->frontRender->render()
136
        );
137
    }
138
139
    /**
140
     * Test on the update of lexer
141
     *
142
     * @dataProvider lexerTags
143
     *
144
     * @param string $oldTags
145
     * @param string $newTags
146
     */
147
    public function testSetLexer($oldTags, $newTags)
148
    {
149
        $this->frontRender = new FrontRender($this->engine, $this->eventDispatcher, self::TEMPLATE);
150
151
        $this->frontRender->setParameters(
152
            [
153
                'applicationName' => 'Test Render',
154
            ]
155
        );
156
157
        $render = $this->frontRender->render();
158
159
        $this->assertContains(
160
            $oldTags,
161
            $render
162
        );
163
164
        $this->assertNotContains(
165
            $newTags,
166
            $render
167
        );
168
    }
169
170
    /**
171
     * Test on the failed template
172
     *
173
     * @expectedException Twig_Error_Syntax
174
     */
175
    public function testExceptionOnSyntax()
176
    {
177
        $this->frontRender = new FrontRender($this->engine, $this->eventDispatcher, self::FAILED_TEMPLATE);
178
179
        $this->frontRender->render();
180
    }
181
182
    /**
183
     * Test when the template doesn't exist
184
     *
185
     * @expectedException InvalidArgumentException
186
     */
187
    public function testExceptionOnFailedPath()
188
    {
189
        $this->frontRender = new FrontRender($this->engine, $this->eventDispatcher, self::FAILED_PATH);
190
191
        $this->frontRender->render();
192
    }
193
194
    /**
195
     * Test when the template path is empty
196
     *
197
     * @expectedException Chris\Bundle\FrontRenderBundle\Exception\FrontRenderException
198
     */
199
    public function testExceptionOnEmptyPath()
200
    {
201
        $this->frontRender = new FrontRender($this->engine, $this->eventDispatcher, '');
202
203
        $this->frontRender->render();
204
    }
205
206
    /**
207
     * Provide the lexer tags
208
     *
209
     * @return array
0 ignored issues
show
Consider making the return type a bit more specific; maybe use string[][].

This check looks for the generic type array as a return type and suggests a more specific type. This type is inferred from the actual code.

Loading history...
210
     */
211
    public function lexerTags()
212
    {
213
        return [
214
            ['{#', '{*'],
215
            ['{%', '{@'],
216
            ['{{', '{$']
217
        ];
218
219
    }
220
}
221