Example #1
0
 public function testCreateOauth2Login()
 {
     $ymlConfig = YamlFile::create(ROOT_PATH . '/tests/data/oauth20login/config.yml');
     $config = new Config('testApp', 'testCfg', []);
     $api = $ymlConfig->get('parameters', 'api');
     $authorization = $ymlConfig->get('authorization');
     $oauth = Api::createAuth($api, $config, $authorization);
     self::assertInstanceOf('\\Keboola\\GenericExtractor\\Authentication\\OAuth20Login', $oauth);
 }
 /**
  * No change to JSON parser structure should happen when nothing is parsed!
  */
 public function testRunMetadataUpdate()
 {
     $logger = $this->getLogger('test', true);
     Logger::setLogger($logger);
     $meta = ['json_parser.struct' => ['tickets.via' => ['channel' => 'scalar', 'source' => 'object']], 'time' => ['previousStart' => 123]];
     $cfg = new Config('testApp', 'testCfg', []);
     $api = Api::create(['baseUrl' => 'http://example.com'], $cfg);
     $ex = new GenericExtractor(new Temp());
     $ex->setLogger($logger);
     $ex->setApi($api);
     $ex->setMetadata($meta);
     $ex->run($cfg);
     $after = $ex->getMetadata();
     self::assertEquals($meta['json_parser.struct'], $after['json_parser.struct']);
     self::assertArrayHasKey('time', $after);
 }
 /**
  * @param Api $api
  */
 public function setApi(Api $api)
 {
     $this->setBaseUrl($api->getBaseUrl());
     $this->setAuth($api->getAuth());
     $this->setScroller($api->getScroller());
     $this->setHeaders($api->getHeaders()->getHeaders());
     $this->setAppName($api->getName());
     $this->setDefaultRequestOptions($api->getDefaultRequestOptions());
     $this->setRetryConfig($api->getRetryConfig());
 }