Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add Tests For Social Post #4

Open
wants to merge 24 commits into
base: 8.x-2.x
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
24 commits
Select commit Hold shift + click to select a range
86959c7
Add tests for Controller
neerajp99 Jun 10, 2019
e8c40ad
Add tests for Network
neerajp99 Jun 10, 2019
3cb6a4c
Add tests for SocialPostManager
neerajp99 Jun 10, 2019
7a015b9
Add tests for class UserAccessController
neerajp99 Jun 10, 2019
33cffc3
Add tests for Plugin
neerajp99 Jun 11, 2019
2382101
Add tests for Controller
neerajp99 Jun 11, 2019
fd033e5
Modified Controller
neerajp99 Jun 13, 2019
0767dae
Add tests for class SocialPostMaager
neerajp99 Jun 13, 2019
75b254e
Add tests for class SocialPost
neerajp99 Jun 13, 2019
3f64956
Edit tests for class SocialPostManager
neerajp99 Jun 13, 2019
3f41ea7
Add tests for class SocialPostListBuilder
neerajp99 Jun 13, 2019
2c8efda
Edit tests for Controller
neerajp99 Jun 16, 2019
357cdd1
Edit tests for Social Post Entity
neerajp99 Jun 16, 2019
e9c2521
Edit tests for Plugin class
neerajp99 Jun 16, 2019
cc2348e
Edit tests for class SocialPostManager;
neerajp99 Jun 16, 2019
6caa6dd
Edit tests for class UserAccessControlHandler
neerajp99 Jun 16, 2019
adad325
Fixed coding standard violations in Controller
neerajp99 Jun 16, 2019
b09a913
Fixed coding standard violations in Social Post Entity
neerajp99 Jun 16, 2019
8ce0d59
Fixed coding standard violations in Plugin Test class
neerajp99 Jun 16, 2019
9fcbf90
Fixed Coding Standard Violations in class SocialPostManager
neerajp99 Jun 16, 2019
c8a9d04
Edit Social Post tests
neerajp99 Jun 19, 2019
cf96baa
Edit Social Post tests
neerajp99 Jun 19, 2019
7900bad
Edit test for class SocialPostManager
neerajp99 Jun 19, 2019
19273c2
Edit Encryption methods in Social Post
neerajp99 Jun 27, 2019
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
20 changes: 20 additions & 0 deletions social_post.post_update.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
<?php

/**
* Update encryption tokens in Social Post.
*/
function social_post_post_update_add_encryption_to_access_tokens(&$sandbox = NULL) {
$entity = \Drupal::entityTypeManager()
->getStorage('social_post');

foreach($entity as $user) {
$token = $user->get('token');
$user->setToken($token);
$user->save();
$result = t('Token %nid saved', [
'%nid' => $user
->id(),
]);
}

}
3 changes: 2 additions & 1 deletion src/Entity/SocialPost.php
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
use Drupal\Core\Entity\EntityTypeInterface;
use Drupal\Core\Entity\ContentEntityInterface;
use Drupal\Core\Entity\EntityChangedTrait;
use Drupal\social_api\Entity\SocialApi;

/**
* Defines the Social Post entity.
Expand Down Expand Up @@ -37,7 +38,7 @@
* }
* )
*/
class SocialPost extends ContentEntityBase implements ContentEntityInterface {
class SocialPost extends SocialApi implements ContentEntityInterface {
use EntityChangedTrait;

/**
Expand Down
10 changes: 2 additions & 8 deletions src/SocialPostManager.php
Original file line number Diff line number Diff line change
Expand Up @@ -183,6 +183,7 @@ public function addRecord($name, $provider_user_id, $token, $additional_data = N
];

$user_info = $this->entityTypeManager->getStorage('social_post')->create($values);
$user_info->setToken($token);

// Save the entity.
$user_info->save();
Expand Down Expand Up @@ -269,14 +270,7 @@ public function getToken($provider_user_id) {
])
);

if (!$user_data) {
return FALSE;
}
else {
// Get token and decrypt it.
return $this->decryptToken($user_data->get('token')->getValue()[0]['value']);
}

return $this->decryptToken($user_data->get('token')->getValue()[0]['value']);
}

/**
Expand Down