Issues (159)

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/Membership/MembershipServiceTest.php (1 issue)

Severity

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
 * Storgman - Student Organizations Management
5
 * Copyright (C) 2014-2015, Dejan Angelov <[email protected]>
6
 *
7
 * This file is part of Storgman.
8
 *
9
 * Storgman is free software: you can redistribute it and/or modify
10
 * it under the terms of the GNU General Public License as published by
11
 * the Free Software Foundation, either version 3 of the License, or
12
 * (at your option) any later version.
13
 *
14
 * Storgman is distributed in the hope that it will be useful,
15
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
16
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
17
 * GNU General Public License for more details.
18
 *
19
 * You should have received a copy of the GNU General Public License
20
 * along with Storgman.  If not, see <http://www.gnu.org/licenses/>.
21
 *
22
 * @package Storgman
23
 * @copyright Copyright (C) 2014-2015, Dejan Angelov <[email protected]>
24
 * @license https://github.com/angelov/storgman/blob/master/LICENSE
25
 * @author Dejan Angelov <[email protected]>
26
 */
27
28
namespace Angelov\Storgman\Tests\Meetings;
29
30
use Angelov\Storgman\Core\DateTime;
31
use Angelov\Storgman\Members\Member;
32
use Angelov\Storgman\Members\Repositories\MembersRepositoryInterface;
33
use Angelov\Storgman\Membership\MembershipService;
34
use Angelov\Storgman\Membership\Reports\ExpectedAndPaidFeesPerMonthReport;
35
use Angelov\Storgman\Membership\Reports\ExpectedFeesPerMonthReport;
36
use Angelov\Storgman\Membership\Reports\PaidFeesPerMonthReport;
37
use Angelov\Storgman\Membership\Repositories\FeesRepositoryInterface;
38
use Angelov\Storgman\Tests\TestCase;
39
use Carbon\Carbon;
40
use Mockery;
41
42
class MembershipServiceTest extends TestCase
43
{
44
    /** @var $members Mockery\MockInterface */
45
    protected $members;
46
47
    /** @var $fees Mockery\MockInterface */
48
    protected $fees;
49
50
    public function setUp()
51
    {
52
        parent::setUp();
53
54
        $this->members = Mockery::mock(MembersRepositoryInterface::class);
55
        $this->fees = Mockery::mock(FeesRepositoryInterface::class);
56
    }
57
58
    public function testCanGenerateExpectedAndPaidFeesPerMonthLastYearReport()
59
    {
60
        $membershipService = new MembershipService($this->members, $this->fees);
61
62
        $expectedFeesPerMonthReport = Mockery::mock(ExpectedFeesPerMonthReport::class);
63
        $paidFeesPerMonthReport = Mockery::mock(PaidFeesPerMonthReport::class);
64
65
        $this->fees->shouldReceive('calculateExpectedFeesPerMonth')->andReturn($expectedFeesPerMonthReport);
66
        $this->fees->shouldReceive('calculatePaidFeesPerMonth')->andReturn($paidFeesPerMonthReport);
67
68
        $expected = [10, 15, 20];
69
        $paid = [5, 20, 15];
70
71
        $expectedFeesPerMonthReport->shouldReceive('getMonthsValues')->andReturn($expected);
72
        $paidFeesPerMonthReport->shouldReceive('getMonthsValues')->andReturn($paid);
73
74
        $this->fees->shouldReceive('calculateExpectedFeesPerMonth');
75
        $this->fees->shouldReceive('calculatePaidFeesPerMonth');
76
77
        $report = $membershipService->getExpectedAndPaidFeesPerMonthLastYear();
78
79
        $this->assertInstanceOf(ExpectedAndPaidFeesPerMonthReport::class, $report);
80
81
        $this->assertEquals($paid, $report->getPaidFees());
82
        $this->assertEquals($expected, $report->getExpectedFees());
83
    }
84
85
    public function testCanGenerateSuggestionDatesForExistingMember()
86
    {
87
        $member = Mockery::mock(Member::class);
88
        $expirationDate = new Carbon('2015-10-22');
89
        $member->shouldReceive('getExpirationDate')->andReturn($expirationDate);
90
91
        $membershipService = new MembershipService($this->members, $this->fees);
92
93
        $suggestedDates = $membershipService->suggestDates($member);
94
95
        $this->assertTrue(is_array($suggestedDates));
96
        $this->assertEquals('2015-10-23', $suggestedDates['from']);
97
        $this->assertEquals('2016-10-23', $suggestedDates['to']);
98
    }
99
100
    public function testCanGenerateSuggestionDatesForNewMember()
101
    {
102
        $member = Mockery::mock(Member::class);
103
        $member->shouldReceive('getExpirationDate')->andReturnNull();
0 ignored issues
show
The call to the method Mockery\Expectation::andReturnNull() seems un-needed as the method has no side-effects.

PHP Analyzer performs a side-effects analysis of your code. A side-effect is basically anything that might be visible after the scope of the method is left.

Let’s take a look at an example:

class User
{
    private $email;

    public function getEmail()
    {
        return $this->email;
    }

    public function setEmail($email)
    {
        $this->email = $email;
    }
}

If we look at the getEmail() method, we can see that it has no side-effect. Whether you call this method or not, no future calls to other methods are affected by this. As such code as the following is useless:

$user = new User();
$user->getEmail(); // This line could safely be removed as it has no effect.

On the hand, if we look at the setEmail(), this method _has_ side-effects. In the following case, we could not remove the method call:

$user = new User();
$user->setEmail('email@domain'); // This line has a side-effect (it changes an
                                 // instance variable).
Loading history...
104
105
        $membershipService = new MembershipService($this->members, $this->fees);
106
107
        $suggestedDates = $membershipService->suggestDates($member);
108
109
        $now = new Carbon();
110
        $nextYear = (new Carbon())->addYear();
111
112
        $this->assertTrue(is_array($suggestedDates));
113
        $this->assertEquals($now->format('Y-m-d'), $suggestedDates['from']);
114
        $this->assertEquals($nextYear->format('Y-m-d'), $suggestedDates['to']);
115
    }
116
}
117