getFileManager()->removeFile($this->filePath1); $this->getFileManager()->removeFile($this->filePath2); parent::tearDown(); } /** * @throws \Espo\Core\Exceptions\Error */ public function testAppend1() { $initial = $this->getMetadata()->get(['app', 'rebuild', 'actionClassNameList']); $contents1 = Json::encode( (object) [ 'actionClassNameList' => [ "\\Espo\\Core\\Rebuild\\Actions\\ScheduledJobs", ] ] ); $contents2 = Json::encode( (object) [ 'readLoaderClassNameList' => [ "\\Espo\\Classes\\FieldProcessing\\Note\\AttachmentsLoader", ] ] ); $this->createDirForFile($this->filePath1); $this->getFileManager()->putContents($this->filePath1, $contents1); $this->getFileManager()->putContents($this->filePath2, $contents2); $this->getDataManager()->clearCache(); $app = $this->createApplication(); /** @var Metadata $metadata */ $metadata = $app->getContainer()->get('metadata'); $this->assertSame( array_merge( $initial, ["\\Espo\\Core\\Rebuild\\Actions\\ScheduledJobs"] ), $metadata->get(['app', 'rebuild', 'actionClassNameList']) ); $this->assertSame( [ "Espo\\Classes\\FieldProcessing\\Note\\AttachmentsLoader", "\\Espo\\Classes\\FieldProcessing\\Note\\AttachmentsLoader", ], $metadata->get(['recordDefs', 'Note', 'readLoaderClassNameList']) ); $this->getFileManager()->removeFile($this->filePath1); $this->getFileManager()->removeFile($this->filePath2); $this->getDataManager()->clearCache(); } private function createDirForFile(string $filePath): void { $prevFolder = ''; foreach (array_slice(explode('/', $filePath), 0, -1) as $folder) { $prevFolder .= $folder . '/'; $this->getFileManager()->mkdir(substr($prevFolder, 0, -1)); } } }