public function storeMetaData(RestoreJob $job, JobStats $jobStats, array $storedStats, OutputInterface $output) { $memoryAtSection = memory_get_usage(); $timeStartSection = microtime(true); $output->writeln('<info>*** Starting with meta data storing ***</info>' . PHP_EOL); $this->filesystem->storeRestoreServerInfo($job->getPath(), $job->getCreatedAt(), $job->getServerInfo()); $output->writeln('<comment> - Stored server-info file</comment>' . PHP_EOL); $this->filesystem->storeRestoreStoredStats($job->getPath(), $job->getCreatedAt(), $storedStats); $output->writeln('<comment> - Stored stored-stats file</comment>' . PHP_EOL); $output->writeln(''); $jobStats->setStoreMetaData(microtime(true) - $timeStartSection, memory_get_usage(), memory_get_usage() - $memoryAtSection, array('storedStats' => $storedStats)); }
public function testStoreRestoreServerInfoNotExistingFolder() { $path = '/tmp/test-path'; $datetimeString = '20151006100005_'; /** @var \PHPUnit_Framework_MockObject_MockObject $dateTime */ $dateTime = $this->getMockBuilder('DateTime')->disableOriginalConstructor()->getMock(); $dateTime->expects($this->once())->method('format')->with('YmdHis_')->willReturn($datetimeString); $folderpath = $path . DIRECTORY_SEPARATOR . FilesystemRepositoryInterface::DIR_META . DIRECTORY_SEPARATOR . $datetimeString . FilesystemRepositoryInterface::DIR_SUB_RESTORE; $filepath = $folderpath . DIRECTORY_SEPARATOR . FilesystemRepositoryInterface::FILENAME_SERVER_INFO . FilesystemRepositoryInterface::FILE_EXTENSION; $serverInfo = new ServerInfo(); $serverInfo->clusterName = 'my-cluster'; $serverInfo->name = 'my-name'; $serverInfo->version = '1.6.0'; $this->filesystem->expects($this->once())->method('exists')->with($folderpath)->willReturn(false); $this->filesystem->expects($this->once())->method('mkdir')->with($folderpath); $this->filesystem->expects($this->once())->method('dumpFile')->with($filepath, json_encode($serverInfo)); $this->filesystemRepository->storeRestoreServerInfo($path, $dateTime, $serverInfo); }