/** * @param string|null $fileLocation * * @SuppressWarnings(PHPMD.StaticAccess) */ protected function buildRegister($fileLocation = null) { $vendorDir = $this->composer->getConfig()->get('vendor-dir'); $modules = []; foreach (glob("{$vendorDir}/{*/**,\\.\\.}/masonry.y{a,}ml", GLOB_BRACE) as $masonryConfig) { try { $modules[] = YamlWorkerModuleDefinition::load($masonryConfig); $this->inputOutput->write("<info>Added module:</info> {$masonryConfig}"); } catch (\Exception $e) { $this->inputOutput->writeError("<error>Invalid module:</error> {$masonryConfig}"); $this->inputOutput->writeError("== {$e->getMessage()}"); } } $register = new ModuleRegister($fileLocation); $register->addWorkerModules($modules); $register->save(); }
/** * @test * @covers ::save * @uses \Foundry\Masonry\ModuleRegister\ModuleRegister::toArray */ public function testSave() { $registerFile = 'register.yaml'; $vfs = vfsStream::setup('root'); $register = new ModuleRegister($vfs->url() . '/' . $registerFile); $this->assertFalse($vfs->hasChild($registerFile)); $register->save(); $this->assertTrue($vfs->hasChild($registerFile)); }