1 | <?php |
||
2 | |||
3 | namespace wapmorgan\UnifiedArchive\Commands; |
||
4 | |||
5 | use Symfony\Component\Console\Input\InputArgument; |
||
6 | use Symfony\Component\Console\Input\InputInterface; |
||
7 | use Symfony\Component\Console\Output\OutputInterface; |
||
8 | |||
9 | class TestCommand extends BaseArchiveCommand |
||
10 | { |
||
11 | protected static $defaultName = 'files:test'; |
||
12 | |||
13 | protected function configure() |
||
14 | { |
||
15 | parent::configure(); |
||
16 | $this |
||
17 | ->setDescription('Tests archive contents') |
||
18 | ->setHelp('Tests archive contents.') |
||
19 | ->addArgument('filter', InputArgument::OPTIONAL, 'Files filter (as for fnmatch). If no * passed in filter, it will be added at the end of filter') |
||
20 | ; |
||
21 | } |
||
22 | |||
23 | public function execute(InputInterface $input, OutputInterface $output) |
||
24 | { |
||
25 | $archive = $this->getArchive($input, $output); |
||
26 | $files = $archive->getFiles($input->getArgument('filter')); |
||
0 ignored issues
–
show
Bug
introduced
by
Loading history...
|
|||
27 | |||
28 | $errored = []; |
||
29 | foreach ($files as $file) { |
||
30 | $output->write($file . ' ... '); |
||
31 | if ($archive->test($file, $hash) === true) { |
||
32 | $output->writeln('<info>ok</info>'); |
||
33 | } else { |
||
34 | $errored[] = $file; |
||
35 | $output->writeln('<error>error</error>'); |
||
36 | var_dump($hash[$file]); |
||
0 ignored issues
–
show
|
|||
37 | } |
||
38 | } |
||
39 | |||
40 | if (!empty($errored)) { |
||
41 | return 1; |
||
42 | } |
||
43 | |||
44 | return 0; |
||
45 | } |
||
46 | } |
||
47 |