Issues (35)

tests/Service/AggregatorTest.php (1 issue)

Labels
Severity
1
<?php
2
3
namespace Xima\DepmonBundle\Tests\Service;
4
5
use PHPUnit\Framework\TestCase;
6
use Symfony\Bundle\FrameworkBundle\Test\WebTestCase;
7
use Xima\DepmonBundle\Service\Aggregator;
8
9
class AggregatorTest extends WebTestCase
10
{
11
12
    /**
13
     * @var Aggregator
14
     */
15
    private $aggregator;
16
17
    private $projectSampleData = [
18
        'name' => 'depmon',
19
        'git' => 'https://github.com/xima-media/depmon.git',
20
        'path' => ''
21
    ];
22
23
    /**
24
     * Preparation
25
     */
26
    public function setUp()
27
    {
28
        $this->aggregator = new Aggregator();
29
    }
30
31
    public function testAggregation()
32
    {
33
        // get own composer.json as reference
34
        $composerFile = file_get_contents("./composer.json");
35
        $composerJson = json_decode($composerFile, true);
36
37
        // aggregating project data
38
        $data = $this->aggregator->fetchProjectData($this->projectSampleData);
0 ignored issues
show
The call to Xima\DepmonBundle\Servic...tor::fetchProjectData() has too few arguments starting with logger. ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-call  annotation

38
        /** @scrutinizer ignore-call */ 
39
        $data = $this->aggregator->fetchProjectData($this->projectSampleData);

This check compares calls to functions or methods with their respective definitions. If the call has less 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. Please note the @ignore annotation hint above.

Loading history...
39
40
        // check equal names
41
        $this->assertEquals($composerJson['name'], $data['composer']->name);
42
        // check if dependencies are there
43
        $this->assertNotEmpty($data['dependencies']);
44
45
    }
46
47
    /**
48
     * Clean up
49
     */
50
    public function tearDown()
51
    {
52
        $this->aggregator->clearProjectData($this->projectSampleData);
53
        rmdir('var/data');
54
        rmdir('var');
55
    }
56
57
}