/** * @group internet */ public function testClientsRetrieval() { $api = new HarvestAPI(); $config = file_exists(BASE_PATH . DIRECTORY_SEPARATOR . $_SERVER['API_CONFIG_FILE']) ? json_decode(file_get_contents(BASE_PATH . DIRECTORY_SEPARATOR . $_SERVER['API_CONFIG_FILE'])) : array(); if (!$config) { $this->markTestSkipped('No API config file present.'); } $api->setUser($config->user); $api->setPassword($config->password); $api->setAccount($config->account); /** @var \Harvest\Model\Result $result */ $result = $api->getClients(); $this->assertInstanceOf('\\Harvest\\Model\\Result', $result); $this->assertTrue($result->isSuccess()); $this->assertNotEmpty($result->get('headers')); $this->assertNotEmpty($result->get('data')); }
/** * Get project data for Redmine projects with Harvest IDs. * * @return array */ protected function getHarvestDataForProjects() { $project_data = []; foreach ($this->projectMap as $harvest_id => $project) { $project_names = []; foreach ($project as $key => $projects) { $project_names[] = current($projects); } $this->output->writeln(sprintf('<info>Getting data for Harvest project %d from project %s</info>', $harvest_id, implode(' - ', $project_names))); $project_data_result = $this->harvestClient->getProject($harvest_id); if ($project_data_result->get('code') !== 200) { $this->output->writeln(sprintf('- <error>Could not get project data for Harvest ID %d associated with Redmine project %s!', $harvest_id, implode(' - ', $project_names))); continue; } $project_data[] = $project_data_result; } return $project_data; }