Magento 2 Documentation  2.3
Documentation for Magento 2 CMS v2.3 (December 2018)
InfoBackupsListCommandTest.php
Go to the documentation of this file.
1 <?php
8 
10 use Symfony\Component\Console\Tester\CommandTester;
11 
12 class InfoBackupsListCommandTest extends \PHPUnit\Framework\TestCase
13 {
14  public function testExecute()
15  {
16  $table = $this->createMock(\Symfony\Component\Console\Helper\Table::class);
17  $table->expects($this->once())->method('setHeaders')->with(['Backup Filename', 'Backup Type']);
18  $table->expects($this->once())->method('addRow')->with(['backupFile_media.tgz', 'media']);
20  $tableFactoryMock = $this->createMock(\Symfony\Component\Console\Helper\TableFactory::class);
21  $tableFactoryMock->expects($this->once())->method('create')->will($this->returnValue($table));
25  $directoryList = $this->createMock(\Magento\Framework\App\Filesystem\DirectoryList::class);
27  $file = $this->createMock(\Magento\Framework\Filesystem\Driver\File::class);
28  $file->expects($this->once())->method('isExists')->will($this->returnValue(true));
29  $file->expects($this->once())
30  ->method('readDirectoryRecursively')
31  ->will($this->returnValue(['backupFile_media.tgz']));
32  $command = new InfoBackupsListCommand($directoryList, $file, $tableFactoryMock);
33  $commandTester = new CommandTester($command);
34  $commandTester->execute([]);
35  $expected = 'Showing backup files in ';
36  $this->assertStringStartsWith($expected, $commandTester->getDisplay());
37  }
38 }
$table
Definition: trigger.php:14