Ejemplo n.º 1
0
 /**
  * Test update()
  *
  * @covers ::put
  * @covers ::update
  * @test
  *
  * @return void
  */
 public function testUpdateCallsPut()
 {
     // Test values
     $getResponse = 'API Response';
     $parameters = array('hours' => '10.25');
     // Create the used mock objects
     $client = $this->getMockBuilder('Redmine\\Client')->disableOriginalConstructor()->getMock();
     $client->expects($this->once())->method('put')->with('/time_entries/5.xml', $this->logicalAnd($this->stringStartsWith('<?xml version="1.0"?>' . "\n" . '<time_entry>'), $this->stringEndsWith('</time_entry>' . "\n"), $this->stringContains('<hours>10.25</hours>')))->willReturn($getResponse);
     // Create the object under test
     $api = new TimeEntry($client);
     // Perform the tests
     $this->assertSame($getResponse, $api->update(5, $parameters));
 }
Ejemplo n.º 2
0
 /**
  * Saves a harvest entry to Redmine, or updates an existing one if it exists.
  *
  * @param array $redmine_time_entry_params
  * @param array $existing_redmine_time_entries
  *
  * @return bool
  */
 protected function saveHarvestTimeEntryToRedmine(array $redmine_time_entry_params, array $existing_redmine_time_entries)
 {
     $time_entry_api = new Redmine\Api\TimeEntry($this->redmineClient);
     if (count($existing_redmine_time_entries) === 0) {
         $time_entry_api->create($redmine_time_entry_params);
     } else {
         // Update existing entry.
         $time_entry_api->update($existing_redmine_time_entries[0]['id'], $redmine_time_entry_params);
     }
     return true;
 }
Ejemplo n.º 3
0
 /**
  * Test update().
  *
  * @covers ::put
  * @covers ::update
  * @test
  */
 public function testUpdateCallsPut()
 {
     // Test values
     $getResponse = 'API Response';
     $parameters = array('hours' => '10.25', 'custom_fields' => array(array('id' => 1, 'name' => 'Affected version', 'value' => '1.0.1'), array('id' => 2, 'name' => 'Resolution', 'value' => 'Fixed')));
     // Create the used mock objects
     $client = $this->getMockBuilder('Redmine\\Client')->disableOriginalConstructor()->getMock();
     $client->expects($this->once())->method('put')->with('/time_entries/5.xml', $this->logicalAnd($this->stringStartsWith('<?xml version="1.0"?>' . "\n" . '<time_entry>'), $this->stringEndsWith('</time_entry>' . "\n"), $this->stringContains('<hours>10.25</hours>'), $this->stringContains('<custom_fields type="array"><custom_field name="Affected version" id="1"><value>1.0.1</value></custom_field><custom_field name="Resolution" id="2"><value>Fixed</value></custom_field></custom_fields>')))->willReturn($getResponse);
     // Create the object under test
     $api = new TimeEntry($client);
     // Perform the tests
     $this->assertSame($getResponse, $api->update(5, $parameters));
 }