Completed
Pull Request — develop (#25)
by Axel
15:47
created

ProjectModelTest   A

Complexity

Total Complexity 1

Size/Duplication

Total Lines 33
Duplicated Lines 0 %

Coupling/Cohesion

Components 0
Dependencies 4

Importance

Changes 1
Bugs 0 Features 1
Metric Value
wmc 1
c 1
b 0
f 1
lcom 0
cbo 4
dl 0
loc 33
rs 10

1 Method

Rating   Name   Duplication   Size   Complexity  
B testModel() 0 31 1
1
<?php
2
3
namespace Developtech\AgilityBundle\Tests\Model;
4
5
use Developtech\AgilityBundle\Tests\Mock\Project;
6
use Developtech\AgilityBundle\Tests\Mock\Feature;
7
use Developtech\AgilityBundle\Tests\Mock\Feedback;
8
9
class ProjectModelTest extends \PHPUnit_Framework_TestCase {
10
    public function testModel() {
11
        $feedback = new Feedback();
12
        $feature = new Feature();
13
        $entity =
14
            (new Project())
0 ignored issues
show
Bug introduced by
The method removeFeedback() does not seem to exist on object<Developtech\Agili...dle\Model\ProjectModel>.

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...
15
            ->setId(1)
16
            ->setName('Great project')
17
            ->setSlug('great-project')
18
            ->setCreatedAt(new \DateTime())
19
            ->setProductOwner((new \StdClass()))
20
            ->setBetaTestStatus('open')
21
            ->setNbBetaTesters(12)
22
            ->addFeature(new Feature())
23
            ->addFeature($feature)
24
            ->removeFeature($feature)
0 ignored issues
show
Documentation introduced by
$feature is of type object<Developtech\Agili...dle\Tests\Mock\Feature>, but the function expects a object<Developtech\Agili...le\Model\FeedbackModel>.

It seems like the type of the argument is not accepted by the function/method which you are calling.

In some cases, in particular if PHP’s automatic type-juggling kicks in this might be fine. In other cases, however this might be a bug.

We suggest to add an explicit type cast like in the following example:

function acceptsInteger($int) { }

$x = '123'; // string "123"

// Instead of
acceptsInteger($x);

// we recommend to use
acceptsInteger((integer) $x);
Loading history...
25
            ->addFeedback($feedback)
26
            ->addFeedback(new Feedback())
27
            ->removeFeedback($feedback)
28
        ;
29
        $this->assertEquals(1, $entity->getId());
30
        $this->assertEquals('Great project', $entity->getName());
31
        $this->assertEquals('great-project', $entity->getSlug());
32
        $this->assertInstanceOf('DateTime', $entity->getCreatedAt());
33
        $this->assertInstanceOf('StdClass', $entity->getProductOwner());
34
        $this->assertEquals('open', $entity->getBetaTestStatus());
35
        $this->assertEquals(12, $entity->getNbBetaTesters());
36
        $this->assertFalse($project->hasFeature($feature));
0 ignored issues
show
Bug introduced by
The variable $project does not exist. Did you forget to declare it?

This check marks access to variables or properties that have not been declared yet. While PHP has no explicit notion of declaring a variable, accessing it before a value is assigned to it is most likely a bug.

Loading history...
37
        $this->assertFalse($project->hasFeedback($feedback));
38
        $this->assertCount(1, $project->getFeedbacks());
39
        $this->assertCount(1, $project->getFeatures());
40
    }
41
}
42