GitHub Access Token became invalid

It seems like the GitHub access token used for retrieving details about this repository from GitHub became invalid. This might prevent certain types of inspections from being run (in particular, everything related to pull requests).
Please ask an admin of your repository to re-new the access token on this website.

ParameterHelperTest   A
last analyzed

Complexity

Total Complexity 2

Size/Duplication

Total Lines 64
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 9

Importance

Changes 0
Metric Value
wmc 2
lcom 1
cbo 9
dl 0
loc 64
rs 10
c 0
b 0
f 0

2 Methods

Rating   Name   Duplication   Size   Complexity  
B testExecute() 0 46 1
A getInputStream() 0 8 1
1
<?php
2
namespace Naneau\FileGen\Test\Console;
3
4
use Naneau\FileGen\Console\Helper\ParameterHelper;
5
6
use Naneau\FileGen\Structure;
7
8
use Naneau\FileGen\Test\Console\ParameterCommand;
9
10
use Symfony\Component\Console\Application;
11
12
use Symfony\Component\Console\Helper\QuestionHelper;
13
use Symfony\Component\Console\Helper\HelperSet;
14
use Symfony\Component\Console\Tester\CommandTester;
15
16
/**
17
 * Testing the parameter helper
18
 */
19
class ParameterHelperTest extends \PHPUnit\Framework\TestCase
20
{
21
    public function testExecute()
22
    {
23
        $application = new Application();
24
        $application->getHelperSet()->set(new ParameterHelper, 'filegenParameters');
25
26
        $command = new ParameterCommand;
27
        $application->add($command);
28
29
        $structure = new Structure;
30
        $structure
31
            ->parameter('foo', 'foo description')
32
            ->parameter('bar', 'bar description')
33
            ->parameter('baz', 'baz description');
34
35
        $structure->getParameterDefinition()->get('baz')->setDefaultValue('BazValue');
36
37
        $command->setStructure($structure);
38
39
        $commandTester = new CommandTester($command);
40
41
        // Set the input stream
42
        $helper = $command->getHelper('question');
43
        $helper->setInputStream(
44
            $this->getInputStream("FooValue\nBarValue\n\n")
45
        );
46
47
        $commandTester->execute(array(
48
            'command' => $command->getName())
49
        );
50
51
        $this->assertEquals(
52
            'foo descriptionbar descriptionbaz description',
53
            $commandTester->getDisplay()
54
        );
55
56
        $received = $command->getReceived();
57
58
        $this->assertArrayHasKey('foo', $received);
59
        $this->assertEquals('FooValue', $received['foo']);
60
61
        $this->assertArrayHasKey('bar', $received);
62
        $this->assertEquals('BarValue', $received['bar']);
63
64
        $this->assertArrayHasKey('baz', $received);
65
        $this->assertEquals('BazValue', $received['baz']);
66
    }
67
68
    /**
69
     * Get input stream
70
     *
71
     * @param string $input
72
     * @return resource
73
     **/
74
    protected function getInputStream($input)
75
    {
76
        $stream = fopen('php://memory', 'r+', false);
77
        fputs($stream, $input);
78
        rewind($stream);
79
80
        return $stream;
81
    }
82
}
83