public function testGetMemberProjects()
 {
     $user = Utils::addUser();
     $resp = Utils::getBuddy()->getApiMembers()->getWorkspaceMemberProjects(Utils::getWorkspaceDomain(), $user->getId());
     $this->assertInstanceOf('Buddy\\Objects\\Projects', $resp);
     $this->assertNotEmpty($resp->getUrl());
     $this->assertEquals(0, count($resp->getProjects()));
 }
 public function testAddAndDeleteEmail()
 {
     $email = new Email();
     $email->setEmail(Utils::randomEmail());
     $resp = Utils::getBuddy()->getApiEmails()->addAuthenticatedUserEmail($email);
     $this->assertInstanceOf('Buddy\\Objects\\Email', $resp);
     $resp = Utils::getBuddy()->getApiEmails()->deleteAuthenticatedUserEmail($email->getEmail());
     $this->assertEquals(true, $resp);
 }
 public function testUpdateUser()
 {
     $user = new User();
     $user->setTitle(Utils::randomString());
     $user->setName(Utils::randomString());
     $resp = Utils::getBuddy()->getApiProfile()->editAuthenticatedUser($user);
     $this->assertInstanceOf('Buddy\\Objects\\User', $resp);
     $this->assertEquals($user->getName(), $resp->getName());
     $this->assertEquals($user->getTitle(), $resp->getTitle());
 }
 public function testDeleteFile()
 {
     $project = Utils::addProject();
     $content = Utils::addFile($project);
     $delFile = new SourceContent();
     $delFile->setMessage('AAA');
     $delFile->setBranch($content->getContent()->getBranch());
     $resp = Utils::getBuddy()->getApiSource()->deleteFile($delFile, Utils::getWorkspaceDomain(), $project->getName(), $content->getContent()->getPath());
     $this->assertInstanceOf('Buddy\\Objects\\Commit', $resp);
 }
 public function testDeleteBranch()
 {
     $project = Utils::addProject();
     $file = Utils::addFile($project);
     $branch = new Branch();
     $branch->setName(Utils::randomString());
     $branch->setCommit($file->getCommit());
     $branch = Utils::getBuddy()->getApiBranches()->addBranch($branch, Utils::getWorkspaceDomain(), $project->getName());
     $resp = Utils::getBuddy()->getApiBranches()->deleteBranch(Utils::getWorkspaceDomain(), $project->getName(), $branch->getName());
     $this->assertEquals(true, $resp);
 }
 public function testCompare()
 {
     $project = Utils::addProject();
     $oldFile = Utils::addFile($project);
     $file = Utils::addFile($project);
     $resp = Utils::getBuddy()->getApiCommits()->getCompare(Utils::getWorkspaceDomain(), $project->getName(), $oldFile->getCommit()->getRevision(), $file->getCommit()->getRevision());
     $this->assertInstanceOf('Buddy\\Objects\\CompareCommits', $resp);
     $this->assertInstanceOf('Buddy\\Objects\\Commit', $resp->getBaseCommit());
     $this->assertInternalType('array', $resp->getCommits());
     $this->assertEquals(0, $resp->getAhead());
     $this->assertEquals(1, $resp->getBehind());
 }
 public function testAddGetDeleteKey()
 {
     $key = new SshKey();
     $key->setContent('ssh-rsa AAAAB3NzaC1yc2EAAAADAQABAAAAgQCG0Ug3U8DoJ6+z36D2h2+oc4UoQRihLNGcAO9SHglFXp+dn1aGJrqeoOrmo4bj5AcydjY33Ylm7ixZEe85vD5INCeldMd8JGmZTj57mwzqpKXFrag+/v9F9qmSEPxKZ1cQj7Q/nRi/hJIoJbsxymrxWhdJZnDNeqwdusR78Xkftw== scot@scot-Macmini');
     $key->setTitle('Test');
     $resp = Utils::getBuddy()->getApiSshKeys()->addAuthenticatedUserKey($key);
     $this->assertInstanceOf('Buddy\\Objects\\SshKey', $resp);
     $this->assertEquals($key->getContent(), $resp->getContent());
     $this->assertEquals($key->getTitle(), $resp->getTitle());
     $this->assertGreaterThan(0, $resp->getId());
     $resp2 = Utils::getBuddy()->getApiSshKeys()->getAuthenticatedUserKey($resp->getId());
     $this->assertEquals($key->getContent(), $resp2->getContent());
     $this->assertEquals($key->getTitle(), $resp2->getTitle());
     $this->assertEquals($resp->getId(), $resp2->getId());
     $resp3 = Utils::getBuddy()->getApiSshKeys()->deleteAuthenticatedUserKey($resp2->getId());
     $this->assertEquals(true, $resp3);
 }
 /**
  * @return Webhook
  */
 public static function addWebhook()
 {
     $webhook = new Webhook();
     $webhook->setTargetUrl('http://onet.pl');
     $webhook->setEvents([Webhook::EVENT_RELEASE_FAILED]);
     return Utils::getBuddy()->getApiWebhooks()->addWebhook($webhook, Utils::getWorkspaceDomain());
 }
 public function testDeleteGroupMember()
 {
     $group = Utils::addGroup();
     $user = Utils::addUser();
     Utils::addUser2Group($group, $user);
     $resp = Utils::getBuddy()->getApiGroups()->deleteGroupMember(Utils::getWorkspaceDomain(), $group->getId(), $user->getId());
     $this->assertEquals(true, $resp);
 }
 /**
  * @expectedException \Buddy\Exceptions\BuddyResponseException
  */
 public function testRetryRelease()
 {
     Utils::getBuddy()->getApiReleases()->retryRelease(Utils::getWorkspaceDomain(), 'test', 1, 1);
 }
 /**
  * @expectedException \Buddy\Exceptions\BuddySDKException
  * @expectedExceptionMessage PermissionSet must be set
  */
 public function testAddProjectMemberWithoutPermission()
 {
     Utils::getBuddy()->getApiProjects()->addProjectMember(new User(), Utils::getWorkspaceDomain(), 'test');
 }
 /**
  * @expectedException \Buddy\Exceptions\BuddyResponseException
  */
 public function testGetTag()
 {
     $project = Utils::addProject();
     Utils::getBuddy()->getApiTags()->getTag(Utils::getWorkspaceDomain(), $project->getName(), 'test');
 }
 /**
  * @expectedException \Buddy\Exceptions\BuddyResponseException
  */
 public function testGetScenarioAction()
 {
     Utils::getBuddy()->getApiScenarios()->getScenarioAction(Utils::getWorkspaceDomain(), 'test', 1, 1);
 }
 public function testDeletePermission()
 {
     $perm = Utils::addPermission();
     $resp = Utils::getBuddy()->getApiPermissions()->deleteWorkspacePermission(Utils::getWorkspaceDomain(), $perm->getId());
     $this->assertEquals(true, $resp);
 }
 public function testEditWebhookOnlyTargetUrl()
 {
     $wh = Utils::addWebhook();
     $wh->setTargetUrl('http://wp.pl');
     $resp = Utils::getBuddy()->getApiWebhooks()->editWebhook($wh, Utils::getWorkspaceDomain(), $wh->getId());
     $this->assertInstanceOf('Buddy\\Objects\\Webhook', $resp);
     $this->assertEquals($wh->getTargetUrl(), $resp->getTargetUrl());
     $this->assertEquals($wh->getSecretKey(), $resp->getSecretKey());
     $this->assertEquals($wh->getProjectFilter(), $resp->getProjectFilter());
     $events = $resp->getEvents();
     $this->assertInternalType('array', $events);
     $this->assertEquals(1, count($events));
     $this->assertEquals(Webhook::EVENT_RELEASE_FAILED, $events[0]);
 }