Issues (11)

Security Analysis    not enabled

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/View/TranslatedViewTest.php (1 issue)

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
/*
4
 * This file is part of the Pagerfanta package.
5
 *
6
 * (c) Pablo Díez <[email protected]>
7
 *
8
 * For the full copyright and license information, please view the LICENSE
9
 * file that was distributed with this source code.
10
 */
11
12
namespace WhiteOctober\PagerfantaBundle\Tests\View;
13
14
abstract class TranslatedViewTest extends \PHPUnit_Framework_TestCase
15
{
16
    private $view;
17
    private $translator;
18
19
    private $translatedView;
20
21
    private $pagerfanta;
22
    private $routeGenerator;
23
24
    protected function setUp()
25
    {
26
        $this->view = $this->createViewMock();
27
        $this->translator = $this->createTranslatorMock();
28
29
        $this->translatedView = $this->createTranslatedView();
30
31
        $this->pagerfanta = $this->createPagerfantaMock();
32
        $this->routeGenerator = $this->createRouteGenerator();
33
    }
34
35
    protected function createOrGetMock($originalClassName)
36
    {
37
        if (method_exists($this, 'createMock')) {
38
            return $this->createMock($originalClassName);
39
        }
40
41
        return $this->getMock($originalClassName);
0 ignored issues
show
Deprecated Code introduced by
The method PHPUnit_Framework_TestCase::getMock() has been deprecated with message: Method deprecated since Release 5.4.0; use createMock() or getMockBuilder() instead

This method has been deprecated. The supplier of the class has supplied an explanatory message.

The explanatory message should give you some clue as to whether and when the method will be removed from the class and what other method or class to use instead.

Loading history...
42
    }
43
44
    private function createViewMock()
45
    {
46
        return $this->createOrGetMock($this->viewClass());
47
    }
48
49
    abstract protected function viewClass();
50
51
    private function createTranslatorMock()
52
    {
53
        return $this->createOrGetMock('Symfony\Component\Translation\TranslatorInterface');
54
    }
55
56
    private function createTranslatedView()
57
    {
58
        $class = $this->translatedViewClass();
59
60
        return new $class($this->view, $this->translator);
61
    }
62
63
    abstract protected function translatedViewClass();
64
65
    private function createPagerfantaMock()
66
    {
67
        return $this->getMockBuilder('Pagerfanta\Pagerfanta')
68
            ->disableOriginalConstructor()
69
            ->getMock();
70
    }
71
72
    private function createRouteGenerator()
73
    {
74
        return function () { };
75
    }
76
77
    public function testRenderShouldTranslatePreviuosAndNextMessage()
78
    {
79
        $this->translatorExpectsPreviousAt(0);
80
        $this->translatorExpectsNextAt(1);
81
82
        $options = array();
83
84
        $this->assertRender($options);
85
    }
86
87
    public function testRenderAllowsCustomizingPreviousMessageWithOption()
88
    {
89
        $this->translatorExpectsNextAt(0);
90
91
        $previousMessageOption = $this->previousMessageOption();
92
        $options = array($previousMessageOption => $this->previousMessage());
93
94
        $this->assertRender($options);
95
    }
96
97
    public function testRenderAllowsCustomizingNextMessageWithOption()
98
    {
99
        $this->translatorExpectsPreviousAt(0);
100
101
        $nextMessageOption = $this->nextMessageOption();
102
        $options = array($nextMessageOption => $this->nextMessage());
103
104
        $this->assertRender($options);
105
    }
106
107
    private function translatorExpectsPreviousAt($at)
108
    {
109
        $previous = $this->previous();
110
111
        $this->translator
112
            ->expects($this->at($at))
113
            ->method('trans')
114
            ->with('previous', array(), 'pagerfanta')
115
            ->will($this->returnValue($previous));
116
    }
117
118
    private function translatorExpectsNextAt($at)
119
    {
120
        $next = $this->next();
121
122
        $this->translator
123
            ->expects($this->at($at))
124
            ->method('trans')
125
            ->with('next', array(), 'pagerfanta')
126
            ->will($this->returnValue($next));
127
    }
128
129
    private function assertRender($options)
130
    {
131
        $previousMessageOption = $this->previousMessageOption();
132
        $nextMessageOption = $this->nextMessageOption();
133
134
        $previous = $this->previous();
135
        $next = $this->next();
136
137
        $expectedOptions = array(
138
            $previousMessageOption => $this->buildPreviousMessage($previous),
139
            $nextMessageOption => $this->buildNextMessage($next)
140
        );
141
142
        $result = new \stdClass();
143
144
        $this->view
145
            ->expects($this->once())
146
            ->method('render')
147
            ->with($this->pagerfanta, $this->routeGenerator, $expectedOptions)
148
            ->will($this->returnvalue($result));
149
150
        $rendered = $this->translatedView->render($this->pagerfanta, $this->routeGenerator, $options);
151
152
        $this->assertSame($result, $rendered);
153
    }
154
155
    abstract protected function previousMessageOption();
156
157
    abstract protected function nextMessageOption();
158
159
    private function previous()
160
    {
161
        return 'Anterior';
162
    }
163
164
    private function next()
165
    {
166
        return 'Siguiente';
167
    }
168
169
    private function previousMessage()
170
    {
171
        return $this->buildPreviousMessage($this->previous());
172
    }
173
174
    private function nextMessage()
175
    {
176
        return $this->buildNextMessage($this->next());
177
    }
178
179
    abstract protected function buildPreviousMessage($text);
180
181
    abstract protected function buildNextMessage($text);
182
183
    public function testGetNameShouldReturnTheName()
184
    {
185
        $name = $this-> translatedViewName();
186
187
        $this->assertSame($name, $this->translatedView->getName());
188
    }
189
190
    abstract protected function translatedViewName();
191
}