示例#1
0
 /**
  * Tests the getters and setters of the model
  * @test
  */
 public function setGetTest()
 {
     $id = "This a weird test";
     $this->_model = new Request\Client();
     $this->_model->setId($id);
     $this->_model->setFilter(array('count' => 1));
     $this->assertEquals($this->_model->getId(), $id);
     $this->assertEquals($this->_model->getServiceResource(), "clients/");
     $this->assertEquals($this->_model->getFilter(), array('count' => 1));
     return $this->_model;
 }
示例#2
0
 /**
  * @test
  * @codeCoverageIgnore
  * @depends createClient
  * @depends getOneClient
  * @depends updateClient
  */
 public function deleteClient($model)
 {
     $this->_model->setId($model->getId());
     $this->markTestIncomplete('Client does not return a empty array like the other resources.');
     $result = $this->_service->delete($this->_model);
     $this->assertInternalType('array', $result, var_export($result, true));
 }
示例#3
0
 /**
  * Test the Parameterize function of the model
  * @test
  * @depends setGetTest
  * @param \Paymill\Models\Request\Client $client
  */
 public function parameterizeTest($client)
 {
     $testId = "client_88a388d9dd48f86c3136";
     $client->setId($testId);
     $creationArray = $client->parameterize("create");
     $updateArray = $client->parameterize("update");
     $getOneArray = $client->parameterize("getOne");
     $this->assertEquals($creationArray, array('email' => "*****@*****.**", 'description' => "Lovely Client"));
     $this->assertEquals($updateArray, array('email' => '*****@*****.**', 'description' => 'Lovely Client'));
     $this->assertEquals($getOneArray, array('count' => 1, 'offset' => 0));
 }
示例#4
0
 public function deleteById($clientId)
 {
     $clientData = UbirimiContainer::get()['repository']->get(UbirimiClient::class)->getById($clientId);
     $query = "SET FOREIGN_KEY_CHECKS = 0;";
     UbirimiContainer::get()['db.connection']->query($query);
     // delete Yongo Product data
     $projects = UbirimiContainer::get()['repository']->get(UbirimiClient::class)->getProjects($clientId);
     while ($projects && ($project = $projects->fetch_array(MYSQLI_ASSOC))) {
         UbirimiContainer::get()['repository']->get(YongoProject::class)->deleteById($project['id']);
     }
     $workflows = UbirimiContainer::get()['repository']->get(Workflow::class)->getByClientId($clientId);
     while ($workflows && ($workflow = $workflows->fetch_array(MYSQLI_ASSOC))) {
         UbirimiContainer::get()['repository']->get(Workflow::class)->deleteById($workflow['id']);
     }
     UbirimiContainer::get()['repository']->get(NotificationScheme::class)->deleteByClientId($clientId);
     $screens = UbirimiContainer::get()['repository']->get(Screen::class)->getByClientId($clientId);
     while ($screens && ($screen = $screens->fetch_array(MYSQLI_ASSOC))) {
         UbirimiContainer::get()['repository']->get(Screen::class)->deleteById($screen['id']);
     }
     UbirimiContainer::get()['repository']->get(NotificationScheme::class)->deleteByClientId($clientId);
     UbirimiContainer::get()['repository']->get(UbirimiClient::class)->deleteYongoIssueTypes($clientId);
     UbirimiContainer::get()['repository']->get(UbirimiClient::class)->deleteYongoIssueStatuses($clientId);
     UbirimiContainer::get()['repository']->get(UbirimiClient::class)->deleteYongoIssueResolutions($clientId);
     UbirimiContainer::get()['repository']->get(UbirimiClient::class)->deleteYongoIssuePriorities($clientId);
     UbirimiContainer::get()['repository']->get(Field::class)->deleteByClientId($clientId);
     UbirimiContainer::get()['repository']->get(FieldConfiguration::class)->deleteByClientId($clientId);
     UbirimiContainer::get()['repository']->get(FieldConfigurationScheme::class)->deleteByClientId($clientId);
     UbirimiContainer::get()['repository']->get(NotificationScheme::class)->deleteByClientId($clientId);
     UbirimiContainer::get()['repository']->get(NotificationScheme::class)->deleteByClientId($clientId);
     UbirimiContainer::get()['repository']->get(IssueTypeScheme::class)->deleteByClientId($clientId);
     UbirimiContainer::get()['repository']->get(IssueTypeScreenScheme::class)->deleteByClientId($clientId);
     // delete issue security schemes
     $issueSecuritySchemes = UbirimiContainer::get()['repository']->get(IssueSecurityScheme::class)->getByClientId($clientId);
     while ($issueSecuritySchemes && ($issueSecurityScheme = $issueSecuritySchemes->fetch_array(MYSQLI_ASSOC))) {
         UbirimiContainer::get()['repository']->get(IssueSecurityScheme::class)->deleteById($issueSecurityScheme['id']);
     }
     $users = UbirimiContainer::get()['repository']->get(UbirimiClient::class)->getUsers($clientId);
     if ($users) {
         $userIdsArray = array();
         while ($user = $users->fetch_array(MYSQLI_ASSOC)) {
             $userIdsArray[] = $user['id'];
             // delete user avatars
             $spaceBasePath = Util::getAssetsFolder(SystemProduct::SYS_PRODUCT_GENERAL_SETTINGS, 'user_avatars');
             Util::deleteDir($spaceBasePath . $user['id']);
         }
         $users_ids_string = implode($userIdsArray, ', ');
         $query = 'delete from general_group_data where user_id IN (' . $users_ids_string . ')';
         UbirimiContainer::get()['db.connection']->query($query);
         $query = 'delete from permission_role_data where default_user_id IN (' . $users_ids_string . ')';
         UbirimiContainer::get()['db.connection']->query($query);
     }
     UbirimiContainer::get()['repository']->get(UbirimiClient::class)->deleteGroups($clientId);
     $query = 'delete from permission_role where client_id = ' . $clientId;
     UbirimiContainer::get()['db.connection']->query($query);
     $query = 'delete from general_user where client_id = ' . $clientId;
     UbirimiContainer::get()['db.connection']->query($query);
     $query = 'delete from event where client_id = ' . $clientId;
     UbirimiContainer::get()['db.connection']->query($query);
     $query = 'delete from client_product where client_id = ' . $clientId;
     UbirimiContainer::get()['db.connection']->query($query);
     $query = 'delete from client_yongo_settings where client_id = ' . $clientId;
     UbirimiContainer::get()['db.connection']->query($query);
     $query = 'delete from client_documentator_settings where client_id = ' . $clientId;
     UbirimiContainer::get()['db.connection']->query($query);
     $query = 'delete from client_smtp_settings where client_id = ' . $clientId;
     UbirimiContainer::get()['db.connection']->query($query);
     $query = 'delete from client_settings where client_id = ' . $clientId;
     UbirimiContainer::get()['db.connection']->query($query);
     $query = 'delete from general_log where client_id = ' . $clientId;
     UbirimiContainer::get()['db.connection']->query($query);
     $query = 'delete from sys_permission_global_data where client_id = ' . $clientId;
     UbirimiContainer::get()['db.connection']->query($query);
     // delete Cheetah Product data
     $agileBoards = UbirimiContainer::get()['repository']->get(Board::class)->getByClientId($clientId, 'array');
     if ($agileBoards) {
         for ($i = 0; $i < count($agileBoards); $i++) {
             UbirimiContainer::get()['repository']->get(Board::class)->deleteById($agileBoards[$i]['id']);
         }
     }
     // delete Events Product data
     UbirimiContainer::get()['repository']->get(UbirimiClient::class)->deleteCalendars($clientId);
     // delete SVN Product data
     UbirimiContainer::get()['repository']->get(UbirimiClient::class)->deleteSVNRepositories($clientId);
     // delete Documentador Product data
     UbirimiContainer::get()['repository']->get(UbirimiClient::class)->deleteSpaces($clientId);
     $query = 'delete from client where id = ' . $clientId . ' limit 1';
     UbirimiContainer::get()['db.connection']->query($query);
     // also delete paymill information
     $client = new PaymillClient();
     $client->setId($clientData['paymill_id']);
     $requestPaymill = new PaymillRequest(UbirimiContainer::get()['paymill.private_key']);
     $response = $requestPaymill->delete($client);
     $query = "SET FOREIGN_KEY_CHECKS = 1;";
     UbirimiContainer::get()['db.connection']->query($query);
 }
