コード例 #1
0
 /**
  * Test update()
  *
  * @covers ::put
  * @covers ::update
  * @covers ::attachCustomFieldXML
  * @test
  *
  * @return void
  */
 public function testUpdateWithCustomField()
 {
     // Test values
     $getResponse = 'API Response';
     $parameters = array('custom_fields' => array(array('id' => 5, 'value' => 'Value 5'), array('id' => 13, 'value' => 'Value 13', 'name' => 'CF Name')));
     // Create the used mock objects
     $client = $this->getMockBuilder('Redmine\\Client')->disableOriginalConstructor()->getMock();
     $client->expects($this->once())->method('put')->with('/users/5.xml', $this->logicalAnd($this->stringStartsWith('<?xml version="1.0"?>' . "\n" . '<user>'), $this->stringEndsWith('</user>' . "\n"), $this->stringContains('<custom_fields type="array">'), $this->stringContains('</custom_fields>'), $this->stringContains('<custom_field name="CF Name" id="13">'), $this->stringContains('<value>Value 13</value>'), $this->stringContains('<custom_field id="5">'), $this->stringContains('<value>Value 5</value>'), $this->stringContains('</custom_field>')))->willReturn($getResponse);
     // Create the object under test
     $api = new User($client);
     // Perform the tests
     $this->assertSame($getResponse, $api->update(5, $parameters));
 }