Issues (32)

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/Manager/FeedbackManagerTest.php (2 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 Developtech\AgilityBundle\Tests\Manager;
4
5
use Developtech\AgilityBundle\Manager\FeedbackManager;
6
7
use Developtech\AgilityBundle\Entity\Feedback;
8
use Developtech\AgilityBundle\Tests\Mock\User;
9
use Developtech\AgilityBundle\Entity\Project;
10
11
use Developtech\AgilityBundle\Utils\Slugger;
12
13
class FeedbackManagerTest extends \PHPUnit_Framework_TestCase {
14
    /** @var FeedbackManager **/
15
    protected $manager;
16
17
    public function setUp() {
18
        $this->manager = new FeedbackManager($this->getEntityManagerMock(), new Slugger(), Feedback::class);
0 ignored issues
show
The call to FeedbackManager::__construct() has too many arguments starting with \Developtech\AgilityBundle\Entity\Feedback::class.

This check compares calls to functions or methods with their respective definitions. If the call has more arguments than are defined, it raises an issue.

If a function is defined several times with a different number of parameters, the check may pick up the wrong definition and report false positives. One codebase where this has been known to happen is Wordpress.

In this case you can add the @ignore PhpDoc annotation to the duplicate definition and it will be ignored.

Loading history...
19
    }
20
21
    public function testGetProjectFeedbacks() {
22
        $feedbacks = $this->manager->getProjectFeedbacks((new Project()));
23
24
        $this->assertCount(2, $feedbacks);
25
        $this->assertInstanceOf(Feedback::class, $feedbacks[0]);
26
        $this->assertEquals(2, $feedbacks[1]->getId());
27
    }
28
29
    public function testGetProjectFeedbacksByAuthor() {
30
        $feedbacks = $this->manager->getProjectFeedbacksByAuthor(new Project(), new User('Hagrid'));
31
32
        $this->assertCount(2, $feedbacks);
33
        $this->assertInstanceOf(Feedback::class, $feedbacks[0]);
34
        $this->assertEquals(2, $feedbacks[1]->getId());
35
        $this->assertEquals('Hagrid', $feedbacks[0]->getAuthor()->getUsername());
36
        $this->assertEquals('Hagrid', $feedbacks[1]->getAuthor()->getUsername());
37
    }
38
39
    public function testGetFeedback() {
40
        $feedback = $this->manager->getFeedback(1);
41
42
        $this->assertInstanceOf(Feedback::class, $feedback);
43
        $this->assertEquals(1, $feedback->getId());
44
    }
45
46
    /**
47
     * @expectedException Symfony\Component\HttpKernel\Exception\NotFoundHttpException
48
     * @expectedExceptionMessage Feedback not found
49
     */
50
    public function testGetFeedbackWithUnexistingFeedback() {
51
        $this->manager->getFeedback(2);
52
    }
53
54
    public function testCreateFeedback() {
55
        $feedback = $this->manager->createFeedback(
56
            (new Project()),
57
            'There is a bug in the kitchen',
58
            'The fridge is hotter than my computer !',
59
            (new User())
60
        );
61
        $this->assertInstanceOf(Feedback::class, $feedback);
62
        $this->assertInstanceOf(Project::class, $feedback->getProject());
63
        $this->assertEquals('There is a bug in the kitchen', $feedback->getName());
64
        $this->assertEquals('there-is-a-bug-in-the-kitchen', $feedback->getSlug());
65
        $this->assertEquals('The fridge is hotter than my computer !', $feedback->getDescription());
66
        $this->assertInstanceOf(User::class, $feedback->getAuthor());
67
        $this->assertEquals(Feedback::STATUS_OPEN, $feedback->getStatus());
68
    }
69
70
    public function testCountFeedbacksPerStatus() {
71
        $this->assertEquals(3, $this->manager->countFeedbacksPerStatus((new Project())->setId(1), Feedback::STATUS_OPEN));
72
    }
73
74
    public function getEntityManagerMock() {
75
        $entityManagerMock = $this
76
            ->getMockBuilder('Doctrine\ORM\EntityManager')
77
            ->disableOriginalConstructor()
78
            ->getMock()
79
        ;
80
        $entityManagerMock
81
            ->expects($this->any())
82
            ->method('getRepository')
83
            ->willReturnCallback([$this, 'getRepositoryMock'])
84
        ;
85
        $entityManagerMock
86
            ->expects($this->any())
87
            ->method('persist')
88
            ->willReturn(true)
89
        ;
90
        $entityManagerMock
91
            ->expects($this->any())
92
            ->method('flush')
93
            ->willReturn(true)
94
        ;
95
        return $entityManagerMock;
96
    }
97
98
    public function getRepositoryMock() {
99
        $repositoryMock = $this
100
            ->getMockBuilder('Developtech\AgilityBundle\Repository\FeedbackRepository')
101
            ->disableOriginalConstructor()
102
            ->setMethods([
103
                'find',
104
                'findBy',
105
                'findByProject',
106
                'countPerStatus'
107
            ])
108
            ->getMock()
109
        ;
110
        $repositoryMock
111
            ->expects($this->any())
112
            ->method('findByProject')
113
            ->willReturnCallback([$this, 'getFeedbacksMock'])
114
        ;
115
        $repositoryMock
116
            ->expects($this->any())
117
            ->method('findBy')
118
            ->willReturnCallback([$this, 'getFeedbacksWithAuthorMock'])
119
        ;
120
        $repositoryMock
121
            ->expects($this->any())
122
            ->method('find')
123
            ->willReturnCallback([$this, 'getFeedbackMock'])
124
        ;
125
        $repositoryMock
126
            ->expects($this->any())
127
            ->method('countPerStatus')
128
            ->willReturn(3)
129
        ;
130
        return $repositoryMock;
131
    }
132
133
    public function getFeedbackMock($id) {
134
        if($id === 2) {
0 ignored issues
show
Expected 1 space after IF keyword; 0 found
Loading history...
135
            return null;
136
        }
137
        return
138
            (new Feedback())
139
            ->setId(1)
140
            ->setName('I can\'t see the calendar')
141
            ->setSlug('i-can-t-see-the-calendar')
142
            ->setDescription('Add brightness to this calendar !')
143
            ->setProject(new Project())
144
            ->setAuthor(new User())
145
            ->setResponsible(new User())
146
            ->setCreatedAt(new \DateTime())
147
            ->setUpdatedAt(new \DateTime())
148
        ;
149
    }
150
151
    public function getFeedbacksMock() {
152
        return [
153
            (new Feedback())
154
            ->setId(1)
155
            ->setName('I can\'t see the calendar')
156
            ->setSlug('i-can-t-see-the-calendar')
157
            ->setDescription('Add brightness to this calendar !')
158
            ->setProject(new Project())
159
            ->setAuthor(new User())
160
            ->setResponsible(new User())
161
            ->setCreatedAt(new \DateTime())
162
            ->setUpdatedAt(new \DateTime()),
163
            (new Feedback())
164
            ->setId(2)
165
            ->setName('The calendar is not shiny enough')
166
            ->setSlug('the-calendar-is-not-shiny-enough')
167
            ->setDescription('This calendar blew my eyes away !')
168
            ->setProject(new Project())
169
            ->setAuthor(new User())
170
            ->setResponsible(new User())
171
            ->setCreatedAt(new \DateTime())
172
            ->setUpdatedAt(new \DateTime()),
173
        ];
174
    }
175
176
    public function getFeedbacksWithAuthorMock() {
177
        return [
178
            (new Feedback())
179
            ->setId(1)
180
            ->setName('I can\'t see the calendar')
181
            ->setSlug('i-can-t-see-the-calendar')
182
            ->setDescription('Add brightness to this calendar !')
183
            ->setProject(new Project())
184
            ->setAuthor(new User('Hagrid'))
185
            ->setResponsible(new User())
186
            ->setCreatedAt(new \DateTime())
187
            ->setUpdatedAt(new \DateTime()),
188
            (new Feedback())
189
            ->setId(2)
190
            ->setName('The calendar is not shiny enough')
191
            ->setSlug('the-calendar-is-not-shiny-enough')
192
            ->setDescription('This calendar blew my eyes away !')
193
            ->setProject(new Project())
194
            ->setAuthor(new User('Hagrid'))
195
            ->setResponsible(new User())
196
            ->setCreatedAt(new \DateTime())
197
            ->setUpdatedAt(new \DateTime()),
198
        ];
199
    }
200
}
201