示例#5
0
 /**
  * Tests the delete request method
  * @test
  * @depends updateTest
  */
 public function deleteTest($client)
 {
     $inputModel = new Request\Client();
     $inputModel->setId($client->getId());
     $outputArray = array();
     $outputArray['header']['status'] = 200;
     $outputArray['body']['data'] = array("id" => "client_88a388d9dd48f86c3136", "email" => null, "description" => "Lovely Client", "created_at" => 1342438695, "updated_at" => 1342438695, "payment" => array("id" => "pay_3af44644dd6d25c820a8", "type" => "creditcard", "client" => "client_88a388d9dd48f86c3136", "card_type" => "visa", "country" => null, "expire_month" => 10, "expire_year" => 2013, "card_holder" => null, "last4" => "1111", "created_at" => 1349942085, "updated_at" => 1349942085, "app_id" => null), "subscription" => null, "app_id" => null);
     $paymentModel = new Response\Payment();
     $paymentModel->setId($outputArray['body']['data']['payment']['id'])->setType($outputArray['body']['data']['payment']['type'])->setClient($outputArray['body']['data']['payment']['client'])->setCardType($outputArray['body']['data']['payment']['card_type'])->setCountry($outputArray['body']['data']['payment']['country'])->setExpireMonth($outputArray['body']['data']['payment']['expire_month'])->setExpireYear($outputArray['body']['data']['payment']['expire_year'])->setCardHolder($outputArray['body']['data']['payment']['card_holder'])->setLastFour($outputArray['body']['data']['payment']['last4'])->setCreatedAt($outputArray['body']['data']['payment']['created_at'])->setUpdatedAt($outputArray['body']['data']['payment']['updated_at'])->setAppId($outputArray['body']['data']['payment']['app_id']);
     $outputModel = new Response\Client();
     $outputModel->setId($outputArray['body']['data']['id'])->setEmail($outputArray['body']['data']['email'])->setDescription($outputArray['body']['data']['description'])->setCreatedAt($outputArray['body']['data']['created_at'])->setUpdatedAt($outputArray['body']['data']['updated_at'])->setPayment($paymentModel)->setSubscription($outputArray['body']['data']['subscription'])->setAppId($outputArray['body']['data']['app_id']);
     $this->_getCurlMock($this->_client->getServiceResource() . $this->_client->getId(), $this->_client->parameterize("delete"), "DELETE", $outputArray);
     $this->_client = $this->_request->delete($inputModel);
     $this->assertEquals($outputModel, $this->_client);
     return $this->_client;
 }