public function testTestConnection() { $config = $this->getConfig(); $config['action'] = 'testConnection'; $app = new Application($config); $result = $app->run(); $this->assertEquals('success', $result['status']); }
use Keboola\DbExtractor\Application; use Keboola\DbExtractor\Configuration\FirebirdConfigDefinition; use Keboola\DbExtractor\Exception\ApplicationException; use Keboola\DbExtractor\Exception\UserException; use Symfony\Component\Yaml\Yaml; define('APP_NAME', 'ex-db-firebird'); define('ROOT_PATH', __DIR__); require_once dirname(__FILE__) . "/vendor/keboola/db-extractor-common/bootstrap.php"; $logger = new \Keboola\DbExtractor\Logger(APP_NAME); try { $arguments = getopt("d::", ["data::"]); if (!isset($arguments["data"])) { throw new UserException('Data folder not set.'); } $config = Yaml::parse(file_get_contents($arguments["data"] . "/config.yml")); $config['parameters']['data_dir'] = $arguments['data']; $config['parameters']['extractor_class'] = 'Firebird'; $app = new Application($config); $app->setConfigDefinition(new FirebirdConfigDefinition()); echo json_encode($app->run()); } catch (UserException $e) { $logger->log('error', $e->getMessage(), (array) $e->getData()); exit(1); } catch (ApplicationException $e) { $logger->log('error', $e->getMessage(), (array) $e->getData()); exit($e->getCode() > 1 ? $e->getCode() : 2); } catch (\Exception $e) { $logger->log('error', $e->getMessage(), ['errFile' => $e->getFile(), 'errLine' => $e->getLine(), 'trace' => $e->getTrace()]); exit(2); } exit(0);
<?php use Keboola\DbExtractor\Application; use Keboola\DbExtractor\Exception\ApplicationException; use Keboola\DbExtractor\Exception\UserException; use Symfony\Component\Yaml\Yaml; define('APP_NAME', 'ex-db-pgsql'); define('ROOT_PATH', __DIR__); require_once dirname(__FILE__) . "/vendor/keboola/db-extractor-common/bootstrap.php"; $logger = new \Keboola\DbExtractor\Logger(APP_NAME); try { $arguments = getopt("d::", ["data::"]); if (!isset($arguments["data"])) { throw new UserException('Data folder not set.'); } $config = Yaml::parse(file_get_contents($arguments["data"] . "/config.yml")); $config['parameters']['data_dir'] = $arguments['data']; $config['parameters']['extractor_class'] = 'PgSQL'; $app = new Application($config); echo json_encode($app->run()); } catch (UserException $e) { $logger->log('error', $e->getMessage(), (array) $e->getData()); exit(1); } catch (ApplicationException $e) { $logger->log('error', $e->getMessage(), (array) $e->getData()); exit($e->getCode() > 1 ? $e->getCode() : 2); } catch (\Exception $e) { $logger->log('error', $e->getMessage(), ['errFile' => $e->getFile(), 'errLine' => $e->getLine(), 'trace' => $e->getTrace()]); exit(2); } exit(0);
protected function runApp(Application $app) { $result = $app->run(); $expectedCsvFile = ROOT_PATH . '/tests/data/escaping.csv'; $outputCsvFile = $this->dataDir . '/out/tables/' . $result['imported'][0] . '.csv'; $outputManifestFile = $this->dataDir . '/out/tables/' . $result['imported'][0] . '.csv.manifest'; $this->assertEquals('success', $result['status']); $this->assertFileExists($outputCsvFile); $this->assertFileExists($outputManifestFile); $this->assertEquals(file_get_contents($expectedCsvFile), file_get_contents($outputCsvFile)); }