/**
  * @param Issue $issue
  * @param TaskStackUserInterface $user
  * @return array
  */
 public function createIssue(Issue $issue, TaskStackUserInterface $user)
 {
     if ($this->userExists($user)) {
         $user = $this->getUser($user);
     } else {
         $user = $this->createUser($user);
     }
     return $this->post('api/issues', ['subject' => $issue->getSubject(), 'description' => $issue->getDescription(), 'requester' => $user['username']]);
 }
 function it_can_create_an_issue_with_new_user(TaskstackUserInterface $user, Issue $issue, HttpAdapter $http)
 {
     $issue->getSubject()->willReturn('The issue subject');
     $issue->getDescription()->willReturn('The description of the issue');
     $expectedIssue = ['id' => '37ce5995-ffbe-11e4-9424-08002751e440', 'friendly_id' => '7H2T5', 'subject' => 'The issue subject', 'description' => 'The description of the issue', 'status' => 1, 'requester' => ['username' => 'BobReporter', 'email' => '*****@*****.**'], 'referenced_users' => [], 'opened' => '2015-05-21T14:35:17+0100', 'updated' => '2015-05-21T14:35:17+0100', 'messages' => [], 'attachments' => [], 'assigned' => false, 'tags' => []];
     $user->getEmail()->willReturn('*****@*****.**');
     $user->getUsername()->willReturn('NobbyNew');
     $user->getFullname()->willReturn('Nobby New');
     $http->get("api/users/new@test.com", [], ["api-key" => "mykey"])->willThrow('Symfony\\Component\\HttpKernel\\Exception\\HttpException');
     $http->post("api/users", ['username' => '*****@*****.**', 'email' => '*****@*****.**', 'fullname' => 'Nobby New'], ["api-key" => "mykey"])->willReturn(['username' => '*****@*****.**', 'email' => '*****@*****.**']);
     $http->post('api/issues', ['subject' => 'The issue subject', 'description' => 'The description of the issue', 'requester' => '*****@*****.**'], ["api-key" => "mykey"])->willReturn($expectedIssue);
     $this->createIssue($issue, $user)->shouldReturn($expectedIssue);
 }