示例#1
0
 /**
  * @covers Redmine\Client
  * @test
  */
 public function testGetAndSetCurlOptions()
 {
     $client = new Client('http://test.local', 'asdf');
     $this->assertSame(array(), $client->getCurlOptions());
     $this->assertInstanceOf('Redmine\\Client', $client->setCurlOption(15, 'value'));
     $this->assertSame(array(15 => 'value'), $client->getCurlOptions());
 }
示例#2
0
 /**
  * @covers Redmine\Client
  * @test
  */
 public function testPrepareXmlPutRequestWithHttpUsernameAndPassword()
 {
     // Create the object under test
     $client = new Client('http://test.local', 'username', 'secret');
     // Perform the tests
     $data = array(1 => 'post_1', '25' => 'post_25');
     $client->setCurlOption(CURLOPT_PROXY, 'PROXYURL:PORT');
     $client->prepareRequest('/issues.xml', 'PUT', $data);
     $curlOptions = $client->getCurlOptions();
     $this->assertRegExp('/username\\:secret/m', $curlOptions[CURLOPT_USERPWD]);
     $this->assertSame('PROXYURL:PORT', $curlOptions[CURLOPT_PROXY]);
     $this->assertSame(CURLAUTH_BASIC, $curlOptions[CURLOPT_HTTPAUTH]);
     $this->assertSame('http://test.local/issues.xml', $curlOptions[CURLOPT_URL]);
     $this->assertSame(0, $curlOptions[CURLOPT_VERBOSE]);
     $this->assertSame(0, $curlOptions[CURLOPT_HEADER]);
     $this->assertSame(1, $curlOptions[CURLOPT_RETURNTRANSFER]);
     $this->assertSame(80, $curlOptions[CURLOPT_PORT]);
     $this->assertContains('Expect: ', $curlOptions[CURLOPT_HTTPHEADER]);
     $this->assertContains('Content-Type: text/xml', $curlOptions[CURLOPT_HTTPHEADER]);
     $this->assertNotContains('X-Redmine-API-Key: username', $curlOptions[CURLOPT_HTTPHEADER]);
     $this->assertNotContains('X-Redmine-API-Key: secret', $curlOptions[CURLOPT_HTTPHEADER]);
     $this->assertSame('PUT', $curlOptions[CURLOPT_CUSTOMREQUEST]);
     $this->assertSame($data, $curlOptions[CURLOPT_POSTFIELDS]);
 }