Skip to content

Commit afb740d

Browse files
committed
feat: Added unit tests for SubCommands
1 parent 6bb1ea0 commit afb740d

File tree

1 file changed

+35
-0
lines changed

1 file changed

+35
-0
lines changed
Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
<?php
2+
3+
declare(strict_types=1);
4+
5+
namespace Tests\Unit\Commands;
6+
7+
use Tests\BaseTestCase;
8+
use Tests\Unit\FileManager\ExtractTest;
9+
use WP_CLI_Secure\FileManager;
10+
use WP_CLI_Secure\SubCommands\BlockAccessToHtaccess;
11+
12+
class SubCommandTest extends BaseTestCase {
13+
14+
public function testItWillSetCorrectCommandArguments() : void {
15+
$assocArgs = [
16+
'file-path' => $this->root->url() . '/.htaccess',
17+
'server' => 'nginx',
18+
'output' => true
19+
];
20+
21+
$command = new BlockAccessToHtaccess($assocArgs);
22+
23+
$this->assertEquals($assocArgs['file-path'], $command->filePath);
24+
$this->assertEquals($assocArgs['server'], $command->serverType);
25+
$this->assertEquals($assocArgs['output'], $command->output);
26+
27+
$assocArgs = [];
28+
29+
$command = new BlockAccessToHtaccess($assocArgs);
30+
31+
$this->assertEquals('.htaccess', $command->filePath);
32+
$this->assertEquals('apache', $command->serverType);
33+
$this->assertFalse($command->output);
34+
}
35+
}

0 commit comments

Comments
 (0)