Exemplo n.º 1
0
 /**
  * Write one data item
  *
  * @param array $item The data item with converted values
  *
  * @return $this
  */
 public function writeItem(array $item)
 {
     // TODO: Implement writeItem() method.
     $project = $item["project"];
     $summary = $item["summary"];
     $description = $item["description"];
     $jar = new FileCookieJar("cookies.json");
     $client = new Client();
     $cookie = $jar->all()[0];
     $domain = $cookie->getDomain();
     $path = $cookie->getPath();
     $request = $client->put("http://" . $domain . $path . "/rest/issue", array(), ["project" => $project, "summary" => $summary, "description" => $description]);
     foreach ($jar->all() as $cookie) {
         $request->addCookie($cookie->getName(), $cookie->getValue());
     }
     $response = $request->send();
     if ($response->getStatusCode() == 201) {
         echo "Successfully created the issue [" . $summary . "].\n";
     } else {
         echo "Something went wrong with [" . $summary . "]\n";
     }
 }
 public function testLoadsFromFileFile()
 {
     $jar = new FileCookieJar($this->file);
     $this->assertEquals(array(), $jar->all());
     unlink($this->file);
 }