/** * Execute the install command * * @param InputInterface $input An InputInterface instance * @param OutputInterface $output An OutputInterface instance * * @return integer 0 if everything went fine, 1 on error */ protected function execute(InputInterface $input, OutputInterface $output) { $this->setupEnvironment($input, $output); try { $arguments = $input->getArguments(); $installer = new Installer(JPATH_ROOT . "/data", $this->container); $count = 0; foreach ($arguments['extension'] as $extension) { $source = realpath($extension); if (!file_exists($source)) { $this->writeln($output, "Unable to locate {$extension}", OutputInterface::VERBOSITY_NORMAL); continue; } $this->writeln($output, " - installing {$extension}", OutputInterface::VERBOSITY_VERBOSE); $entityNames = $installer->install($source); foreach ($entityNames as $entityName) { $this->writeln($output, " - {$entityName}", OutputInterface::VERBOSITY_VERY_VERBOSE); } $count++; } $this->writeln($output, " - finishing", OutputInterface::VERBOSITY_VERY_VERBOSE); $installer->finish(); $this->writeln($output, "Installed {$count} extension(s)", OutputInterface::VERBOSITY_NORMAL); return 0; } catch (\Exception $e) { $this->writeln($output, $e->getMessage() . "\n\n" . $e->getTraceAsString()); return 1; } }
/** * @testdox hasOne and HasMany relations from one entity create a belongsTo relationship on the other. */ public function testResolveHasOneOrHasMany() { $this->installer->install(__DIR__ . '/data/ext_article'); $this->installer->install(__DIR__ . '/data/ext_category'); $this->installer->finish(); $originalStructure = $this->getStructureFromFile(__DIR__ . '/data/ext_article/entities/Article.xml'); $this->assertFalse(in_array('category_id', $originalStructure['relations']['belongsTo'])); $cachedStructure = $this->getStructureFromFile($this->dataDirectory . '/entities/Article.xml'); $this->assertTrue(in_array('category_id', $cachedStructure['relations']['belongsTo'])); }