Ejemplo n.º 1
0
 /**
  * Test all()
  *
  * @covers ::all
  * @test
  *
  * @return void
  */
 public function testAllReturnsClientGetResponseWithParameters()
 {
     // Test values
     $parameters = array('project_id' => 5, 'user_id' => 10, 'limit' => 2);
     $getResponse = array('API Response');
     // Create the used mock objects
     $client = $this->getMockBuilder('Redmine\\Client')->disableOriginalConstructor()->getMock();
     $client->expects($this->any())->method('get')->with($this->logicalAnd($this->stringStartsWith('/time_entries.json?'), $this->stringContains('project_id=5'), $this->stringContains('user_id=10'), $this->stringContains('limit=2')))->willReturn($getResponse);
     // Create the object under test
     $api = new TimeEntry($client);
     // Perform the tests
     $this->assertSame($getResponse, $api->all($parameters));
 }
Ejemplo n.º 2
0
 /**
  * Get Redmine time entries matching a harvest entry.
  *
  * @param array                   $redmine_issue
  * @param \Harvest\Model\DayEntry $harvest_entry
  *
  * @return array
  */
 protected function getExistingRedmineIssueTimeEntries(array $redmine_issue, DayEntry $harvest_entry)
 {
     $redmine_search_params = ['issue_id' => $redmine_issue['issue']['id'], 'limit' => 10000];
     $this->setRedmineClient();
     $time_entry_api = new Redmine\Api\TimeEntry($this->redmineClient);
     $redmine_time_entries = $time_entry_api->all($redmine_search_params);
     $matching_entries = [];
     if (isset($redmine_time_entries['total_count']) && $redmine_time_entries['total_count'] > 0) {
         // There might be a match.
         foreach ($redmine_time_entries['time_entries'] as $redmine_time_entry) {
             // TODO: There should always be a comment in the time entry,
             // but this is not the case for time entry ID 3494 and others.
             if (isset($redmine_time_entry['comments']) && strpos($redmine_time_entry['comments'], $harvest_entry->get('id')) !== false) {
                 $matching_entries[] = $redmine_time_entry;
             }
         }
     }
     return $matching_entries;
 }