public function testSetStoreMappings() { $timeTaken = 11; $memoryUsage = 22; $memoryUsed = 33; $options = array('my' => 'option'); $this->entity->setStoreMappings($timeTaken, $memoryUsage, $memoryUsed, $options); $result = $this->entity->toArray(); $this->assertArrayHasKey(JobStats::NAME_STORE_MAPPINGS, $result['data']); $data = $result['data'][JobStats::NAME_STORE_MAPPINGS]; $this->assertSame($timeTaken, $data['timeTaken']); $this->assertSame($memoryUsage, $data['memoryUsage']); $this->assertSame($memoryUsed, $data['memoryUsed']); $this->assertEquals($options, $data['options']); $this->assertContains(date('Y-m-d H:i:'), $data['createdAt']); }
/** * Stores mappings into filesystem * * @param BackupJob $job * @param JobStats $jobStats * @param OutputInterface $output * @author Daniel Wendlandt */ private function storeMappings(BackupJob $job, JobStats $jobStats, OutputInterface $output) { $memoryAtSection = memory_get_usage(); $timeStartSection = microtime(true); $mappingFilesCreated = $this->filesystem->storeMappings($job->getPath(), $job->getMappings()); $jobStats->setStoreMappings(microtime(true) - $timeStartSection, memory_get_usage(), memory_get_usage() - $memoryAtSection, array('mappingFilesCreated' => $mappingFilesCreated)); $output->writeln('<info>*** Stored ' . $mappingFilesCreated . ' mapping files ***</info>' . PHP_EOL); /** @var Index $index */ foreach ($job->getMappings()->getIndices() as $index) { /** @var Type $type */ foreach ($index->getTypes() as $type) { $output->writeln('<comment> - ' . $index->getName() . DIRECTORY_SEPARATOR . $type->getName() . FilesystemRepository::FILE_EXTENSION . '</comment>'); } } $output->writeln(''); }