These results are based on our legacy PHP analysis, consider migrating to our new PHP analysis engine instead. Learn more
1 | <?php |
||
2 | namespace Redaxscript\Tests\Console\Command; |
||
3 | |||
4 | use Redaxscript\Console\Command; |
||
5 | use Redaxscript\Tests\TestCaseAbstract; |
||
6 | use org\bovigo\vfs\vfsStream as Stream; |
||
7 | |||
8 | /** |
||
9 | * BackupTest |
||
10 | * |
||
11 | * @since 3.0.0 |
||
12 | * |
||
13 | * @package Redaxscript |
||
14 | * @category Tests |
||
15 | * @author Henry Ruhs |
||
16 | * |
||
17 | * @covers Redaxscript\Console\Command\Backup |
||
18 | * @covers Redaxscript\Console\Command\CommandAbstract |
||
19 | * |
||
20 | * @requires OS Linux |
||
21 | */ |
||
22 | |||
23 | class BackupTest extends TestCaseAbstract |
||
24 | { |
||
25 | /** |
||
26 | * setUp |
||
27 | * |
||
28 | * @since 3.2.0 |
||
29 | */ |
||
30 | |||
31 | public function setUp() |
||
32 | { |
||
33 | parent::setUp(); |
||
34 | Stream::setup('root', 0777, $this->getJSON('tests' . DIRECTORY_SEPARATOR . 'provider' . DIRECTORY_SEPARATOR . 'Console' . DIRECTORY_SEPARATOR . 'ConsoleTest_setUp.json')); |
||
0 ignored issues
–
show
|
|||
35 | } |
||
36 | |||
37 | /** |
||
38 | * tearDown |
||
39 | * |
||
40 | * @since 3.0.0 |
||
41 | */ |
||
42 | |||
43 | public function tearDown() |
||
44 | { |
||
45 | $this->_request->setServer('argv', null); |
||
46 | } |
||
47 | |||
48 | /** |
||
49 | * testNoArgument |
||
50 | * |
||
51 | * @since 3.0.0 |
||
52 | */ |
||
53 | |||
54 | public function testNoArgument() |
||
55 | { |
||
56 | /* setup */ |
||
57 | |||
58 | $backupCommand = new Command\Backup($this->_registry, $this->_request, $this->_language, $this->_config); |
||
59 | |||
60 | /* expect and actual */ |
||
61 | |||
62 | $expect = $backupCommand->getHelp(); |
||
63 | $actual = $backupCommand->run('cli'); |
||
64 | |||
65 | /* compare */ |
||
66 | |||
67 | $this->assertEquals($expect, $actual); |
||
68 | } |
||
69 | |||
70 | /** |
||
71 | * testDatabase |
||
72 | * |
||
73 | * @since 3.0.0 |
||
74 | */ |
||
75 | |||
76 | public function testDatabase() |
||
77 | { |
||
78 | /* setup */ |
||
79 | |||
80 | $this->_request->setServer('argv', |
||
81 | [ |
||
0 ignored issues
–
show
array('console.php', 'ba...Y_SEPARATOR . 'build')) is of type array<integer,string,{"0..."string","4":"string"}> , but the function expects a string|boolean|null .
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...
|
|||
82 | 'console.php', |
||
83 | 'backup', |
||
84 | 'database', |
||
85 | '--directory', |
||
86 | Stream::url('root' . DIRECTORY_SEPARATOR . 'build') |
||
87 | ]); |
||
88 | $backupCommand = new Command\Backup($this->_registry, $this->_request, $this->_language, $this->_config); |
||
89 | |||
90 | /* actual */ |
||
91 | |||
92 | $actual = $backupCommand->run('cli'); |
||
93 | |||
94 | /* compare */ |
||
95 | |||
96 | $this->assertTrue($actual); |
||
97 | } |
||
98 | |||
99 | /** |
||
100 | * testDatabaseInvalid |
||
101 | * |
||
102 | * @since 3.0.0 |
||
103 | */ |
||
104 | |||
105 | public function testDatabaseInvalid() |
||
106 | { |
||
107 | /* setup */ |
||
108 | |||
109 | $this->_request->setServer('argv', |
||
110 | [ |
||
111 | 'console.php', |
||
112 | 'backup', |
||
113 | 'database', |
||
114 | '--no-interaction' |
||
115 | ]); |
||
116 | $backupCommand = new Command\Backup($this->_registry, $this->_request, $this->_language, $this->_config); |
||
117 | |||
118 | /* actual */ |
||
119 | |||
120 | $actual = $backupCommand->run('cli'); |
||
121 | |||
122 | /* compare */ |
||
123 | |||
124 | $this->assertFalse($actual); |
||
125 | } |
||
126 | } |
||
127 |
This check looks at variables that are passed out again to other methods.
If the outgoing method call has stricter type requirements than the method itself, an issue is raised.
An additional type check may prevent trouble.