Ejemplo n.º 1
0
 /**
  * Authenticate to remote API
  * @return Redmine
  */
 protected function authenticate()
 {
     $redmine = new Redmine($this->redmineProtocol . $this->redmineUrl, $this->redmineToken);
     $redmine->setPort($this->redminePort);
     return $redmine;
 }
Ejemplo n.º 2
0
 /**
  * @covers Redmine\Client
  * @test
  */
 public function testPrepareJsonPostRequestWithHttpUsername()
 {
     // Create the object under test
     $client = new Client('http://test.local', 'USER_API-KEY159');
     $client->setPort(8080);
     // Perform the tests
     $data = array(1 => 'post_1', '25' => 'post_25');
     $client->prepareRequest('/issues.json', 'POST', $data);
     $curlOptions = $client->getCurlOptions();
     $this->assertRegExp('/USER_API-KEY159\\:[0-9]*/', $curlOptions[CURLOPT_USERPWD]);
     $this->assertSame(CURLAUTH_BASIC, $curlOptions[CURLOPT_HTTPAUTH]);
     $this->assertSame('http://test.local/issues.json', $curlOptions[CURLOPT_URL]);
     $this->assertSame(0, $curlOptions[CURLOPT_VERBOSE]);
     $this->assertSame(0, $curlOptions[CURLOPT_HEADER]);
     $this->assertSame(1, $curlOptions[CURLOPT_RETURNTRANSFER]);
     $this->assertSame(8080, $curlOptions[CURLOPT_PORT]);
     $this->assertContains('Expect: ', $curlOptions[CURLOPT_HTTPHEADER]);
     $this->assertContains('Content-Type: application/json', $curlOptions[CURLOPT_HTTPHEADER]);
     $this->assertContains('X-Redmine-API-Key: USER_API-KEY159', $curlOptions[CURLOPT_HTTPHEADER]);
     $this->assertSame(1, $curlOptions[CURLOPT_POST]);
     $this->assertSame($data, $curlOptions[CURLOPT_POSTFIELDS]);
 }