From 61bfd6bc95c22bf589c91c644ba47501e8687775 Mon Sep 17 00:00:00 2001 From: Johan Janssens Date: Wed, 27 May 2015 01:32:09 +0200 Subject: [PATCH] #75 : Remove JLinkedin library --- libraries/joomla/linkedin/communications.php | 224 --- libraries/joomla/linkedin/companies.php | 476 ----- libraries/joomla/linkedin/groups.php | 1088 ---------- libraries/joomla/linkedin/index.html | 1 - libraries/joomla/linkedin/jobs.php | 372 ---- libraries/joomla/linkedin/linkedin.php | 151 -- libraries/joomla/linkedin/oauth.php | 144 -- libraries/joomla/linkedin/object.php | 106 - libraries/joomla/linkedin/people.php | 381 ---- libraries/joomla/linkedin/stream.php | 627 ------ .../linkedin/JLinkedinCommunicationsTest.php | 416 ---- .../linkedin/JLinkedinCompaniesTest.php | 732 ------- .../joomla/linkedin/JLinkedinGroupsTest.php | 1748 ----------------- .../joomla/linkedin/JLinkedinJobsTest.php | 554 ------ .../joomla/linkedin/JLinkedinOAuthTest.php | 150 -- .../joomla/linkedin/JLinkedinObjectTest.php | 97 - .../joomla/linkedin/JLinkedinPeopleTest.php | 538 ----- .../joomla/linkedin/JLinkedinStreamTest.php | 1067 ---------- .../joomla/linkedin/JLinkedinTest.php | 210 -- .../linkedin/stubs/JLinkedinObjectMock.php | 17 - 20 files changed, 9099 deletions(-) delete mode 100644 libraries/joomla/linkedin/communications.php delete mode 100644 libraries/joomla/linkedin/companies.php delete mode 100644 libraries/joomla/linkedin/groups.php delete mode 100644 libraries/joomla/linkedin/index.html delete mode 100644 libraries/joomla/linkedin/jobs.php delete mode 100644 libraries/joomla/linkedin/linkedin.php delete mode 100644 libraries/joomla/linkedin/oauth.php delete mode 100644 libraries/joomla/linkedin/object.php delete mode 100644 libraries/joomla/linkedin/people.php delete mode 100644 libraries/joomla/linkedin/stream.php delete mode 100644 tests/unit/suites/libraries/joomla/linkedin/JLinkedinCommunicationsTest.php delete mode 100644 tests/unit/suites/libraries/joomla/linkedin/JLinkedinCompaniesTest.php delete mode 100644 tests/unit/suites/libraries/joomla/linkedin/JLinkedinGroupsTest.php delete mode 100644 tests/unit/suites/libraries/joomla/linkedin/JLinkedinJobsTest.php delete mode 100644 tests/unit/suites/libraries/joomla/linkedin/JLinkedinOAuthTest.php delete mode 100644 tests/unit/suites/libraries/joomla/linkedin/JLinkedinObjectTest.php delete mode 100644 tests/unit/suites/libraries/joomla/linkedin/JLinkedinPeopleTest.php delete mode 100644 tests/unit/suites/libraries/joomla/linkedin/JLinkedinStreamTest.php delete mode 100644 tests/unit/suites/libraries/joomla/linkedin/JLinkedinTest.php delete mode 100644 tests/unit/suites/libraries/joomla/linkedin/stubs/JLinkedinObjectMock.php diff --git a/libraries/joomla/linkedin/communications.php b/libraries/joomla/linkedin/communications.php deleted file mode 100644 index 1ee1cad10b..0000000000 --- a/libraries/joomla/linkedin/communications.php +++ /dev/null @@ -1,224 +0,0 @@ -oauth->getToken(); - - // Set parameters. - $parameters = array( - 'oauth_token' => $token['key'] - ); - - // Set the success response code. - $this->oauth->setOption('success_code', 201); - - // Set the API base. - $base = '/v1/people/~/mailbox'; - - // Build the xml. - $xml = ' - - - - ' . $first_name . ' - ' . $last_name . ' - - - - ' . $subject . ' - ' . $body . ' - - - ' . $connection . ' - - - '; - - $header['Content-Type'] = 'text/xml'; - - // Build the request path. - $path = $this->getOption('api.url') . $base; - - // Send the request. - $response = $this->oauth->oauthRequest($path, 'POST', $parameters, $xml, $header); - - return $response; - } - - /** - * Method used to invite people. - * - * @param string $id Member id. - * @param string $first_name A string containing frist name of the recipient. - * @param string $last_name A string containing last name of the recipient. - * @param string $subject The subject of the message that will be sent to the recipient - * @param string $body A text of the message. - * @param string $connection Only connecting as a 'friend' is supported presently. - * - * @return array The decoded JSON response - * - * @since 13.1 - */ - public function inviteById($id, $first_name, $last_name, $subject, $body, $connection = 'friend') - { - $token = $this->oauth->getToken(); - - // Set parameters. - $parameters = array( - 'oauth_token' => $token['key'] - ); - - // Set the API base for people search. - $base = '/v1/people-search:(people:(api-standard-profile-request))'; - - $data['format'] = 'json'; - $data['first-name'] = $first_name; - $data['last-name'] = $last_name; - - // Build the request path. - $path = $this->getOption('api.url') . $base; - - // Send the request. - $response = $this->oauth->oauthRequest($path, 'GET', $parameters, $data); - - if (strpos($response->body, 'apiStandardProfileRequest') === false) - { - throw new RuntimeException($response->body); - } - - // Get header value. - $value = explode('"value": "', $response->body); - $value = explode('"', $value[1]); - $value = $value[0]; - - // Split on the colon character. - $value = explode(':', $value); - $name = $value[0]; - $value = $value[1]; - - // Set the success response code. - $this->oauth->setOption('success_code', 201); - - // Set the API base. - $base = '/v1/people/~/mailbox'; - - // Build the xml. - $xml = ' - - - - - - - ' . $subject . ' - ' . $body . ' - - - ' . $connection . ' - - ' . $name . ' - ' . $value . ' - - - - '; - - $header['Content-Type'] = 'text/xml'; - - // Build the request path. - $path = $this->getOption('api.url') . $base; - - // Send the request. - $response = $this->oauth->oauthRequest($path, 'POST', $parameters, $xml, $header); - - return $response; - } - - /** - * Method used to send messages via LinkedIn between two or more individuals connected to the member sending the message.. - * - * @param mixed $recipient A string containing the member id or an array of ids. - * @param string $subject The subject of the message that will be sent to the recipient - * @param string $body A text of the message. - * - * @return array The decoded JSON response - * - * @since 13.1 - */ - public function sendMessage($recipient, $subject, $body) - { - $token = $this->oauth->getToken(); - - // Set parameters. - $parameters = array( - 'oauth_token' => $token['key'] - ); - - // Set the success response code. - $this->oauth->setOption('success_code', 201); - - // Set the API base. - $base = '/v1/people/~/mailbox'; - - // Build the xml. - $xml = ' - '; - - if (is_array($recipient)) - { - foreach ($recipient as $r) - { - $xml .= ' - - '; - } - } - - $xml .= ' - ' . $subject . ' - ' . $body . ' - '; - - $header['Content-Type'] = 'text/xml'; - - // Build the request path. - $path = $this->getOption('api.url') . $base; - - // Send the request. - $response = $this->oauth->oauthRequest($path, 'POST', $parameters, $xml, $header); - - return $response; - } -} diff --git a/libraries/joomla/linkedin/companies.php b/libraries/joomla/linkedin/companies.php deleted file mode 100644 index 2877a9b5f6..0000000000 --- a/libraries/joomla/linkedin/companies.php +++ /dev/null @@ -1,476 +0,0 @@ -oauth->getToken(); - - // Set parameters. - $parameters = array( - 'oauth_token' => $token['key'] - ); - - // Set the API base - $base = '/v1/companies'; - - if ($id && $name) - { - $base .= '::(' . $id . ',universal-name=' . $name . ')'; - } - elseif ($id) - { - $base .= '/' . $id; - } - elseif ($name) - { - $base .= '/universal-name=' . $name; - } - - // Set request parameters. - $data['format'] = 'json'; - - if ($domain) - { - $data['email-domain'] = $domain; - } - - // Check if fields is specified. - if ($fields) - { - $base .= ':' . $fields; - } - - // Build the request path. - $path = $this->getOption('api.url') . $base; - - // Send the request. - $response = $this->oauth->oauthRequest($path, 'GET', $parameters, $data); - - return json_decode($response->body); - } - - /** - * Method to read shares for a particular company . - * - * @param string $id The unique company identifier. - * @param string $type Any valid Company Update Type from the table: https://developer.linkedin.com/reading-company-updates. - * @param integer $count Maximum number of updates to return. - * @param integer $start The offset by which to start Network Update pagination. - * - * @return array The decoded JSON response - * - * @since 13.1 - */ - public function getUpdates($id, $type = null, $count = 0, $start = 0) - { - $token = $this->oauth->getToken(); - - // Set parameters. - $parameters = array( - 'oauth_token' => $token['key'] - ); - - // Set the API base - $base = '/v1/companies/' . $id . '/updates'; - - // Set request parameters. - $data['format'] = 'json'; - - // Check if type is specified. - if ($type) - { - $data['event-type'] = $type; - } - - // Check if count is specified. - if ($count > 0) - { - $data['count'] = $count; - } - - // Check if start is specified. - if ($start > 0) - { - $data['start'] = $start; - } - - // Build the request path. - $path = $this->getOption('api.url') . $base; - - // Send the request. - $response = $this->oauth->oauthRequest($path, 'GET', $parameters, $data); - - return json_decode($response->body); - } - - /** - * Method to search across company pages. - * - * @param string $fields Request fields beyond the default ones. - * @param string $keywords Members who have all the keywords anywhere in their profile. - * @param boolean $hq Matching companies by the headquarters location. When this is set to "true" and a location facet is used, - * this restricts returned companies to only those whose headquarters resides in the specified location. - * @param string $facets Facet buckets to return, e.g. location. - * @param array $facet Array of facet values to search over. Contains values for location, industry, network, company-size, - * num-followers-range and fortune, in exactly this order, null must be specified for an element if no value. - * @param integer $start Starting location within the result set for paginated returns. - * @param integer $count The number of results returned. - * @param string $sort Controls the search result order. There are four options: relevance, relationship, - * followers and company-size. - * - * @return array The decoded JSON response - * - * @since 13.1 - */ - public function search($fields = null, $keywords = null, $hq = false, $facets = null, $facet = null, $start = 0, $count = 0, $sort = null) - { - $token = $this->oauth->getToken(); - - // Set parameters. - $parameters = array( - 'oauth_token' => $token['key'] - ); - - // Set the API base - $base = '/v1/company-search'; - - $data['format'] = 'json'; - - // Check if fields is specified. - if ($fields) - { - $base .= ':' . $fields; - } - - // Check if keywords is specified. - if ($keywords) - { - $data['keywords'] = $keywords; - } - - // Check if hq is true. - if ($hq) - { - $data['hq-only'] = $hq; - } - - // Check if facets is specified. - if ($facets) - { - $data['facets'] = $facets; - } - - // Check if facet is specified. - if ($facet) - { - $data['facet'] = array(); - for ($i = 0; $i < count($facet); $i++) - { - if ($facet[$i]) - { - if ($i == 0) - { - $data['facet'][] = 'location,' . $facet[$i]; - } - if ($i == 1) - { - $data['facet'][] = 'industry,' . $facet[$i]; - } - if ($i == 2) - { - $data['facet'][] = 'network,' . $facet[$i]; - } - if ($i == 3) - { - $data['facet'][] = 'company-size,' . $facet[$i]; - } - if ($i == 4) - { - $data['facet'][] = 'num-followers-range,' . $facet[$i]; - } - if ($i == 5) - { - $data['facet'][] = 'fortune,' . $facet[$i]; - } - } - } - } - - // Check if start is specified. - if ($start > 0) - { - $data['start'] = $start; - } - - // Check if count is specified. - if ($count > 0) - { - $data['count'] = $count; - } - - // Check if sort is specified. - if ($sort) - { - $data['sort'] = $sort; - } - - // Build the request path. - $path = $this->getOption('api.url') . $base; - - // Send the request. - $response = $this->oauth->oauthRequest($path, 'GET', $parameters, $data); - - return json_decode($response->body); - } - - /** - * Method to get a list of companies the current member is following. - * - * @param string $fields Request fields beyond the default ones. - * - * @return array The decoded JSON response - * - * @since 13.1 - */ - public function getFollowed($fields = null) - { - $token = $this->oauth->getToken(); - - // Set parameters. - $parameters = array( - 'oauth_token' => $token['key'] - ); - - // Set the API base - $base = '/v1/people/~/following/companies'; - - $data['format'] = 'json'; - - // Check if fields is specified. - if ($fields) - { - $base .= ':' . $fields; - } - - // Build the request path. - $path = $this->getOption('api.url') . $base; - - // Send the request. - $response = $this->oauth->oauthRequest($path, 'GET', $parameters, $data); - - return json_decode($response->body); - } - - /** - * Method to follow a company. - * - * @param string $id The unique identifier for a company. - * - * @return array The decoded JSON response - * - * @since 13.1 - */ - public function follow($id) - { - $token = $this->oauth->getToken(); - - // Set parameters. - $parameters = array( - 'oauth_token' => $token['key'] - ); - - // Set the success response code. - $this->oauth->setOption('success_code', 201); - - // Set the API base - $base = '/v1/people/~/following/companies'; - - // Build xml. - $xml = '' . $id . ''; - - // Build the request path. - $path = $this->getOption('api.url') . $base; - - $header['Content-Type'] = 'text/xml'; - - // Send the request. - $response = $this->oauth->oauthRequest($path, 'POST', $parameters, $xml, $header); - - return $response; - } - - /** - * Method to unfollow a company. - * - * @param string $id The unique identifier for a company. - * - * @return array The decoded JSON response - * - * @since 13.1 - */ - public function unfollow($id) - { - $token = $this->oauth->getToken(); - - // Set parameters. - $parameters = array( - 'oauth_token' => $token['key'] - ); - - // Set the success response code. - $this->oauth->setOption('success_code', 204); - - // Set the API base - $base = '/v1/people/~/following/companies/id=' . $id; - - // Build the request path. - $path = $this->getOption('api.url') . $base; - - // Send the request. - $response = $this->oauth->oauthRequest($path, 'DELETE', $parameters); - - return $response; - } - - /** - * Method to get a collection of suggested companies for the current user. - * - * @param string $fields Request fields beyond the default ones. - * @param integer $start Starting location within the result set for paginated returns. - * @param integer $count The number of results returned. - * - * @return array The decoded JSON response - * - * @since 13.1 - */ - public function getSuggested($fields = null, $start = 0, $count = 0) - { - $token = $this->oauth->getToken(); - - // Set parameters. - $parameters = array( - 'oauth_token' => $token['key'] - ); - - // Set the API base - $base = '/v1/people/~/suggestions/to-follow/companies'; - - $data['format'] = 'json'; - - // Check if fields is specified. - if ($fields) - { - $base .= ':' . $fields; - } - - // Check if start is specified. - if ($start > 0) - { - $data['start'] = $start; - } - - // Check if count is specified. - if ($count > 0) - { - $data['count'] = $count; - } - - // Build the request path. - $path = $this->getOption('api.url') . $base; - - // Send the request. - $response = $this->oauth->oauthRequest($path, 'GET', $parameters, $data); - - return json_decode($response->body); - } - - /** - * Method to get a collection of suggested companies for the current user. - * - * @param string $id The unique identifier for a company. - * @param string $fields Request fields beyond the default ones. - * @param integer $start Starting location within the result set for paginated returns. - * @param integer $count The number of results returned. - * - * @return array The decoded JSON response - * - * @since 13.1 - */ - public function getProducts($id, $fields = null, $start = 0, $count = 0) - { - $token = $this->oauth->getToken(); - - // Set parameters. - $parameters = array( - 'oauth_token' => $token['key'] - ); - - // Set the API base - $base = '/v1/companies/' . $id . '/products'; - - $data['format'] = 'json'; - - // Check if fields is specified. - if ($fields) - { - $base .= ':' . $fields; - } - - // Check if start is specified. - if ($start > 0) - { - $data['start'] = $start; - } - - // Check if count is specified. - if ($count > 0) - { - $data['count'] = $count; - } - - // Build the request path. - $path = $this->getOption('api.url') . $base; - - // Send the request. - $response = $this->oauth->oauthRequest($path, 'GET', $parameters, $data); - - return json_decode($response->body); - } -} diff --git a/libraries/joomla/linkedin/groups.php b/libraries/joomla/linkedin/groups.php deleted file mode 100644 index f883302551..0000000000 --- a/libraries/joomla/linkedin/groups.php +++ /dev/null @@ -1,1088 +0,0 @@ -oauth->getToken(); - - // Set parameters. - $parameters = array( - 'oauth_token' => $token['key'] - ); - - // Set the API base - $base = '/v1/groups/' . $id; - - $data['format'] = 'json'; - - // Check if fields is specified. - if ($fields) - { - $base .= ':' . $fields; - } - - // Check if start is specified. - if ($start > 0) - { - $data['start'] = $start; - } - - // Check if count is specified. - if ($count != 5) - { - $data['count'] = $count; - } - - // Build the request path. - $path = $this->getOption('api.url') . $base; - - // Send the request. - $response = $this->oauth->oauthRequest($path, 'GET', $parameters, $data); - - return json_decode($response->body); - } - - /** - * Method to find the groups a member belongs to. - * - * @param string $id The unique identifier for a user. - * @param string $fields Request fields beyond the default ones. - * @param integer $start Starting location within the result set for paginated returns. - * @param integer $count The number of results returned. - * @param string $membership_state The state of the caller’s membership to the specified group. - * Values are: non-member, awaiting-confirmation, awaiting-parent-group-confirmation, member, moderator, manager, owner. - * - * @return array The decoded JSON response - * - * @since 13.1 - */ - public function getMemberships($id = null, $fields = null, $start = 0, $count = 5, $membership_state = null) - { - $token = $this->oauth->getToken(); - - // Set parameters. - $parameters = array( - 'oauth_token' => $token['key'] - ); - - // Set the API base - $base = '/v1/people/'; - - // Check if id is specified. - if ($id) - { - $base .= $id . '/group-memberships'; - } - else - { - $base .= '~/group-memberships'; - } - - $data['format'] = 'json'; - - // Check if fields is specified. - if ($fields) - { - $base .= ':' . $fields; - } - - // Check if start is specified. - if ($start > 0) - { - $data['start'] = $start; - } - - // Check if count is specified. - if ($count != 5) - { - $data['count'] = $count; - } - - // Check if membership_state is specified. - if ($membership_state) - { - $data['membership-state'] = $membership_state; - } - - // Build the request path. - $path = $this->getOption('api.url') . $base; - - // Send the request. - $response = $this->oauth->oauthRequest($path, 'GET', $parameters, $data); - - return json_decode($response->body); - } - - /** - * Method to find the groups a member belongs to. - * - * @param string $person_id The unique identifier for a user. - * @param string $group_id The unique identifier for a group. - * @param string $fields Request fields beyond the default ones. - * @param integer $start Starting location within the result set for paginated returns. - * @param integer $count The number of results returned. - * - * @return array The decoded JSON response - * - * @since 13.1 - */ - public function getSettings($person_id = null, $group_id = null, $fields = null, $start = 0, $count = 5) - { - $token = $this->oauth->getToken(); - - // Set parameters. - $parameters = array( - 'oauth_token' => $token['key'] - ); - - // Set the API base - $base = '/v1/people/'; - - // Check if person_id is specified. - if ($person_id) - { - $base .= $person_id . '/group-memberships'; - } - else - { - $base .= '~/group-memberships'; - } - - // Check if group_id is specified. - if ($group_id) - { - $base .= '/' . $group_id; - } - - $data['format'] = 'json'; - - // Check if fields is specified. - if ($fields) - { - $base .= ':' . $fields; - } - - // Check if start is specified. - if ($start > 0) - { - $data['start'] = $start; - } - - // Check if count is specified. - if ($count != 5) - { - $data['count'] = $count; - } - - // Build the request path. - $path = $this->getOption('api.url') . $base; - - // Send the request. - $response = $this->oauth->oauthRequest($path, 'GET', $parameters, $data); - - return json_decode($response->body); - } - - /** - * Method to change a groups settings. - * - * @param string $group_id The unique identifier for a group. - * @param boolean $show_logo Show group logo in profile. - * @param string $digest_frequency E-mail digest frequency. - * @param boolean $announcements E-mail announcements from managers. - * @param boolean $allow_messages Allow messages from members. - * @param boolean $new_post E-mail for every new post. - * - * @return array The decoded JSON response - * - * @since 13.1 - */ - public function changeSettings($group_id, $show_logo = null, $digest_frequency = null, $announcements = null, - $allow_messages = null, $new_post = null) - { - $token = $this->oauth->getToken(); - - // Set parameters. - $parameters = array( - 'oauth_token' => $token['key'] - ); - - // Set the API base - $base = '/v1/people/~/group-memberships/' . $group_id; - - // Build xml. - $xml = ''; - - if (!is_null($show_logo)) - { - $xml .= '' . $this->booleanToString($show_logo) . ''; - } - - if ($digest_frequency) - { - $xml .= '' . $digest_frequency . ''; - } - - if (!is_null($announcements)) - { - $xml .= '' . $this->booleanToString($announcements) . ''; - } - - if (!is_null($new_post)) - { - $xml .= '' . $this->booleanToString($new_post) . ''; - } - - $xml .= ''; - - // Build the request path. - $path = $this->getOption('api.url') . $base; - - $header['Content-Type'] = 'text/xml'; - - // Send the request. - $response = $this->oauth->oauthRequest($path, 'PUT', $parameters, $xml, $header); - - return $response; - } - - /** - * Method to join a group. - * - * @param string $group_id The unique identifier for a group. - * @param boolean $show_logo Show group logo in profile. - * @param string $digest_frequency E-mail digest frequency. - * @param boolean $announcements E-mail announcements from managers. - * @param boolean $allow_messages Allow messages from members. - * @param boolean $new_post E-mail for every new post. - * - * @return array The decoded JSON response - * - * @since 13.1 - */ - public function joinGroup($group_id, $show_logo = null, $digest_frequency = null, $announcements = null, - $allow_messages = null, $new_post = null) - { - $token = $this->oauth->getToken(); - - // Set parameters. - $parameters = array( - 'oauth_token' => $token['key'] - ); - - // Set the success response code. - $this->oauth->setOption('success_code', 201); - - // Set the API base - $base = '/v1/people/~/group-memberships'; - - // Build xml. - $xml = '' . $group_id . ''; - - if (!is_null($show_logo)) - { - $xml .= '' . $this->booleanToString($show_logo) . ''; - } - - if ($digest_frequency) - { - $xml .= '' . $digest_frequency . ''; - } - - if (!is_null($announcements)) - { - $xml .= '' . $this->booleanToString($announcements) . ''; - } - - if (!is_null($new_post)) - { - $xml .= '' . $this->booleanToString($new_post) . ''; - } - - $xml .= 'member'; - - // Build the request path. - $path = $this->getOption('api.url') . $base; - - $header['Content-Type'] = 'text/xml'; - - // Send the request. - $response = $this->oauth->oauthRequest($path, 'POST', $parameters, $xml, $header); - - return $response; - } - - /** - * Method to leave a group. - * - * @param string $group_id The unique identifier for a group. - * - * @return array The decoded JSON response - * - * @since 13.1 - */ - public function leaveGroup($group_id) - { - $token = $this->oauth->getToken(); - - // Set parameters. - $parameters = array( - 'oauth_token' => $token['key'] - ); - - // Set the success response code. - $this->oauth->setOption('success_code', 204); - - // Set the API base - $base = '/v1/people/~/group-memberships/' . $group_id; - - // Build the request path. - $path = $this->getOption('api.url') . $base; - - // Send the request. - $response = $this->oauth->oauthRequest($path, 'DELETE', $parameters); - - return $response; - } - - /** - * Method to get dicussions for a group. - * - * @param string $id The unique identifier for a group. - * @param string $fields Request fields beyond the default ones. - * @param integer $start Starting location within the result set for paginated returns. - * @param integer $count The number of results returned. - * @param string $order Sort order for posts. Valid for: recency, popularity. - * @param string $category Category of posts. Valid for: discussion - * @param string $modified_since Timestamp filter for posts created after the specified value. - * - * @return array The decoded JSON response - * - * @since 13.1 - */ - public function getDiscussions($id, $fields = null, $start = 0, $count = 0, $order = null, $category = 'discussion', $modified_since = null) - { - $token = $this->oauth->getToken(); - - // Set parameters. - $parameters = array( - 'oauth_token' => $token['key'] - ); - - // Set the API base - $base = '/v1/groups/' . $id . '/posts'; - - $data['format'] = 'json'; - - // Check if fields is specified. - if ($fields) - { - $base .= ':' . $fields; - } - - // Check if start is specified. - if ($start > 0) - { - $data['start'] = $start; - } - - // Check if count is specified. - if ($count > 0) - { - $data['count'] = $count; - } - - // Check if order is specified. - if ($order) - { - $data['order'] = $order; - } - - // Check if category is specified. - if ($category) - { - $data['category'] = $category; - } - - // Check if modified_since is specified. - if ($modified_since) - { - $data['modified-since'] = $modified_since; - } - - // Build the request path. - $path = $this->getOption('api.url') . $base; - - // Send the request. - $response = $this->oauth->oauthRequest($path, 'GET', $parameters, $data); - - return json_decode($response->body); - } - - /** - * Method to get posts a user started / participated in / follows for a group. - * - * @param string $group_id The unique identifier for a group. - * @param string $role Filter for posts related to the caller. Valid for: creator, commenter, follower. - * @param string $person_id The unique identifier for a user. - * @param string $fields Request fields beyond the default ones. - * @param integer $start Starting location within the result set for paginated returns. - * @param integer $count The number of results returned. - * @param string $order Sort order for posts. Valid for: recency, popularity. - * @param string $category Category of posts. Valid for: discussion - * @param string $modified_since Timestamp filter for posts created after the specified value. - * - * @return array The decoded JSON response - * - * @since 13.1 - */ - public function getUserPosts($group_id, $role, $person_id = null, $fields = null, $start = 0, $count = 0, - $order = null, $category = 'discussion', $modified_since = null) - { - $token = $this->oauth->getToken(); - - // Set parameters. - $parameters = array( - 'oauth_token' => $token['key'] - ); - - // Set the API base - $base = '/v1/people/'; - - // Check if person_id is specified. - if ($person_id) - { - $base .= $person_id; - } - else - { - $base .= '~'; - } - - $base .= '/group-memberships/' . $group_id . '/posts'; - - $data['format'] = 'json'; - $data['role'] = $role; - - // Check if fields is specified. - if ($fields) - { - $base .= ':' . $fields; - } - - // Check if start is specified. - if ($start > 0) - { - $data['start'] = $start; - } - - // Check if count is specified. - if ($count > 0) - { - $data['count'] = $count; - } - - // Check if order is specified. - if ($order) - { - $data['order'] = $order; - } - - // Check if category is specified. - if ($category) - { - $data['category'] = $category; - } - - // Check if modified_since is specified. - if ($modified_since) - { - $data['modified-since'] = $modified_since; - } - - // Build the request path. - $path = $this->getOption('api.url') . $base; - - // Send the request. - $response = $this->oauth->oauthRequest($path, 'GET', $parameters, $data); - - return json_decode($response->body); - } - - /** - * Method to retrieve details about a post. - * - * @param string $post_id The unique identifier for a post. - * @param string $fields Request fields beyond the default ones. - * - * @return array The decoded JSON response - * - * @since 13.1 - */ - public function getPost($post_id, $fields = null) - { - $token = $this->oauth->getToken(); - - // Set parameters. - $parameters = array( - 'oauth_token' => $token['key'] - ); - - // Set the API base - $base = '/v1/posts/' . $post_id; - - $data['format'] = 'json'; - - // Check if fields is specified. - if ($fields) - { - $base .= ':' . $fields; - } - - // Build the request path. - $path = $this->getOption('api.url') . $base; - - // Send the request. - $response = $this->oauth->oauthRequest($path, 'GET', $parameters, $data); - - return json_decode($response->body); - } - - /** - * Method to retrieve all comments of a post. - * - * @param string $post_id The unique identifier for a post. - * @param string $fields Request fields beyond the default ones. - * @param integer $start Starting location within the result set for paginated returns. - * @param integer $count The number of results returned. - * - * @return array The decoded JSON response - * - * @since 13.1 - */ - public function getPostComments($post_id, $fields = null, $start = 0, $count = 0) - { - $token = $this->oauth->getToken(); - - // Set parameters. - $parameters = array( - 'oauth_token' => $token['key'] - ); - - // Set the API base - $base = '/v1/posts/' . $post_id . '/comments'; - - $data['format'] = 'json'; - - // Check if fields is specified. - if ($fields) - { - $base .= ':' . $fields; - } - - // Check if start is specified. - if ($start > 0) - { - $data['start'] = $start; - } - - // Check if count is specified. - if ($count > 0) - { - $data['count'] = $count; - } - - // Build the request path. - $path = $this->getOption('api.url') . $base; - - // Send the request. - $response = $this->oauth->oauthRequest($path, 'GET', $parameters, $data); - - return json_decode($response->body); - } - - /** - * Method to retrieve all comments of a post. - * - * @param string $group_id The unique identifier for a group. - * @param string $title Post title. - * @param string $summary Post summary. - * - * @return string The created post's id. - * - * @since 13.1 - */ - public function createPost($group_id, $title, $summary) - { - $token = $this->oauth->getToken(); - - // Set parameters. - $parameters = array( - 'oauth_token' => $token['key'] - ); - - // Set the success response code. - $this->oauth->setOption('success_code', 201); - - // Set the API base - $base = '/v1/groups/' . $group_id . '/posts'; - - // Build xml. - $xml = '' . $title . '' . $summary . ''; - - // Build the request path. - $path = $this->getOption('api.url') . $base; - - $header['Content-Type'] = 'text/xml'; - - // Send the request. - $response = $this->oauth->oauthRequest($path, 'POST', $parameters, $xml, $header); - - // Return the post id. - $response = explode('posts/', $response->headers['Location']); - - return $response[1]; - } - - /** - * Method to like or unlike a post. - * - * @param string $post_id The unique identifier for a group. - * @param boolean $like True to like post, false otherwise. - * - * @return array The decoded JSON response - * - * @since 13.1 - */ - private function _likeUnlike($post_id, $like) - { - $token = $this->oauth->getToken(); - - // Set parameters. - $parameters = array( - 'oauth_token' => $token['key'] - ); - - // Set the success response code. - $this->oauth->setOption('success_code', 204); - - // Set the API base - $base = '/v1/posts/' . $post_id . '/relation-to-viewer/is-liked'; - - // Build xml. - $xml = '' . $this->booleanToString($like) . ''; - - // Build the request path. - $path = $this->getOption('api.url') . $base; - - $header['Content-Type'] = 'text/xml'; - - // Send the request. - $response = $this->oauth->oauthRequest($path, 'PUT', $parameters, $xml, $header); - - return $response; - } - - /** - * Method used to like a post. - * - * @param string $post_id The unique identifier for a group. - * - * @return array The decoded JSON response - * - * @since 13.1 - */ - public function likePost($post_id) - { - return $this->_likeUnlike($post_id, true); - } - - /** - * Method used to unlike a post. - * - * @param string $post_id The unique identifier for a group. - * - * @return array The decoded JSON response - * - * @since 13.1 - */ - public function unlikePost($post_id) - { - return $this->_likeUnlike($post_id, false); - } - - /** - * Method to follow or unfollow a post. - * - * @param string $post_id The unique identifier for a group. - * @param boolean $follow True to like post, false otherwise. - * - * @return array The decoded JSON response - * - * @since 13.1 - */ - private function _followUnfollow($post_id, $follow) - { - $token = $this->oauth->getToken(); - - // Set parameters. - $parameters = array( - 'oauth_token' => $token['key'] - ); - - // Set the success response code. - $this->oauth->setOption('success_code', 204); - - // Set the API base - $base = '/v1/posts/' . $post_id . '/relation-to-viewer/is-following'; - - // Build xml. - $xml = '' . $this->booleanToString($follow) . ''; - - // Build the request path. - $path = $this->getOption('api.url') . $base; - - $header['Content-Type'] = 'text/xml'; - - // Send the request. - $response = $this->oauth->oauthRequest($path, 'PUT', $parameters, $xml, $header); - - return $response; - } - - /** - * Method used to follow a post. - * - * @param string $post_id The unique identifier for a group. - * - * @return array The decoded JSON response - * - * @since 13.1 - */ - public function followPost($post_id) - { - return $this->_followUnfollow($post_id, true); - } - - /** - * Method used to unfollow a post. - * - * @param string $post_id The unique identifier for a group. - * - * @return array The decoded JSON response - * - * @since 13.1 - */ - public function unfollowPost($post_id) - { - return $this->_followUnfollow($post_id, false); - } - - /** - * Method to flag a post as a Promotion or Job. - * - * @param string $post_id The unique identifier for a group. - * @param string $flag Flag as a 'promotion' or 'job'. - * - * @return array The decoded JSON response - * - * @since 13.1 - */ - public function flagPost($post_id, $flag) - { - $token = $this->oauth->getToken(); - - // Set parameters. - $parameters = array( - 'oauth_token' => $token['key'] - ); - - // Set the success response code. - $this->oauth->setOption('success_code', 204); - - // Set the API base - $base = '/v1/posts/' . $post_id . '/category/code'; - - // Build xml. - $xml = '' . $flag . ''; - - // Build the request path. - $path = $this->getOption('api.url') . $base; - - $header['Content-Type'] = 'text/xml'; - - // Send the request. - $response = $this->oauth->oauthRequest($path, 'PUT', $parameters, $xml, $header); - - return $response; - } - - /** - * Method to delete a post if the current user is the creator or flag it as inappropriate otherwise. - * - * @param string $post_id The unique identifier for a group. - * - * @return array The decoded JSON response - * - * @since 13.1 - */ - public function deletePost($post_id) - { - $token = $this->oauth->getToken(); - - // Set parameters. - $parameters = array( - 'oauth_token' => $token['key'] - ); - - // Set the success response code. - $this->oauth->setOption('success_code', 204); - - // Set the API base - $base = '/v1/posts/' . $post_id; - - // Build the request path. - $path = $this->getOption('api.url') . $base; - - // Send the request. - $response = $this->oauth->oauthRequest($path, 'DELETE', $parameters); - - return $response; - } - - /** - * Method to access the comments resource. - * - * @param string $comment_id The unique identifier for a comment. - * @param string $fields Request fields beyond the default ones. - * - * @return array The decoded JSON response - * - * @since 13.1 - */ - public function getComment($comment_id, $fields = null) - { - $token = $this->oauth->getToken(); - - // Set parameters. - $parameters = array( - 'oauth_token' => $token['key'] - ); - - // Set the API base - $base = '/v1/comments/' . $comment_id; - - $data['format'] = 'json'; - - // Check if fields is specified. - if ($fields) - { - $base .= ':' . $fields; - } - - // Build the request path. - $path = $this->getOption('api.url') . $base; - - // Send the request. - $response = $this->oauth->oauthRequest($path, 'GET', $parameters, $data); - - return json_decode($response->body); - } - - /** - * Method to add a comment to a post - * - * @param string $post_id The unique identifier for a group. - * @param string $comment The post comment's text. - * - * @return string The created comment's id. - * - * @since 13.1 - */ - public function addComment($post_id, $comment) - { - $token = $this->oauth->getToken(); - - // Set parameters. - $parameters = array( - 'oauth_token' => $token['key'] - ); - - // Set the success response code. - $this->oauth->setOption('success_code', 201); - - // Set the API base - $base = '/v1/posts/' . $post_id . '/comments'; - - // Build xml. - $xml = '' . $comment . ''; - - // Build the request path. - $path = $this->getOption('api.url') . $base; - - $header['Content-Type'] = 'text/xml'; - - // Send the request. - $response = $this->oauth->oauthRequest($path, 'POST', $parameters, $xml, $header); - - // Return the comment id. - $response = explode('comments/', $response->headers['Location']); - - return $response[1]; - } - - /** - * Method to delete a comment if the current user is the creator or flag it as inappropriate otherwise. - * - * @param string $comment_id The unique identifier for a group. - * - * @return array The decoded JSON response - * - * @since 13.1 - */ - public function deleteComment($comment_id) - { - $token = $this->oauth->getToken(); - - // Set parameters. - $parameters = array( - 'oauth_token' => $token['key'] - ); - - // Set the success response code. - $this->oauth->setOption('success_code', 204); - - // Set the API base - $base = '/v1/comments/' . $comment_id; - - // Build the request path. - $path = $this->getOption('api.url') . $base; - - // Send the request. - $response = $this->oauth->oauthRequest($path, 'DELETE', $parameters); - - return $response; - } - - /** - * Method to get suggested groups for a user. - * - * @param string $person_id The unique identifier for a user. - * @param string $fields Request fields beyond the default ones. - * - * @return array The decoded JSON response - * - * @since 13.1 - */ - public function getSuggested($person_id = null, $fields = null) - { - $token = $this->oauth->getToken(); - - // Set parameters. - $parameters = array( - 'oauth_token' => $token['key'] - ); - - // Set the API base - $base = '/v1/people/'; - - // Check if person_id is specified. - if ($person_id) - { - $base .= $person_id . '/suggestions/groups'; - } - else - { - $base .= '~/suggestions/groups'; - } - - $data['format'] = 'json'; - - // Check if fields is specified. - if ($fields) - { - $base .= ':' . $fields; - } - - // Build the request path. - $path = $this->getOption('api.url') . $base; - - // Send the request. - $response = $this->oauth->oauthRequest($path, 'GET', $parameters, $data); - - return json_decode($response->body); - } - - /** - * Method to delete a group suggestion for a user. - * - * @param string $suggestion_id The unique identifier for a suggestion. - * @param string $person_id The unique identifier for a user. - * - * @return array The decoded JSON response - * - * @since 13.1 - */ - public function deleteSuggestion($suggestion_id, $person_id = null) - { - $token = $this->oauth->getToken(); - - // Set parameters. - $parameters = array( - 'oauth_token' => $token['key'] - ); - - // Set the success response code. - $this->oauth->setOption('success_code', 204); - - // Set the API base - $base = '/v1/people/'; - - // Check if person_id is specified. - if ($person_id) - { - $base .= $person_id . '/suggestions/groups/' . $suggestion_id; - } - else - { - $base .= '~/suggestions/groups/' . $suggestion_id; - } - - // Build the request path. - $path = $this->getOption('api.url') . $base; - - // Send the request. - $response = $this->oauth->oauthRequest($path, 'DELETE', $parameters); - - return $response; - } -} diff --git a/libraries/joomla/linkedin/index.html b/libraries/joomla/linkedin/index.html deleted file mode 100644 index 2efb97f319..0000000000 --- a/libraries/joomla/linkedin/index.html +++ /dev/null @@ -1 +0,0 @@ - diff --git a/libraries/joomla/linkedin/jobs.php b/libraries/joomla/linkedin/jobs.php deleted file mode 100644 index 41cfd7fb63..0000000000 --- a/libraries/joomla/linkedin/jobs.php +++ /dev/null @@ -1,372 +0,0 @@ -oauth->getToken(); - - // Set parameters. - $parameters = array( - 'oauth_token' => $token['key'] - ); - - // Set the API base - $base = '/v1/jobs/' . $id; - - // Set request parameters. - $data['format'] = 'json'; - - // Check if fields is specified. - if ($fields) - { - $base .= ':' . $fields; - } - - // Build the request path. - $path = $this->getOption('api.url') . $base; - - // Send the request. - $response = $this->oauth->oauthRequest($path, 'GET', $parameters, $data); - - return json_decode($response->body); - } - - /** - * Method to get a list of bookmarked jobs for the current member. - * - * @param string $fields Request fields beyond the default ones. - * - * @return array The decoded JSON response - * - * @since 13.1 - */ - public function getBookmarked($fields = null) - { - $token = $this->oauth->getToken(); - - // Set parameters. - $parameters = array( - 'oauth_token' => $token['key'] - ); - - // Set the API base - $base = '/v1/people/~/job-bookmarks'; - - // Set request parameters. - $data['format'] = 'json'; - - // Check if fields is specified. - if ($fields) - { - $base .= ':' . $fields; - } - - // Build the request path. - $path = $this->getOption('api.url') . $base; - - // Send the request. - $response = $this->oauth->oauthRequest($path, 'GET', $parameters, $data); - - return json_decode($response->body); - } - - /** - * Method to bookmark a job to the current user's account. - * - * @param integer $id The unique identifier for a job. - * - * @return array The decoded JSON response - * - * @since 13.1 - */ - public function bookmark($id) - { - $token = $this->oauth->getToken(); - - // Set parameters. - $parameters = array( - 'oauth_token' => $token['key'] - ); - - // Set the success response code. - $this->oauth->setOption('success_code', 201); - - // Set the API base - $base = '/v1/people/~/job-bookmarks'; - - // Build xml. - $xml = '' . $id . ''; - - // Build the request path. - $path = $this->getOption('api.url') . $base; - - $header['Content-Type'] = 'text/xml'; - - // Send the request. - $response = $this->oauth->oauthRequest($path, 'POST', $parameters, $xml, $header); - - return $response; - } - - /** - * Method to delete a bookmark. - * - * @param integer $id The unique identifier for a job. - * - * @return array The decoded JSON response - * - * @since 13.1 - */ - public function deleteBookmark($id) - { - $token = $this->oauth->getToken(); - - // Set parameters. - $parameters = array( - 'oauth_token' => $token['key'] - ); - - // Set the success response code. - $this->oauth->setOption('success_code', 204); - - // Set the API base - $base = '/v1/people/~/job-bookmarks/' . $id; - - // Build the request path. - $path = $this->getOption('api.url') . $base; - - // Send the request. - $response = $this->oauth->oauthRequest($path, 'DELETE', $parameters); - - return $response; - } - - /** - * Method to retrieve job suggestions for the current user. - * - * @param string $fields Request fields beyond the default ones. - * @param integer $start Starting location within the result set for paginated returns. - * @param integer $count The number of results returned. - * - * @return array The decoded JSON response - * - * @since 13.1 - */ - public function getSuggested($fields = null, $start = 0, $count = 0) - { - $token = $this->oauth->getToken(); - - // Set parameters. - $parameters = array( - 'oauth_token' => $token['key'] - ); - - // Set the API base - $base = '/v1/people/~/suggestions/job-suggestions'; - - $data['format'] = 'json'; - - // Check if fields is specified. - if ($fields) - { - $base .= ':' . $fields; - } - - // Check if start is specified. - if ($start > 0) - { - $data['start'] = $start; - } - - // Check if count is specified. - if ($count > 0) - { - $data['count'] = $count; - } - - // Build the request path. - $path = $this->getOption('api.url') . $base; - - // Send the request. - $response = $this->oauth->oauthRequest($path, 'GET', $parameters, $data); - - return json_decode($response->body); - } - - /** - * Method to search across LinkedIn's job postings. - * - * @param string $fields Request fields beyond the default ones. - * @param string $keywords Members who have all the keywords anywhere in their profile. - * @param string $company_name Jobs with a matching company name. - * @param string $job_title Matches jobs with the same job title. - * @param string $country_code Matches members with a location in a specific country. Values are defined in by ISO 3166 standard. - * Country codes must be in all lower case. - * @param integer $postal_code Matches members centered around a Postal Code. Must be combined with the country-code parameter. - * Not supported for all countries. - * @param integer $distance Matches members within a distance from a central point. This is measured in miles. - * @param string $facets Facet buckets to return, e.g. location. - * @param array $facet Array of facet values to search over. Contains values for company, date-posted, location, job-function, - * industry, and salary, in exactly this order, null must be specified for an element if no value. - * @param integer $start Starting location within the result set for paginated returns. - * @param integer $count The number of results returned. - * @param string $sort Controls the search result order. There are four options: R (relationship), DA (date-posted-asc), - * DD (date-posted-desc). - * - * @return array The decoded JSON response - * - * @since 13.1 - */ - public function search($fields = null, $keywords = null, $company_name = null, $job_title = null, $country_code = null, $postal_code = null, - $distance = null, $facets = null, $facet = null, $start = 0, $count = 0, $sort = null) - { - $token = $this->oauth->getToken(); - - // Set parameters. - $parameters = array( - 'oauth_token' => $token['key'] - ); - - // Set the API base - $base = '/v1/job-search'; - - $data['format'] = 'json'; - - // Check if fields is specified. - if ($fields) - { - $base .= ':' . $fields; - } - - // Check if keywords is specified. - if ($keywords) - { - $data['keywords'] = $keywords; - } - - // Check if company-name is specified. - if ($company_name) - { - $data['company-name'] = $company_name; - } - - // Check if job-title is specified. - if ($job_title) - { - $data['job-title'] = $job_title; - } - - // Check if country_code is specified. - if ($country_code) - { - $data['country-code'] = $country_code; - } - - // Check if postal_code is specified. - if ($postal_code) - { - $data['postal-code'] = $postal_code; - } - - // Check if distance is specified. - if ($distance) - { - $data['distance'] = $distance; - } - - // Check if facets is specified. - if ($facets) - { - $data['facets'] = $facets; - } - - // Check if facet is specified. - if ($facet) - { - $data['facet'] = array(); - for ($i = 0; $i < count($facet); $i++) - { - if ($facet[$i]) - { - if ($i == 0) - { - $data['facet'][] = 'company,' . $this->oauth->safeEncode($facet[$i]); - } - if ($i == 1) - { - $data['facet'][] = 'date-posted,' . $facet[$i]; - } - if ($i == 2) - { - $data['facet'][] = 'location,' . $facet[$i]; - } - if ($i == 3) - { - $data['facet'][] = 'job-function,' . $this->oauth->safeEncode($facet[$i]); - } - if ($i == 4) - { - $data['facet'][] = 'industry,' . $facet[$i]; - } - if ($i == 5) - { - $data['facet'][] = 'salary,' . $facet[$i]; - } - } - } - } - - // Check if start is specified. - if ($start > 0) - { - $data['start'] = $start; - } - - // Check if count is specified. - if ($count > 0) - { - $data['count'] = $count; - } - - // Check if sort is specified. - if ($sort) - { - $data['sort'] = $sort; - } - - // Build the request path. - $path = $this->getOption('api.url') . $base; - - // Send the request. - $response = $this->oauth->oauthRequest($path, 'GET', $parameters, $data); - - return json_decode($response->body); - } -} diff --git a/libraries/joomla/linkedin/linkedin.php b/libraries/joomla/linkedin/linkedin.php deleted file mode 100644 index 9931ac7e37..0000000000 --- a/libraries/joomla/linkedin/linkedin.php +++ /dev/null @@ -1,151 +0,0 @@ -oauth = $oauth; - $this->options = isset($options) ? $options : new JRegistry; - $this->client = isset($client) ? $client : new JHttp($this->options); - - // Setup the default API url if not already set. - $this->options->def('api.url', 'https://api.linkedin.com'); - } - - /** - * Magic method to lazily create API objects - * - * @param string $name Name of property to retrieve - * - * @return JLinkedinObject Linkedin API object (statuses, users, favorites, etc.). - * - * @since 13.1 - * @throws InvalidArgumentException - */ - public function __get($name) - { - $class = 'JLinkedin' . ucfirst($name); - - if (class_exists($class)) - { - if (false == isset($this->$name)) - { - $this->$name = new $class($this->options, $this->client, $this->oauth); - } - - return $this->$name; - } - - throw new InvalidArgumentException(sprintf('Argument %s produced an invalid class name: %s', $name, $class)); - } - - /** - * Get an option from the JLinkedin instance. - * - * @param string $key The name of the option to get. - * - * @return mixed The option value. - * - * @since 13.1 - */ - public function getOption($key) - { - return $this->options->get($key); - } - - /** - * Set an option for the Linkedin instance. - * - * @param string $key The name of the option to set. - * @param mixed $value The option value to set. - * - * @return JLinkedin This object for method chaining. - * - * @since 13.1 - */ - public function setOption($key, $value) - { - $this->options->set($key, $value); - - return $this; - } -} diff --git a/libraries/joomla/linkedin/oauth.php b/libraries/joomla/linkedin/oauth.php deleted file mode 100644 index 5f5feeb4ae..0000000000 --- a/libraries/joomla/linkedin/oauth.php +++ /dev/null @@ -1,144 +0,0 @@ -options = isset($options) ? $options : new JRegistry; - - $this->options->def('accessTokenURL', 'https://www.linkedin.com/uas/oauth/accessToken'); - $this->options->def('authenticateURL', 'https://www.linkedin.com/uas/oauth/authenticate'); - $this->options->def('authoriseURL', 'https://www.linkedin.com/uas/oauth/authorize'); - $this->options->def('requestTokenURL', 'https://www.linkedin.com/uas/oauth/requestToken'); - - // Call the JOauthV1aclient constructor to setup the object. - parent::__construct($this->options, $client, $input); - } - - /** - * Method to verify if the access token is valid by making a request to an API endpoint. - * - * @return boolean Returns true if the access token is valid and false otherwise. - * - * @since 13.1 - */ - public function verifyCredentials() - { - $token = $this->getToken(); - - // Set parameters. - $parameters = array( - 'oauth_token' => $token['key'] - ); - - $data['format'] = 'json'; - - // Set the API url. - $path = 'https://api.linkedin.com/v1/people::(~)'; - - // Send the request. - $response = $this->oauthRequest($path, 'GET', $parameters, $data); - - // Verify response - if ($response->code == 200) - { - return true; - } - else - { - return false; - } - } - - /** - * Method to validate a response. - * - * @param string $url The request URL. - * @param JHttpResponse $response The response to validate. - * - * @return void - * - * @since 13.1 - * @throws DomainException - */ - public function validateResponse($url, $response) - { - if (!$code = $this->getOption('success_code')) - { - $code = 200; - } - - if (strpos($url, '::(~)') === false && $response->code != $code) - { - if ($error = json_decode($response->body)) - { - throw new DomainException('Error code ' . $error->errorCode . ' received with message: ' . $error->message . '.'); - } - else - { - throw new DomainException($response->body); - } - } - } - - /** - * Method used to set permissions. - * - * @param mixed $scope String or an array of string containing permissions. - * - * @return JLinkedinOauth This object for method chaining - * - * @see https://developer.linkedin.com/documents/authentication - * @since 13.1 - */ - public function setScope($scope) - { - $this->setOption('scope', $scope); - - return $this; - } - - /** - * Method to get the current scope - * - * @return string String or an array of string containing permissions. - * - * @since 13.1 - */ - public function getScope() - { - return $this->getOption('scope'); - } -} diff --git a/libraries/joomla/linkedin/object.php b/libraries/joomla/linkedin/object.php deleted file mode 100644 index 7d6ac57998..0000000000 --- a/libraries/joomla/linkedin/object.php +++ /dev/null @@ -1,106 +0,0 @@ -options = isset($options) ? $options : new JRegistry; - $this->client = isset($client) ? $client : new JHttp($this->options); - $this->oauth = $oauth; - } - - /** - * Method to convert boolean to string. - * - * @param boolean $bool The boolean value to convert. - * - * @return string String with the converted boolean. - * - * @since 13.1 - */ - public function booleanToString($bool) - { - if ($bool) - { - return 'true'; - } - else - { - return 'false'; - } - } - - /** - * Get an option from the JLinkedinObject instance. - * - * @param string $key The name of the option to get. - * - * @return mixed The option value. - * - * @since 13.1 - */ - public function getOption($key) - { - return $this->options->get($key); - } - - /** - * Set an option for the JLinkedinObject instance. - * - * @param string $key The name of the option to set. - * @param mixed $value The option value to set. - * - * @return JLinkedinObject This object for method chaining. - * - * @since 13.1 - */ - public function setOption($key, $value) - { - $this->options->set($key, $value); - - return $this; - } -} diff --git a/libraries/joomla/linkedin/people.php b/libraries/joomla/linkedin/people.php deleted file mode 100644 index 970d7df2e5..0000000000 --- a/libraries/joomla/linkedin/people.php +++ /dev/null @@ -1,381 +0,0 @@ -oauth->getToken(); - - // Set parameters. - $parameters = array( - 'oauth_token' => $token['key'] - ); - - // Set the API base - $base = '/v1/people/'; - - $data['format'] = 'json'; - - // Check if a member id is specified. - if ($id) - { - $base .= 'id=' . $id; - } - elseif (!$url) - { - $base .= '~'; - } - - // Check if profile url is specified. - if ($url) - { - $base .= 'url=' . $this->oauth->safeEncode($url); - - // Choose public profile - if (!strcmp($type, 'public')) - { - $base .= ':public'; - } - } - - // Check if fields is specified. - if ($fields) - { - $base .= ':' . $fields; - } - - // Check if language is specified. - $header = array(); - if ($language) - { - $header = array('Accept-Language' => $language); - } - - // Build the request path. - $path = $this->getOption('api.url') . $base; - - // Send the request. - $response = $this->oauth->oauthRequest($path, 'GET', $parameters, $data, $header); - - return json_decode($response->body); - } - - /** - * Method to get a list of connections for a user who has granted access to his/her account. - * - * @param string $fields Request fields beyond the default ones. - * @param integer $start Starting location within the result set for paginated returns. - * @param integer $count The number of results returned. - * @param string $modified Values are updated or new. - * @param string $modified_since Value as a Unix time stamp of milliseconds since epoch. - * - * @return array The decoded JSON response - * - * @since 13.1 - */ - public function getConnections($fields = null, $start = 0, $count = 500, $modified = null, $modified_since = null) - { - $token = $this->oauth->getToken(); - - // Set parameters. - $parameters = array( - 'oauth_token' => $token['key'] - ); - - // Set the API base - $base = '/v1/people/~/connections'; - - $data['format'] = 'json'; - - // Check if fields is specified. - if ($fields) - { - $base .= ':' . $fields; - } - - // Check if start is specified. - if ($start > 0) - { - $data['start'] = $start; - } - // Check if count is specified. - if ($count != 500) - { - $data['count'] = $count; - } - - // Check if modified is specified. - if ($modified) - { - $data['modified'] = $modified; - } - - // Check if modified_since is specified. - if ($modified_since) - { - $data['modified-since'] = $modified_since; - } - - // Build the request path. - $path = $this->getOption('api.url') . $base; - - // Send the request. - $response = $this->oauth->oauthRequest($path, 'GET', $parameters, $data); - - return json_decode($response->body); - } - - /** - * Method to get information about people. - * - * @param string $fields Request fields beyond the default ones. provide 'api-standard-profile-request' - * field for out of network profiles. - * @param string $keywords Members who have all the keywords anywhere in their profile. - * @param string $first_name Members with a matching first name. Matches must be exact. - * @param string $last_name Members with a matching last name. Matches must be exactly. - * @param string $company_name Members who have a matching company name on their profile. - * @param boolean $current_company A value of true matches members who currently work at the company specified in the company-name - * parameter. - * @param string $title Matches members with that title on their profile. - * @param boolean $current_title A value of true matches members whose title is currently the one specified in the title-name parameter. - * @param string $school_name Members who have a matching school name on their profile. - * @param string $current_school A value of true matches members who currently attend the school specified in the school-name parameter. - * @param string $country_code Matches members with a location in a specific country. Values are defined in by ISO 3166 standard. - * Country codes must be in all lower case. - * @param integer $postal_code Matches members centered around a Postal Code. Must be combined with the country-code parameter. - * Not supported for all countries. - * @param integer $distance Matches members within a distance from a central point. This is measured in miles. - * @param string $facets Facet buckets to return, e.g. location. - * @param array $facet Array of facet values to search over. Contains values for location, industry, network, language, - * current-company, past-company and school, in exactly this order, null must be specified for an element if no value. - * @param integer $start Starting location within the result set for paginated returns. - * @param integer $count The number of results returned. - * @param string $sort Controls the search result order. There are four options: connections, recommenders, - * distance and relevance. - * - * @return array The decoded JSON response - * - * @since 13.1 - */ - public function search($fields = null, $keywords = null, $first_name = null, $last_name = null, $company_name = null, - $current_company = null, $title = null, $current_title = null, $school_name = null, $current_school = null, $country_code = null, - $postal_code = null, $distance = null, $facets = null, $facet = null, $start = 0, $count = 10, $sort = null) - { - $token = $this->oauth->getToken(); - - // Set parameters. - $parameters = array( - 'oauth_token' => $token['key'] - ); - - // Set the API base - $base = '/v1/people-search'; - - $data['format'] = 'json'; - - // Check if fields is specified. - if ($fields) - { - $base .= ':' . $fields; - } - - // Check if keywords is specified. - if ($keywords) - { - $data['keywords'] = $keywords; - } - - // Check if first_name is specified. - if ($first_name) - { - $data['first-name'] = $first_name; - } - - // Check if last_name is specified. - if ($last_name) - { - $data['last-name'] = $last_name; - } - - // Check if company-name is specified. - if ($company_name) - { - $data['company-name'] = $company_name; - } - - // Check if current_company is specified. - if ($current_company) - { - $data['current-company'] = $current_company; - } - - // Check if title is specified. - if ($title) - { - $data['title'] = $title; - } - - // Check if current_title is specified. - if ($current_title) - { - $data['current-title'] = $current_title; - } - - // Check if school_name is specified. - if ($school_name) - { - $data['school-name'] = $school_name; - } - - // Check if current_school is specified. - if ($current_school) - { - $data['current-school'] = $current_school; - } - - // Check if country_code is specified. - if ($country_code) - { - $data['country-code'] = $country_code; - } - - // Check if postal_code is specified. - if ($postal_code) - { - $data['postal-code'] = $postal_code; - } - - // Check if distance is specified. - if ($distance) - { - $data['distance'] = $distance; - } - - // Check if facets is specified. - if ($facets) - { - $data['facets'] = $facets; - } - - // Check if facet is specified. - if ($facet) - { - $data['facet'] = array(); - for ($i = 0; $i < count($facet); $i++) - { - if ($facet[$i]) - { - if ($i == 0) - { - $data['facet'][] = 'location,' . $facet[$i]; - } - if ($i == 1) - { - $data['facet'][] = 'industry,' . $facet[$i]; - } - if ($i == 2) - { - $data['facet'][] = 'network,' . $facet[$i]; - } - if ($i == 3) - { - $data['facet'][] = 'language,' . $facet[$i]; - } - if ($i == 4) - { - $data['facet'][] = 'current-company,' . $facet[$i]; - } - if ($i == 5) - { - $data['facet'][] = 'past-company,' . $facet[$i]; - } - if ($i == 6) - { - $data['facet'][] = 'school,' . $facet[$i]; - } - } - } - } - - // Check if start is specified. - if ($start > 0) - { - $data['start'] = $start; - } - - // Check if count is specified. - if ($count != 10) - { - $data['count'] = $count; - } - - // Check if sort is specified. - if ($sort) - { - $data['sort'] = $sort; - } - - // Build the request path. - $path = $this->getOption('api.url') . $base; - - // Send the request. - $response = $this->oauth->oauthRequest($path, 'GET', $parameters, $data); - - if (strpos($fields, 'api-standard-profile-request') === false) - { - return json_decode($response->body); - } - - // Get header name. - $name = explode('"name": "', $response->body); - $name = explode('"', $name[1]); - $name = $name[0]; - - // Get header value. - $value = explode('"value": "', $response->body); - $value = explode('"', $value[1]); - $value = $value[0]; - - // Get request url. - $url = explode('"url": "', $response->body); - $url = explode('"', $url[1]); - $url = $url[0]; - - // Build header for out of network profile. - $header[$name] = $value; - - // Send the request. - $response = $this->oauth->oauthRequest($url, 'GET', $parameters, $data, $header); - - return json_decode($response->body); - } -} diff --git a/libraries/joomla/linkedin/stream.php b/libraries/joomla/linkedin/stream.php deleted file mode 100644 index 82b241a7fb..0000000000 --- a/libraries/joomla/linkedin/stream.php +++ /dev/null @@ -1,627 +0,0 @@ -oauth->getToken(); - - // Set parameters. - $parameters = array( - 'oauth_token' => $token['key'] - ); - - // Set the success response code. - $this->oauth->setOption('success_code', 201); - - // Set the API base - $base = '/v1/people/~/shares'; - - // Check if twitter is true. - if ($twitter) - { - $base .= '?twitter-post=true'; - } - - // Build xml. - $xml = ' - - ' . $visibility . ' - '; - - // Check if comment specified. - if ($comment) - { - $xml .= '' . $comment . ''; - } - - // Check if title and url are specified. - if ($title && $url) - { - $xml .= ' - ' . $title . ' - ' . $url . ''; - - // Check if image is specified. - if ($image) - { - $xml .= '' . $image . ''; - } - - // Check if descrption id specified. - if ($description) - { - $xml .= '' . $description . ''; - } - - $xml .= ''; - } - elseif (!$comment) - { - throw new RuntimeException('Post must contain comment and/or (title and url).'); - } - - $xml .= ''; - - // Build the request path. - $path = $this->getOption('api.url') . $base; - - $header['Content-Type'] = 'text/xml'; - - // Send the request. - $response = $this->oauth->oauthRequest($path, 'POST', $parameters, $xml, $header); - - return $response; - } - - /** - * Method to reshare an existing share. - * - * @param string $visibility One of anyone: all members or connections-only: connections only. - * @param string $id The unique identifier for a share. - * @param string $comment Text of member's comment. - * @param boolean $twitter True to have LinkedIn pass the status message along to a member's tethered Twitter account. - * - * @return array The decoded JSON response - * - * @since 13.1 - * @throws RuntimeException - */ - public function reshare($visibility, $id, $comment = null, $twitter = false) - { - $token = $this->oauth->getToken(); - - // Set parameters. - $parameters = array( - 'oauth_token' => $token['key'] - ); - - // Set the success response code. - $this->oauth->setOption('success_code', 201); - - // Set the API base - $base = '/v1/people/~/shares'; - - // Check if twitter is true. - if ($twitter) - { - $base .= '?twitter-post=true'; - } - - // Build xml. - $xml = ' - - ' . $visibility . ' - '; - - // Check if comment specified. - if ($comment) - { - $xml .= '' . $comment . ''; - } - - $xml .= ' - - ' . $id . ' - - - '; - - // Build the request path. - $path = $this->getOption('api.url') . $base; - - $header['Content-Type'] = 'text/xml'; - - // Send the request. - $response = $this->oauth->oauthRequest($path, 'POST', $parameters, $xml, $header); - - return $response; - } - - /** - * Method to get a particular member's current share. - * - * @param string $id Member id of the profile you want. - * @param string $url The public profile URL. - * - * @return array The decoded JSON response - * - * @since 13.1 - */ - public function getCurrentShare($id = null, $url = null) - { - $token = $this->oauth->getToken(); - - // Set parameters. - $parameters = array( - 'oauth_token' => $token['key'] - ); - - // Set the API base - $base = '/v1/people/'; - - // Check if a member id is specified. - if ($id) - { - $base .= 'id=' . $id; - } - elseif (!$url) - { - $base .= '~'; - } - - // Check if profile url is specified. - if ($url) - { - $base .= 'url=' . $this->oauth->safeEncode($url); - } - - $base .= ':(current-share)'; - - // Set request parameters. - $data['format'] = 'json'; - - // Build the request path. - $path = $this->getOption('api.url') . $base; - - // Send the request. - $response = $this->oauth->oauthRequest($path, 'GET', $parameters, $data); - - return json_decode($response->body); - } - - /** - * Method to get a particular member's current share. - * - * @param string $id Member id of the profile you want. - * @param string $url The public profile URL. - * @param boolean $self Used to return member's feed. Omitted to return aggregated network feed. - * - * @return array The decoded JSON response - * - * @since 13.1 - */ - public function getShareStream($id = null, $url = null, $self = true) - { - $token = $this->oauth->getToken(); - - // Set parameters. - $parameters = array( - 'oauth_token' => $token['key'] - ); - - // Set the API base - $base = '/v1/people/'; - - // Check if a member id is specified. - if ($id) - { - $base .= $id; - } - elseif (!$url) - { - $base .= '~'; - } - - // Check if profile url is specified. - if ($url) - { - $base .= 'url=' . $this->oauth->safeEncode($url); - } - - $base .= '/network'; - - // Set request parameters. - $data['format'] = 'json'; - $data['type'] = 'SHAR'; - - // Check if self is true - if ($self) - { - $data['scope'] = 'self'; - } - - // Build the request path. - $path = $this->getOption('api.url') . $base; - - // Send the request. - $response = $this->oauth->oauthRequest($path, 'GET', $parameters, $data); - - return json_decode($response->body); - } - - /** - * Method to get the users network updates. - * - * @param string $id Member id. - * @param boolean $self Used to return member's feed. Omitted to return aggregated network feed. - * @param mixed $type String containing any valid Network Update Type from the table or an array of strings - * to specify more than one Network Update type. - * @param integer $count Number of updates to return, with a maximum of 250. - * @param integer $start The offset by which to start Network Update pagination. - * @param string $after Timestamp after which to retrieve updates. - * @param string $before Timestamp before which to retrieve updates. - * @param boolean $hidden Whether to display updates from people the member has chosen to "hide" from their update stream. - * - * @return array The decoded JSON response - * - * @since 13.1 - */ - public function getNetworkUpdates($id = null, $self = true, $type = null, $count = 0, $start = 0, $after = null, $before = null, - $hidden = false) - { - $token = $this->oauth->getToken(); - - // Set parameters. - $parameters = array( - 'oauth_token' => $token['key'] - ); - - // Set the API base - $base = '/v1/people/'; - - // Check if a member id is specified. - if ($id) - { - $base .= $id; - } - else - { - $base .= '~'; - } - - $base .= '/network/updates'; - - // Set request parameters. - $data['format'] = 'json'; - - // Check if self is true. - if ($self) - { - $data['scope'] = 'self'; - } - - // Check if type is specified. - if ($type) - { - $data['type'] = $type; - } - - // Check if count is specified. - if ($count > 0) - { - $data['count'] = $count; - } - - // Check if start is specified. - if ($start > 0) - { - $data['start'] = $start; - } - - // Check if after is specified. - if ($after) - { - $data['after'] = $after; - } - - // Check if before is specified. - if ($before > 0) - { - $data['before'] = $before; - } - - // Check if hidden is true. - if ($hidden) - { - $data['hidden'] = $hidden; - } - - // Build the request path. - $path = $this->getOption('api.url') . $base; - - // Send the request. - $response = $this->oauth->oauthRequest($path, 'GET', $parameters, $data); - - return json_decode($response->body); - } - - /** - * Method to get information about the current member's network. - * - * @return array The decoded JSON response - * - * @since 13.1 - */ - public function getNetworkStats() - { - $token = $this->oauth->getToken(); - - // Set parameters. - $parameters = array( - 'oauth_token' => $token['key'] - ); - - // Set the API base - $base = '/v1/people/~/network/network-stats'; - - // Set request parameters. - $data['format'] = 'json'; - - // Build the request path. - $path = $this->getOption('api.url') . $base; - - // Send the request. - $response = $this->oauth->oauthRequest($path, 'GET', $parameters, $data); - - return json_decode($response->body); - } - - /** - * Method to get the users network updates. - * - * @param string $body The actual content of the update. You can use HTML to include links to the user name and the content the user - * created. Other HTML tags are not supported. All body text should be HTML entity escaped and UTF-8 compliant. - * - * @return array The decoded JSON response - * - * @since 13.1 - */ - public function postNetworkUpdate($body) - { - $token = $this->oauth->getToken(); - - // Set parameters. - $parameters = array( - 'oauth_token' => $token['key'] - ); - - // Set the success response code. - $this->oauth->setOption('success_code', 201); - - // Set the API base - $base = '/v1/people/~/person-activities'; - - // Build the xml. - $xml = ' - linkedin-html - ' . $body . ' - '; - - $header['Content-Type'] = 'text/xml'; - - // Build the request path. - $path = $this->getOption('api.url') . $base; - - // Send the request. - $response = $this->oauth->oauthRequest($path, 'POST', $parameters, $xml, $header); - - return $response; - } - - /** - * Method to retrieve all comments for a given network update. - * - * @param string $key update/update-key representing an update. - * - * @return array The decoded JSON response - * - * @since 13.1 - */ - public function getComments($key) - { - $token = $this->oauth->getToken(); - - // Set parameters. - $parameters = array( - 'oauth_token' => $token['key'] - ); - - // Set the API base - $base = '/v1/people/~/network/updates/key=' . $key . '/update-comments'; - - // Set request parameters. - $data['format'] = 'json'; - - // Build the request path. - $path = $this->getOption('api.url') . $base; - - // Send the request. - $response = $this->oauth->oauthRequest($path, 'GET', $parameters, $data); - - return json_decode($response->body); - } - - /** - * Method to post a new comment to an existing update. - * - * @param string $key update/update-key representing an update. - * @param string $comment Maximum length of 700 characters - * - * @return array The decoded JSON response - * - * @since 13.1 - */ - public function postComment($key, $comment) - { - $token = $this->oauth->getToken(); - - // Set parameters. - $parameters = array( - 'oauth_token' => $token['key'] - ); - - // Set the success response code. - $this->oauth->setOption('success_code', 201); - - // Set the API base - $base = '/v1/people/~/network/updates/key=' . $key . '/update-comments'; - - // Build the xml. - $xml = ' - ' . $comment . ' - '; - - $header['Content-Type'] = 'text/xml'; - - // Build the request path. - $path = $this->getOption('api.url') . $base; - - // Send the request. - $response = $this->oauth->oauthRequest($path, 'POST', $parameters, $xml, $header); - - return $response; - } - - /** - * Method to retrieve the complete list of people who liked an update. - * - * @param string $key update/update-key representing an update. - * - * @return array The decoded JSON response - * - * @since 13.1 - */ - public function getLikes($key) - { - $token = $this->oauth->getToken(); - - // Set parameters. - $parameters = array( - 'oauth_token' => $token['key'] - ); - - // Set the API base - $base = '/v1/people/~/network/updates/key=' . $key . '/likes'; - - // Set request parameters. - $data['format'] = 'json'; - - // Build the request path. - $path = $this->getOption('api.url') . $base; - - // Send the request. - $response = $this->oauth->oauthRequest($path, 'GET', $parameters, $data); - - return json_decode($response->body); - } - - /** - * Method to like or unlike an update. - * - * @param string $key Update/update-key representing an update. - * @param boolean $like True to like update, false otherwise. - * - * @return array The decoded JSON response - * - * @since 13.1 - */ - private function _likeUnlike($key, $like) - { - $token = $this->oauth->getToken(); - - // Set parameters. - $parameters = array( - 'oauth_token' => $token['key'] - ); - - // Set the success response code. - $this->oauth->setOption('success_code', 204); - - // Set the API base - $base = '/v1/people/~/network/updates/key=' . $key . '/is-liked'; - - // Build xml. - $xml = '' . $this->booleanToString($like) . ''; - - // Build the request path. - $path = $this->getOption('api.url') . $base; - - $header['Content-Type'] = 'text/xml'; - - // Send the request. - $response = $this->oauth->oauthRequest($path, 'PUT', $parameters, $xml, $header); - - return $response; - } - - /** - * Method used to like an update. - * - * @param string $key Update/update-key representing an update. - * - * @return array The decoded JSON response - * - * @since 13.1 - */ - public function like($key) - { - return $this->_likeUnlike($key, true); - } - - /** - * Method used to unlike an update. - * - * @param string $key Update/update-key representing an update. - * - * @return array The decoded JSON response - * - * @since 13.1 - */ - public function unlike($key) - { - return $this->_likeUnlike($key, false); - } -} diff --git a/tests/unit/suites/libraries/joomla/linkedin/JLinkedinCommunicationsTest.php b/tests/unit/suites/libraries/joomla/linkedin/JLinkedinCommunicationsTest.php deleted file mode 100644 index 8af72a46b5..0000000000 --- a/tests/unit/suites/libraries/joomla/linkedin/JLinkedinCommunicationsTest.php +++ /dev/null @@ -1,416 +0,0 @@ -options = new JRegistry; - $this->input = new JInput; - $this->client = $this->getMock('JHttp', array('get', 'post', 'delete', 'put')); - $this->oauth = new JLinkedinOauth($this->options, $this->client, $this->input); - $this->oauth->setToken(array('key' => $key, 'secret' => $secret)); - - $this->object = new JLinkedinCommunications($this->options, $this->client, $this->oauth); - - $this->options->set('consumer_key', $key); - $this->options->set('consumer_secret', $secret); - $this->options->set('callback', $my_url); - } - - /** - * Tears down the fixture, for example, closes a network connection. - * This method is called after a test is executed. - * - * @return void - */ - protected function tearDown() - { - } - - /** - * Tests the inviteByEmail method - * - * @return void - * - * @since 13.1 - */ - public function testInviteByEmail() - { - $email = 'example@domain.com'; - $first_name = 'Frist'; - $last_name = 'Last'; - $subject = 'Subject'; - $body = 'body'; - $connection = 'friend'; - - $path = '/v1/people/~/mailbox'; - - // Build the xml. - $xml = ' - - - - ' . $first_name . ' - ' . $last_name . ' - - - - ' . $subject . ' - ' . $body . ' - - - ' . $connection . ' - - - '; - - $header['Content-Type'] = 'text/xml'; - - $returnData = new stdClass; - $returnData->code = 201; - $returnData->body = $this->sampleString; - - $this->client->expects($this->once()) - ->method('post', $xml, $header) - ->with($path) - ->will($this->returnValue($returnData)); - - $this->assertThat( - $this->object->inviteByEmail($email, $first_name, $last_name, $subject, $body, $connection), - $this->equalTo($returnData) - ); - } - - /** - * Tests the inviteByEmail method - failure - * - * @return void - * - * @expectedException DomainException - * @since 13.1 - */ - public function testInviteByEmailFailure() - { - $email = 'example@domain.com'; - $first_name = 'Frist'; - $last_name = 'Last'; - $subject = 'Subject'; - $body = 'body'; - $connection = 'friend'; - - $path = '/v1/people/~/mailbox'; - - // Build the xml. - $xml = ' - - - - ' . $first_name . ' - ' . $last_name . ' - - - - ' . $subject . ' - ' . $body . ' - - - ' . $connection . ' - - - '; - - $header['Content-Type'] = 'text/xml'; - - $returnData = new stdClass; - $returnData->code = 401; - $returnData->body = $this->errorString; - - $this->client->expects($this->once()) - ->method('post', $xml, $header) - ->with($path) - ->will($this->returnValue($returnData)); - - $this->object->inviteByEmail($email, $first_name, $last_name, $subject, $body, $connection); - } - - /** - * Tests the inviteById method - * - * @return void - * - * @since 13.1 - */ - public function testInviteById() - { - $id = 'lcnIwDU0S6'; - $first_name = 'Frist'; - $last_name = 'Last'; - $subject = 'Subject'; - $body = 'body'; - $connection = 'friend'; - - $name = 'NAME_SEARCH'; - $value = 'mwjY'; - - $path = '/v1/people-search:(people:(api-standard-profile-request))'; - - $returnData = new stdClass; - $returnData->code = 200; - $returnData->body = '{"apiStandardProfileRequest": {"headers": {"_total": 1,"values": [{"name": "x-li-auth-token","value": "' . - $name . ':' . $value . '"}]}}}'; - - $data['format'] = 'json'; - $data['first-name'] = $first_name; - $data['last-name'] = $last_name; - - $path = $this->oauth->toUrl($path, $data); - - $this->client->expects($this->at(0)) - ->method('get') - ->with($path) - ->will($this->returnValue($returnData)); - - $path = '/v1/people/~/mailbox'; - - // Build the xml. - $xml = ' - - - - - - - ' . $subject . ' - ' . $body . ' - - - ' . $connection . ' - - ' . $name . ' - ' . $value . ' - - - - '; - - $header['Content-Type'] = 'text/xml'; - - $returnData = new stdClass; - $returnData->code = 201; - $returnData->body = $this->sampleString; - - $this->client->expects($this->at(1)) - ->method('post', $xml, $header) - ->with($path) - ->will($this->returnValue($returnData)); - - $this->assertThat( - $this->object->inviteById($id, $first_name, $last_name, $subject, $body, $connection), - $this->equalTo($returnData) - ); - } - - /** - * Tests the inviteById method - failure - * - * @return void - * - * @expectedException RuntimeException - * @since 13.1 - */ - public function testInviteByIdFailure() - { - $id = 'lcnIwDU0S6'; - $first_name = 'Frist'; - $last_name = 'Last'; - $subject = 'Subject'; - $body = 'body'; - $connection = 'friend'; - - $name = 'NAME_SEARCH'; - $value = 'mwjY'; - - $path = '/v1/people-search:(people:(api-standard-profile-request))'; - - $returnData = new stdClass; - $returnData->code = 200; - $returnData->body = $this->sampleString; - - $data['format'] = 'json'; - $data['first-name'] = $first_name; - $data['last-name'] = $last_name; - - $path = $this->oauth->toUrl($path, $data); - - $this->client->expects($this->at(0)) - ->method('get') - ->with($path) - ->will($this->returnValue($returnData)); - - $this->object->inviteById($id, $first_name, $last_name, $subject, $body, $connection); - } - - /** - * Tests the sendMessage method - * - * @return void - * - * @since 13.1 - */ - public function testSendMessage() - { - $recipient = array('~', 'lcnIwDU0S6'); - $subject = 'Subject'; - $body = 'body'; - - $path = '/v1/people/~/mailbox'; - - // Build the xml. - $xml = ' - - - - - - - - - ' . $subject . ' - ' . $body . ' - '; - - $header['Content-Type'] = 'text/xml'; - - $returnData = new stdClass; - $returnData->code = 201; - $returnData->body = $this->sampleString; - - $this->client->expects($this->once()) - ->method('post', $xml, $header) - ->with($path) - ->will($this->returnValue($returnData)); - - $this->assertThat( - $this->object->sendMessage($recipient, $subject, $body), - $this->equalTo($returnData) - ); - } - - /** - * Tests the sendMessage method - failure - * - * @return void - * - * @expectedException DomainException - * @since 13.1 - */ - public function testSendMessageFailure() - { - $recipient = array('~', 'lcnIwDU0S6'); - $subject = 'Subject'; - $body = 'body'; - - $path = '/v1/people/~/mailbox'; - - // Build the xml. - $xml = ' - - - - - - - - - ' . $subject . ' - ' . $body . ' - '; - - $header['Content-Type'] = 'text/xml'; - - $returnData = new stdClass; - $returnData->code = 401; - $returnData->body = $this->errorString; - - $this->client->expects($this->once()) - ->method('post', $xml, $header) - ->with($path) - ->will($this->returnValue($returnData)); - - $this->object->sendMessage($recipient, $subject, $body); - } -} diff --git a/tests/unit/suites/libraries/joomla/linkedin/JLinkedinCompaniesTest.php b/tests/unit/suites/libraries/joomla/linkedin/JLinkedinCompaniesTest.php deleted file mode 100644 index d251adda5e..0000000000 --- a/tests/unit/suites/libraries/joomla/linkedin/JLinkedinCompaniesTest.php +++ /dev/null @@ -1,732 +0,0 @@ -options = new JRegistry; - $this->input = new JInput; - $this->client = $this->getMock('JHttp', array('get', 'post', 'delete', 'put')); - $this->oauth = new JLinkedinOauth($this->options, $this->client, $this->input); - $this->oauth->setToken(array('key' => $key, 'secret' => $secret)); - - $this->object = new JLinkedinCompanies($this->options, $this->client, $this->oauth); - - $this->options->set('consumer_key', $key); - $this->options->set('consumer_secret', $secret); - $this->options->set('callback', $my_url); - } - - /** - * Tears down the fixture, for example, closes a network connection. - * This method is called after a test is executed. - * - * @return void - */ - protected function tearDown() - { - } - - /** - * Provides test data for request format detection. - * - * @return array - * - * @since 13.1 - */ - public function seedGetCompanies() - { - // Company id, company name, email-domain - return array( - array(123345, null, null), - array(12345, 'example', null), - array(null, 'example', null), - array(null, null, 'example.com'), - array(null, null, null) - ); - } - - /** - * Tests the getCompanies method - * - * @param integer $id The unique internal numeric company identifier. - * @param string $name The unique string identifier for a company. - * @param string $domain Company email domains. - * - * @return void - * - * @dataProvider seedGetCompanies - * @since 13.1 - */ - public function testGetCompanies($id, $name, $domain) - { - $fields = '(id,name,ticker,description)'; - - if ($id == null && $name == null && $domain == null) - { - $this->setExpectedException('RuntimeException'); - $this->object->getCompanies($id, $name, $domain, $fields); - } - - // Set request parameters. - $data['format'] = 'json'; - - $path = '/v1/companies'; - - if ($id && $name) - { - $path .= '::(' . $id . ',universal-name=' . $name . ')'; - } - elseif ($id) - { - $path .= '/' . $id; - } - elseif ($name) - { - $path .= '/universal-name=' . $name; - } - - if ($domain) - { - $data['email-domain'] = $domain; - } - - $path .= ':' . $fields; - - $returnData = new stdClass; - $returnData->code = 200; - $returnData->body = $this->sampleString; - - $path = $this->oauth->toUrl($path, $data); - - $this->client->expects($this->once()) - ->method('get') - ->with($path) - ->will($this->returnValue($returnData)); - - $this->assertThat( - $this->object->getCompanies($id, $name, $domain, $fields), - $this->equalTo(json_decode($this->sampleString)) - ); - } - - /** - * Tests the getCompanies method - failure - * - * @return void - * - * @expectedException DomainException - * @since 13.1 - */ - public function testGetCompaniesFailure() - { - $id = 12345; - $name = 'example'; - $domain = 'example.com'; - $fields = '(id,name,ticker,description)'; - - // Set request parameters. - $data['format'] = 'json'; - $data['email-domain'] = $domain; - - $path = '/v1/companies::(' . $id . ',universal-name=' . $name . '):' . $fields; - - $returnData = new stdClass; - $returnData->code = 401; - $returnData->body = $this->errorString; - - $path = $this->oauth->toUrl($path, $data); - - $this->client->expects($this->once()) - ->method('get') - ->with($path) - ->will($this->returnValue($returnData)); - - $this->object->getCompanies($id, $name, $domain, $fields); - } - - /** - * Tests the getUpdates method - * - * @return void - * - * @since 13.1 - */ - public function testGetUpdates() - { - $id = 12345; - $type = 'new-hire'; - $count = 10; - $start = 1; - - // Set request parameters. - $data['format'] = 'json'; - $data['event-type'] = $type; - $data['count'] = $count; - $data['start'] = $start; - - $path = '/v1/companies/' . $id . '/updates'; - - $returnData = new stdClass; - $returnData->code = 200; - $returnData->body = $this->sampleString; - - $path = $this->oauth->toUrl($path, $data); - - $this->client->expects($this->once()) - ->method('get') - ->with($path) - ->will($this->returnValue($returnData)); - - $this->assertThat( - $this->object->getUpdates($id, $type, $count, $start), - $this->equalTo(json_decode($this->sampleString)) - ); - } - - /** - * Tests the getUpdates method - failure - * - * @return void - * - * @expectedException DomainException - * @since 13.1 - */ - public function testGetUpdatesFailure() - { - $id = 12345; - $type = 'new-hire'; - $count = 10; - $start = 1; - - // Set request parameters. - $data['format'] = 'json'; - $data['event-type'] = $type; - $data['count'] = $count; - $data['start'] = $start; - - $path = '/v1/companies/' . $id . '/updates'; - - $returnData = new stdClass; - $returnData->code = 401; - $returnData->body = $this->errorString; - - $path = $this->oauth->toUrl($path, $data); - - $this->client->expects($this->once()) - ->method('get') - ->with($path) - ->will($this->returnValue($returnData)); - - $this->object->getUpdates($id, $type, $count, $start); - } - - /** - * Tests the search method - * - * @return void - * - * @since 13.1 - */ - public function testSearch() - { - $fields = '(facets)'; - $keywords = 'linkedin'; - $hq = true; - $facets = 'location,industry,network,company-size,num-followers-range,fortune'; - $facet = array('us-84', 47, 'F', 'B', 100, 100); - $start = 1; - $count = 50; - $sort = 'relevance'; - - // Set request parameters. - $data['format'] = 'json'; - $data['keywords'] = $keywords; - $data['hq-only'] = $hq; - $data['facets'] = $facets; - $data['facet'] = array(); - $data['facet'][] = 'location,' . $facet[0]; - $data['facet'][] = 'industry,' . $facet[1]; - $data['facet'][] = 'network,' . $facet[2]; - $data['facet'][] = 'company-size,' . $facet[3]; - $data['facet'][] = 'num-followers-range,' . $facet[4]; - $data['facet'][] = 'fortune,' . $facet[5]; - - $data['start'] = $start; - $data['count'] = $count; - $data['sort'] = $sort; - - $path = '/v1/company-search'; - - $path .= ':' . $fields; - - $returnData = new stdClass; - $returnData->code = 200; - $returnData->body = $this->sampleString; - - $path = $this->oauth->toUrl($path, $data); - - $this->client->expects($this->once()) - ->method('get') - ->with($path) - ->will($this->returnValue($returnData)); - - $this->assertThat( - $this->object->search($fields, $keywords, $hq, $facets, $facet, $start, $count, $sort), - $this->equalTo(json_decode($this->sampleString)) - ); - } - - /** - * Tests the search method - failure - * - * @return void - * - * @expectedException DomainException - * @since 13.1 - */ - public function testSearchFailure() - { - $fields = '(facets)'; - $keywords = 'linkedin'; - $hq = true; - $facets = 'location,industry,network,company-size,num-followers-range,fortune'; - $facet = array('us-84', 47, 'F', 'B', 100, 100); - $start = 1; - $count = 50; - $sort = 'relevance'; - - // Set request parameters. - $data['format'] = 'json'; - $data['keywords'] = $keywords; - $data['hq-only'] = $hq; - $data['facets'] = $facets; - $data['facet'] = array(); - $data['facet'][] = 'location,' . $facet[0]; - $data['facet'][] = 'industry,' . $facet[1]; - $data['facet'][] = 'network,' . $facet[2]; - $data['facet'][] = 'company-size,' . $facet[3]; - $data['facet'][] = 'num-followers-range,' . $facet[4]; - $data['facet'][] = 'fortune,' . $facet[5]; - - $data['start'] = $start; - $data['count'] = $count; - $data['sort'] = $sort; - - $path = '/v1/company-search:' . $fields; - - $returnData = new stdClass; - $returnData->code = 401; - $returnData->body = $this->errorString; - - $path = $this->oauth->toUrl($path, $data); - - $this->client->expects($this->once()) - ->method('get') - ->with($path) - ->will($this->returnValue($returnData)); - - $this->object->search($fields, $keywords, $hq, $facets, $facet, $start, $count, $sort); - } - - /** - * Tests the getFollowed method - * - * @return void - * - * @since 13.1 - */ - public function testGetFollowed() - { - $fields = '(id,name,email-domains)'; - - // Set request parameters. - $data['format'] = 'json'; - - $path = '/v1/people/~/following/companies:' . $fields; - - $returnData = new stdClass; - $returnData->code = 200; - $returnData->body = $this->sampleString; - - $path = $this->oauth->toUrl($path, $data); - - $this->client->expects($this->once()) - ->method('get') - ->with($path) - ->will($this->returnValue($returnData)); - - $this->assertThat( - $this->object->getFollowed($fields), - $this->equalTo(json_decode($this->sampleString)) - ); - } - - /** - * Tests the getFollowed method - failure - * - * @return void - * - * @expectedException DomainException - * @since 13.1 - */ - public function testGetFollowedFailure() - { - $fields = '(id,name,email-domains)'; - - // Set request parameters. - $data['format'] = 'json'; - - $path = '/v1/people/~/following/companies:' . $fields; - - $returnData = new stdClass; - $returnData->code = 401; - $returnData->body = $this->errorString; - - $path = $this->oauth->toUrl($path, $data); - - $this->client->expects($this->once()) - ->method('get') - ->with($path) - ->will($this->returnValue($returnData)); - - $this->object->getFollowed($fields); - } - - /** - * Tests the follow method - * - * @return void - * - * @since 13.1 - */ - public function testFollow() - { - $id = '12345'; - - $path = '/v1/people/~/following/companies'; - - $xml = '' . $id . ''; - - $header['Content-Type'] = 'text/xml'; - - $returnData = new stdClass; - $returnData->code = 201; - $returnData->body = $this->sampleString; - - $this->client->expects($this->once()) - ->method('post', $xml, $header) - ->with($path) - ->will($this->returnValue($returnData)); - - $this->assertThat( - $this->object->follow($id), - $this->equalTo($returnData) - ); - } - - /** - * Tests the follow method - failure - * - * @return void - * - * @expectedException DomainException - * @since 13.1 - */ - public function testFollowFailure() - { - $id = '12345'; - - $path = '/v1/people/~/following/companies'; - - $xml = '' . $id . ''; - - $header['Content-Type'] = 'text/xml'; - - $returnData = new stdClass; - $returnData->code = 401; - $returnData->body = $this->errorString; - - $this->client->expects($this->once()) - ->method('post', $xml, $header) - ->with($path) - ->will($this->returnValue($returnData)); - - $this->object->follow($id); - } - - /** - * Tests the unfollow method - * - * @return void - * - * @since 13.1 - */ - public function testUnfollow() - { - $id = '12345'; - - $path = '/v1/people/~/following/companies/id=' . $id; - - $returnData = new stdClass; - $returnData->code = 204; - $returnData->body = $this->sampleString; - - $this->client->expects($this->once()) - ->method('delete') - ->with($path) - ->will($this->returnValue($returnData)); - - $this->assertThat( - $this->object->unfollow($id), - $this->equalTo($returnData) - ); - } - - /** - * Tests the unfollow method - failure - * - * @return void - * - * @expectedException DomainException - * @since 13.1 - */ - public function testUnfollowFailure() - { - $id = '12345'; - - $path = '/v1/people/~/following/companies/id=' . $id; - - $returnData = new stdClass; - $returnData->code = 401; - $returnData->body = $this->errorString; - - $this->client->expects($this->once()) - ->method('delete') - ->with($path) - ->will($this->returnValue($returnData)); - - $this->object->unfollow($id); - } - - /** - * Tests the getSuggested method - * - * @return void - * - * @since 13.1 - */ - public function testGetSuggested() - { - $fields = '(id,name,email-domains)'; - $start = 1; - $count = 10; - - // Set request parameters. - $data['format'] = 'json'; - $data['start'] = $start; - $data['count'] = $count; - - $path = '/v1/people/~/suggestions/to-follow/companies:' . $fields; - - $returnData = new stdClass; - $returnData->code = 200; - $returnData->body = $this->sampleString; - - $path = $this->oauth->toUrl($path, $data); - - $this->client->expects($this->once()) - ->method('get') - ->with($path) - ->will($this->returnValue($returnData)); - - $this->assertThat( - $this->object->getSuggested($fields, $start, $count), - $this->equalTo(json_decode($this->sampleString)) - ); - } - - /** - * Tests the getSuggested method - failure - * - * @return void - * - * @expectedException DomainException - * @since 13.1 - */ - public function testGetSuggestedFailure() - { - $fields = '(id,name,email-domains)'; - $start = 1; - $count = 10; - - // Set request parameters. - $data['format'] = 'json'; - $data['start'] = $start; - $data['count'] = $count; - - $path = '/v1/people/~/suggestions/to-follow/companies:' . $fields; - - $returnData = new stdClass; - $returnData->code = 401; - $returnData->body = $this->errorString; - - $path = $this->oauth->toUrl($path, $data); - - $this->client->expects($this->once()) - ->method('get') - ->with($path) - ->will($this->returnValue($returnData)); - - $this->object->getSuggested($fields, $start, $count); - } - - /** - * Tests the getProducts method - * - * @return void - * - * @since 13.1 - */ - public function testGetProducts() - { - $id = 12345; - $fields = '(id,name,type,creation-timestamp)'; - $start = 1; - $count = 10; - - // Set request parameters. - $data['format'] = 'json'; - $data['start'] = $start; - $data['count'] = $count; - - $path = '/v1/companies/' . $id . '/products:' . $fields; - - $returnData = new stdClass; - $returnData->code = 200; - $returnData->body = $this->sampleString; - - $path = $this->oauth->toUrl($path, $data); - - $this->client->expects($this->once()) - ->method('get') - ->with($path) - ->will($this->returnValue($returnData)); - - $this->assertThat( - $this->object->getProducts($id, $fields, $start, $count), - $this->equalTo(json_decode($this->sampleString)) - ); - } - - /** - * Tests the getProducts method - failure - * - * @return void - * - * @expectedException DomainException - * @since 13.1 - */ - public function testGetProductsFailure() - { - $id = 12345; - $fields = '(id,name,type,creation-timestamp)'; - $start = 1; - $count = 10; - - // Set request parameters. - $data['format'] = 'json'; - $data['start'] = $start; - $data['count'] = $count; - - $path = '/v1/companies/' . $id . '/products:' . $fields; - - $returnData = new stdClass; - $returnData->code = 401; - $returnData->body = $this->errorString; - - $path = $this->oauth->toUrl($path, $data); - - $this->client->expects($this->once()) - ->method('get') - ->with($path) - ->will($this->returnValue($returnData)); - - $this->object->getProducts($id, $fields, $start, $count); - } -} diff --git a/tests/unit/suites/libraries/joomla/linkedin/JLinkedinGroupsTest.php b/tests/unit/suites/libraries/joomla/linkedin/JLinkedinGroupsTest.php deleted file mode 100644 index 157af2ef9e..0000000000 --- a/tests/unit/suites/libraries/joomla/linkedin/JLinkedinGroupsTest.php +++ /dev/null @@ -1,1748 +0,0 @@ -options = new JRegistry; - $this->input = new JInput; - $this->client = $this->getMock('JHttp', array('get', 'post', 'delete', 'put')); - $this->oauth = new JLinkedinOauth($this->options, $this->client, $this->input); - $this->oauth->setToken(array('key' => $key, 'secret' => $secret)); - - $this->object = new JLinkedinGroups($this->options, $this->client, $this->oauth); - - $this->options->set('consumer_key', $key); - $this->options->set('consumer_secret', $secret); - $this->options->set('callback', $my_url); - } - - /** - * Tears down the fixture, for example, closes a network connection. - * This method is called after a test is executed. - * - * @return void - */ - protected function tearDown() - { - } - - /** - * Tests the getGroup method - * - * @return void - * - * @since 13.1 - */ - public function testGetGroup() - { - $id = '12345'; - $fields = '(id,name,short-description,description,relation-to-viewer:(membership-state,available-actions),is-open-to-non-members)'; - $start = 1; - $count = 10; - - // Set request parameters. - $data['format'] = 'json'; - $data['start'] = $start; - $data['count'] = $count; - - $path = '/v1/groups/' . $id; - - $path .= ':' . $fields; - - $returnData = new stdClass; - $returnData->code = 200; - $returnData->body = $this->sampleString; - - $path = $this->oauth->toUrl($path, $data); - - $this->client->expects($this->once()) - ->method('get') - ->with($path) - ->will($this->returnValue($returnData)); - - $this->assertThat( - $this->object->getGroup($id, $fields, $start, $count), - $this->equalTo(json_decode($this->sampleString)) - ); - } - - /** - * Tests the getGroup method - failure - * - * @return void - * - * @since 13.1 - * @expectedException DomainException - */ - public function testGetGroupFailure() - { - $id = '12345'; - $fields = '(id,name,short-description,description,relation-to-viewer:(membership-state,available-actions),is-open-to-non-members)'; - $start = 1; - $count = 10; - - // Set request parameters. - $data['format'] = 'json'; - $data['start'] = $start; - $data['count'] = $count; - - $path = '/v1/groups/' . $id; - $path .= ':' . $fields; - - $returnData = new stdClass; - $returnData->code = 401; - $returnData->body = $this->errorString; - - $path = $this->oauth->toUrl($path, $data); - - $this->client->expects($this->once()) - ->method('get') - ->with($path) - ->will($this->returnValue($returnData)); - - $this->object->getGroup($id, $fields, $start, $count); - } - - /** - * Provides test data for request format detection. - * - * @return array - * - * @since 13.1 - */ - public function seedId() - { - // Member ID - return array( - array('lcnIwDU0S6'), - array(null) - ); - } - - /** - * Tests the getMemberships method - * - * @param string $person_id The unique identifier for a user. - * - * @return void - * - * @dataProvider seedId - * @since 13.1 - */ - public function testGetMemberships($person_id) - { - $fields = '(id,name,short-description,description,relation-to-viewer:(membership-state,available-actions),is-open-to-non-members)'; - $start = 1; - $count = 10; - $membership_state = 'member'; - - // Set request parameters. - $data['format'] = 'json'; - $data['start'] = $start; - $data['count'] = $count; - $data['membership-state'] = $membership_state; - - if ($person_id) - { - $path = '/v1/people/' . $person_id . '/group-memberships'; - } - else - { - $path = '/v1/people/~/group-memberships'; - } - - $path .= ':' . $fields; - - $returnData = new stdClass; - $returnData->code = 200; - $returnData->body = $this->sampleString; - - $path = $this->oauth->toUrl($path, $data); - - $this->client->expects($this->once()) - ->method('get') - ->with($path) - ->will($this->returnValue($returnData)); - - $this->assertThat( - $this->object->getMemberships($person_id, $fields, $start, $count, $membership_state), - $this->equalTo(json_decode($this->sampleString)) - ); - } - - /** - * Tests the getMemberships method - failure - * - * @param string $person_id The unique identifier for a user. - * - * @return void - * - * @dataProvider seedId - * @expectedException DomainException - * @since 13.1 - */ - public function testGetMembershipsFailure($person_id) - { - $fields = '(id,name,short-description,description,relation-to-viewer:(membership-state,available-actions),is-open-to-non-members)'; - $start = 1; - $count = 10; - $membership_state = 'member'; - - // Set request parameters. - $data['format'] = 'json'; - $data['start'] = $start; - $data['count'] = $count; - $data['membership-state'] = $membership_state; - - if ($person_id) - { - $path = '/v1/people/' . $person_id . '/group-memberships'; - } - else - { - $path = '/v1/people/~/group-memberships'; - } - - $path .= ':' . $fields; - - $returnData = new stdClass; - $returnData->code = 401; - $returnData->body = $this->errorString; - - $path = $this->oauth->toUrl($path, $data); - - $this->client->expects($this->once()) - ->method('get') - ->with($path) - ->will($this->returnValue($returnData)); - - $this->object->getMemberships($person_id, $fields, $start, $count, $membership_state); - } - - /** - * Tests the getSettings method - * - * @param string $person_id The unique identifier for a user. - * - * @return void - * - * @dataProvider seedId - * @since 13.1 - */ - public function testGetSettings($person_id) - { - $group_id = '12345'; - $fields = '(group:(id,name),membership-state,email-digest-frequency,email-announcements-from-managers, - allow-messages-from-members,email-for-every-new-post)'; - $start = 1; - $count = 10; - - // Set request parameters. - $data['format'] = 'json'; - $data['start'] = $start; - $data['count'] = $count; - - if ($person_id) - { - $path = '/v1/people/' . $person_id . '/group-memberships'; - } - else - { - $path = '/v1/people/~/group-memberships'; - } - - $path .= '/' . $group_id; - - $path .= ':' . $fields; - - $returnData = new stdClass; - $returnData->code = 200; - $returnData->body = $this->sampleString; - - $path = $this->oauth->toUrl($path, $data); - - $this->client->expects($this->once()) - ->method('get') - ->with($path) - ->will($this->returnValue($returnData)); - - $this->assertThat( - $this->object->getSettings($person_id, $group_id, $fields, $start, $count), - $this->equalTo(json_decode($this->sampleString)) - ); - } - - /** - * Tests the getSettings method - failure - * - * @param string $person_id The unique identifier for a user. - * - * @return void - * - * @dataProvider seedId - * @expectedException DomainException - * @since 13.1 - */ - public function testGetSettingsFailure($person_id) - { - $group_id = '12345'; - $fields = '(group:(id,name),membership-state,email-digest-frequency,email-announcements-from-managers, - allow-messages-from-members,email-for-every-new-post)'; - $start = 1; - $count = 10; - - // Set request parameters. - $data['format'] = 'json'; - $data['start'] = $start; - $data['count'] = $count; - - if ($person_id) - { - $path = '/v1/people/' . $person_id . '/group-memberships'; - } - else - { - $path = '/v1/people/~/group-memberships'; - } - - $path .= '/' . $group_id; - - $path .= ':' . $fields; - - $returnData = new stdClass; - $returnData->code = 401; - $returnData->body = $this->errorString; - - $path = $this->oauth->toUrl($path, $data); - - $this->client->expects($this->once()) - ->method('get') - ->with($path) - ->will($this->returnValue($returnData)); - - $this->object->getSettings($person_id, $group_id, $fields, $start, $count); - } - - /** - * Tests the changeSettings method - * - * @return void - * - * @since 13.1 - */ - public function testChangeSettings() - { - $group_id = '12345'; - $show_logo = true; - $digest_frequency = 'daily'; - $announcements = true; - $allow_messages = true; - $new_post = true; - - $path = '/v1/people/~/group-memberships/' . $group_id; - - $xml = ' - true - - daily - - true - true - true - '; - - $header['Content-Type'] = 'text/xml'; - - $returnData = new stdClass; - $returnData->code = 200; - $returnData->body = $this->sampleString; - - $this->client->expects($this->once()) - ->method('put', $xml, $header) - ->with($path) - ->will($this->returnValue($returnData)); - - $this->assertThat( - $this->object->changeSettings($group_id, $show_logo, $digest_frequency, $announcements, $allow_messages, $new_post), - $this->equalTo($returnData) - ); - } - - /** - * Tests the changeSettings method - failure - * - * @return void - * - * @expectedException DomainException - * @since 13.1 - */ - public function testChangeSettingsFailure() - { - $group_id = '12345'; - $show_logo = true; - $digest_frequency = 'daily'; - $announcements = true; - $allow_messages = true; - $new_post = true; - - $path = '/v1/people/~/group-memberships/' . $group_id; - - $xml = ' - true - - daily - - true - true - true - '; - - $header['Content-Type'] = 'text/xml'; - - $returnData = new stdClass; - $returnData->code = 403; - $returnData->body = 'Throttle limit for calls to this resource is reached.'; - - $this->client->expects($this->once()) - ->method('put', $xml, $header) - ->with($path) - ->will($this->returnValue($returnData)); - - $this->object->changeSettings($group_id, $show_logo, $digest_frequency, $announcements, $allow_messages, $new_post); - } - - /** - * Tests the joinGroup method - * - * @return void - * - * @since 13.1 - */ - public function testJoinGroup() - { - $group_id = '12345'; - $show_logo = true; - $digest_frequency = 'daily'; - $announcements = true; - $allow_messages = true; - $new_post = true; - - $path = '/v1/people/~/group-memberships'; - - $xml = ' - - ' . $group_id . ' - - true - - daily - - true - true - false - - member - - '; - - $header['Content-Type'] = 'text/xml'; - - $returnData = new stdClass; - $returnData->code = 201; - $returnData->body = $this->sampleString; - - $this->client->expects($this->once()) - ->method('post', $xml, $header) - ->with($path) - ->will($this->returnValue($returnData)); - - $this->assertThat( - $this->object->joinGroup($group_id, $show_logo, $digest_frequency, $announcements, $allow_messages, $new_post), - $this->equalTo($returnData) - ); - } - - /** - * Tests the joinGroup method - failure - * - * @return void - * - * @expectedException DomainException - * @since 13.1 - */ - public function testJoinGroupFailure() - { - $group_id = '12345'; - $show_logo = true; - $digest_frequency = 'daily'; - $announcements = true; - $allow_messages = true; - $new_post = true; - - $path = '/v1/people/~/group-memberships'; - - $xml = ' - - ' . $group_id . ' - - true - - daily - - true - true - false - - member - - '; - - $header['Content-Type'] = 'text/xml'; - - $returnData = new stdClass; - $returnData->code = 403; - $returnData->body = 'Throttle limit for calls to this resource is reached.'; - - $this->client->expects($this->once()) - ->method('post', $xml, $header) - ->with($path) - ->will($this->returnValue($returnData)); - - $this->object->joinGroup($group_id, $show_logo, $digest_frequency, $announcements, $allow_messages, $new_post); - } - - /** - * Tests the leaveGroup method - * - * @return void - * - * @since 13.1 - */ - public function testLeaveGroup() - { - $group_id = '12345'; - - $path = '/v1/people/~/group-memberships/' . $group_id; - - $returnData = new stdClass; - $returnData->code = 204; - $returnData->body = $this->sampleString; - - $this->client->expects($this->once()) - ->method('delete') - ->with($path) - ->will($this->returnValue($returnData)); - - $this->assertThat( - $this->object->leaveGroup($group_id), - $this->equalTo($returnData) - ); - } - - /** - * Tests the leaveGroup method - failure - * - * @return void - * - * @expectedException DomainException - * @since 13.1 - */ - public function testLeaveGroupFailure() - { - $group_id = '12345'; - - $path = '/v1/people/~/group-memberships/' . $group_id; - - $returnData = new stdClass; - $returnData->code = 401; - $returnData->body = 'unauthorized'; - - $this->client->expects($this->once()) - ->method('delete') - ->with($path) - ->will($this->returnValue($returnData)); - - $this->object->leaveGroup($group_id); - } - - /** - * Tests the getDiscussions method - * - * @return void - * - * @since 13.1 - */ - public function testGetDiscussions() - { - $id = '12345'; - $fields = '(creation-timestamp,title,summary,creator:(first-name,last-name),likes,attachment:(content-url,title),relation-to-viewer)'; - $start = 1; - $count = 10; - $order = 'recency'; - $category = 'discussion'; - $modified_since = '1302727083000'; - - // Set request parameters. - $data['format'] = 'json'; - $data['start'] = $start; - $data['count'] = $count; - $data['order'] = $order; - $data['category'] = $category; - $data['modified-since'] = $modified_since; - - $path = '/v1/groups/' . $id . '/posts'; - - $path .= ':' . $fields; - - $returnData = new stdClass; - $returnData->code = 200; - $returnData->body = $this->sampleString; - - $path = $this->oauth->toUrl($path, $data); - - $this->client->expects($this->once()) - ->method('get') - ->with($path) - ->will($this->returnValue($returnData)); - - $this->assertThat( - $this->object->getDiscussions($id, $fields, $start, $count, $order, $category, $modified_since), - $this->equalTo(json_decode($this->sampleString)) - ); - } - - /** - * Tests the getDiscussions method - failure - * - * @return void - * - * @expectedException DomainException - * @since 13.1 - */ - public function testGetDiscussionsFailure() - { - $id = '12345'; - $fields = '(creation-timestamp,title,summary,creator:(first-name,last-name),likes,attachment:(content-url,title),relation-to-viewer)'; - $start = 1; - $count = 10; - $order = 'recency'; - $category = 'discussion'; - $modified_since = '1302727083000'; - - // Set request parameters. - $data['format'] = 'json'; - $data['start'] = $start; - $data['count'] = $count; - $data['order'] = $order; - $data['category'] = $category; - $data['modified-since'] = $modified_since; - - $path = '/v1/groups/' . $id . '/posts'; - - $path .= ':' . $fields; - - $returnData = new stdClass; - $returnData->code = 401; - $returnData->body = $this->errorString; - - $path = $this->oauth->toUrl($path, $data); - - $this->client->expects($this->once()) - ->method('get') - ->with($path) - ->will($this->returnValue($returnData)); - - $this->object->getDiscussions($id, $fields, $start, $count, $order, $category, $modified_since); - } - - /** - * Tests the getUserPosts method - * - * @param string $person_id The unique identifier for a user. - * - * @return void - * - * @dataProvider seedId - * @since 13.1 - */ - public function testGetUserPosts($person_id) - { - $group_id = '12345'; - $role = 'creator'; - $fields = '(creation-timestamp,title,summary,creator:(first-name,last-name),likes,attachment:(content-url,title),relation-to-viewer)'; - $start = 1; - $count = 10; - $order = 'recency'; - $category = 'discussion'; - $modified_since = '1302727083000'; - - // Set request parameters. - $data['format'] = 'json'; - $data['role'] = $role; - $data['start'] = $start; - $data['count'] = $count; - $data['order'] = $order; - $data['category'] = $category; - $data['modified-since'] = $modified_since; - - if ($person_id) - { - $path = '/v1/people/' . $person_id . '/group-memberships/' . $group_id . '/posts'; - } - else - { - $path = '/v1/people/~/group-memberships/' . $group_id . '/posts'; - } - - $path .= ':' . $fields; - - $returnData = new stdClass; - $returnData->code = 200; - $returnData->body = $this->sampleString; - - $path = $this->oauth->toUrl($path, $data); - - $this->client->expects($this->once()) - ->method('get') - ->with($path) - ->will($this->returnValue($returnData)); - - $this->assertThat( - $this->object->getUserPosts($group_id, $role, $person_id, $fields, $start, $count, $order, $category, $modified_since), - $this->equalTo(json_decode($this->sampleString)) - ); - } - - /** - * Tests the getUserPosts method - failure - * - * @return void - * - * @expectedException DomainException - * @since 13.1 - */ - public function testGetUserPostsFailure() - { - $group_id = '12345'; - $role = 'creator'; - $person_id = '123345456'; - $fields = '(creation-timestamp,title,summary,creator:(first-name,last-name),likes,attachment:(content-url,title),relation-to-viewer)'; - $start = 1; - $count = 10; - $order = 'recency'; - $category = 'discussion'; - $modified_since = '1302727083000'; - - // Set request parameters. - $data['format'] = 'json'; - $data['role'] = $role; - $data['start'] = $start; - $data['count'] = $count; - $data['order'] = $order; - $data['category'] = $category; - $data['modified-since'] = $modified_since; - - $path = '/v1/people/' . $person_id . '/group-memberships/' . $group_id . '/posts'; - - $path .= ':' . $fields; - - $returnData = new stdClass; - $returnData->code = 401; - $returnData->body = $this->errorString; - - $path = $this->oauth->toUrl($path, $data); - - $this->client->expects($this->once()) - ->method('get') - ->with($path) - ->will($this->returnValue($returnData)); - - $this->object->getUserPosts($group_id, $role, $person_id, $fields, $start, $count, $order, $category, $modified_since); - } - - /** - * Tests the getPost method - * - * @return void - * - * @since 13.1 - */ - public function testGetPost() - { - $post_id = 'g-12345'; - $fields = '(id,type,category,creator,title,relation-to-viewer:(is-following,is-liked),likes,comments,site-group-post-url)'; - - // Set request parameters. - $data['format'] = 'json'; - - $path = '/v1/posts/' . $post_id; - - $path .= ':' . $fields; - - $returnData = new stdClass; - $returnData->code = 200; - $returnData->body = $this->sampleString; - - $path = $this->oauth->toUrl($path, $data); - - $this->client->expects($this->once()) - ->method('get') - ->with($path) - ->will($this->returnValue($returnData)); - - $this->assertThat( - $this->object->getPost($post_id, $fields), - $this->equalTo(json_decode($this->sampleString)) - ); - } - - /** - * Tests the getPost method - failure - * - * @return void - * - * @expectedException DomainException - * @since 13.1 - */ - public function testGetPostFailure() - { - $post_id = 'g-12345'; - $fields = '(id,type,category,creator,title,relation-to-viewer:(is-following,is-liked),likes,comments,site-group-post-url)'; - - // Set request parameters. - $data['format'] = 'json'; - - $path = '/v1/posts/' . $post_id; - - $path .= ':' . $fields; - - $returnData = new stdClass; - $returnData->code = 401; - $returnData->body = $this->errorString; - - $path = $this->oauth->toUrl($path, $data); - - $this->client->expects($this->once()) - ->method('get') - ->with($path) - ->will($this->returnValue($returnData)); - - $this->object->getPost($post_id, $fields); - } - - /** - * Tests the getPostComments method - * - * @return void - * - * @since 13.1 - */ - public function testGetPostComments() - { - $post_id = 'g-12345'; - $fields = '(creator:(first-name,last-name,picture-url),creation-timestamp,text))'; - $start = 1; - $count = 5; - - // Set request parameters. - $data['format'] = 'json'; - $data['start'] = $start; - $data['count'] = $count; - - $path = '/v1/posts/' . $post_id . '/comments'; - - $path .= ':' . $fields; - - $returnData = new stdClass; - $returnData->code = 200; - $returnData->body = $this->sampleString; - - $path = $this->oauth->toUrl($path, $data); - - $this->client->expects($this->once()) - ->method('get') - ->with($path) - ->will($this->returnValue($returnData)); - - $this->assertThat( - $this->object->getPostComments($post_id, $fields, $start, $count), - $this->equalTo(json_decode($this->sampleString)) - ); - } - - /** - * Tests the getPostComments method - failure - * - * @return void - * - * @expectedException DomainException - * @since 13.1 - */ - public function testGetPostCommentsFailure() - { - $post_id = 'g-12345'; - $fields = '(creator:(first-name,last-name,picture-url),creation-timestamp,text))'; - $start = 1; - $count = 5; - - // Set request parameters. - $data['format'] = 'json'; - $data['start'] = $start; - $data['count'] = $count; - - $path = '/v1/posts/' . $post_id . '/comments'; - - $path .= ':' . $fields; - - $returnData = new stdClass; - $returnData->code = 401; - $returnData->body = $this->errorString; - - $path = $this->oauth->toUrl($path, $data); - - $this->client->expects($this->once()) - ->method('get') - ->with($path) - ->will($this->returnValue($returnData)); - - $this->object->getPostComments($post_id, $fields, $start, $count); - } - - /** - * Tests the createPost method - * - * @return void - * - * @since 13.1 - */ - public function testCreatePost() - { - $group_id = '12345'; - $title = 'post title'; - $summary = 'post summary'; - - $path = '/v1/groups/' . $group_id . '/posts'; - - $xml = '' . $title . '' . $summary . ''; - - $header['Content-Type'] = 'text/xml'; - - $returnData = new stdClass; - $returnData->code = 201; - $returnData->body = $this->sampleString; - $returnData->headers = array('Location' => 'https://api.linkedin.com/v1/posts/g_12334_234512'); - - $this->client->expects($this->once()) - ->method('post', $xml, $header) - ->with($path) - ->will($this->returnValue($returnData)); - - $this->assertThat( - $this->object->createPost($group_id, $title, $summary), - $this->equalTo('g_12334_234512') - ); - } - - /** - * Tests the createPost method - failure - * - * @return void - * - * @expectedException DomainException - * @since 13.1 - */ - public function testCreatePostFailure() - { - $group_id = '12345'; - $title = 'post title'; - $summary = 'post summary'; - - $path = '/v1/groups/' . $group_id . '/posts'; - - $xml = '' . $title . '' . $summary . ''; - - $header['Content-Type'] = 'text/xml'; - - $returnData = new stdClass; - $returnData->code = 401; - $returnData->body = $this->errorString; - - $this->client->expects($this->once()) - ->method('post', $xml, $header) - ->with($path) - ->will($this->returnValue($returnData)); - - $this->object->createPost($group_id, $title, $summary); - } - - /** - * Tests the _likeUnlike method - * - * @return void - * - * @since 13.1 - */ - public function test_likeUnlike() - { - // Method tested via requesting classes - $this->markTestSkipped('This method is tested via requesting classes.'); - } - - /** - * Tests the likePost method - * - * @return void - * - * @since 13.1 - */ - public function testLikePost() - { - $post_id = 'g_12345'; - - $path = '/v1/posts/' . $post_id . '/relation-to-viewer/is-liked'; - - $xml = 'true'; - - $header['Content-Type'] = 'text/xml'; - - $returnData = new stdClass; - $returnData->code = 204; - $returnData->body = $this->sampleString; - - $this->client->expects($this->once()) - ->method('put', $xml, $header) - ->with($path) - ->will($this->returnValue($returnData)); - - $this->assertThat( - $this->object->likePost($post_id), - $this->equalTo($returnData) - ); - } - - /** - * Tests the likePost method - failure - * - * @return void - * - * @expectedException DomainException - * @since 13.1 - */ - public function testLikePostFailure() - { - $post_id = 'g_12345'; - - $path = '/v1/posts/' . $post_id . '/relation-to-viewer/is-liked'; - - $xml = 'true'; - - $header['Content-Type'] = 'text/xml'; - - $returnData = new stdClass; - $returnData->code = 401; - $returnData->body = $this->errorString; - - $this->client->expects($this->once()) - ->method('put', $xml, $header) - ->with($path) - ->will($this->returnValue($returnData)); - - $this->object->likePost($post_id); - } - - /** - * Tests the unlikePost method - * - * @return void - * - * @since 13.1 - */ - public function testUnlikePost() - { - $post_id = 'g_12345'; - - $path = '/v1/posts/' . $post_id . '/relation-to-viewer/is-liked'; - - $xml = 'false'; - - $header['Content-Type'] = 'text/xml'; - - $returnData = new stdClass; - $returnData->code = 204; - $returnData->body = $this->sampleString; - - $this->client->expects($this->once()) - ->method('put', $xml, $header) - ->with($path) - ->will($this->returnValue($returnData)); - - $this->assertThat( - $this->object->unlikePost($post_id), - $this->equalTo($returnData) - ); - } - - /** - * Tests the _followUnfollow method - * - * @return void - * - * @since 13.1 - */ - public function test_followUnfollow() - { - // Method tested via requesting classes - $this->markTestSkipped('This method is tested via requesting classes.'); - } - - /** - * Tests the followPost method - * - * @return void - * - * @since 13.1 - */ - public function testFollowPost() - { - $post_id = 'g_12345'; - - $path = '/v1/posts/' . $post_id . '/relation-to-viewer/is-following'; - - $xml = 'true'; - - $header['Content-Type'] = 'text/xml'; - - $returnData = new stdClass; - $returnData->code = 204; - $returnData->body = $this->sampleString; - - $this->client->expects($this->once()) - ->method('put', $xml, $header) - ->with($path) - ->will($this->returnValue($returnData)); - - $this->assertThat( - $this->object->followPost($post_id), - $this->equalTo($returnData) - ); - } - - /** - * Tests the followPost method - failure - * - * @return void - * - * @expectedException DomainException - * @since 13.1 - */ - public function testFollowPostFailure() - { - $post_id = 'g_12345'; - - $path = '/v1/posts/' . $post_id . '/relation-to-viewer/is-following'; - - $xml = 'true'; - - $header['Content-Type'] = 'text/xml'; - - $returnData = new stdClass; - $returnData->code = 401; - $returnData->body = $this->errorString; - - $this->client->expects($this->once()) - ->method('put', $xml, $header) - ->with($path) - ->will($this->returnValue($returnData)); - - $this->object->followPost($post_id); - } - - /** - * Tests the unfollowPost method - * - * @return void - * - * @since 13.1 - */ - public function testUnfollowPost() - { - $post_id = 'g_12345'; - - $path = '/v1/posts/' . $post_id . '/relation-to-viewer/is-following'; - - $xml = 'false'; - - $header['Content-Type'] = 'text/xml'; - - $returnData = new stdClass; - $returnData->code = 204; - $returnData->body = $this->sampleString; - - $this->client->expects($this->once()) - ->method('put', $xml, $header) - ->with($path) - ->will($this->returnValue($returnData)); - - $this->assertThat( - $this->object->unfollowPost($post_id), - $this->equalTo($returnData) - ); - } - - /** - * Tests the flagPost method - * - * @return void - * - * @since 13.1 - */ - public function testFalgPost() - { - $flag = 'promotion'; - $post_id = 'g_12345'; - - $path = '/v1/posts/' . $post_id . '/category/code'; - - $xml = '' . $flag . ''; - - $header['Content-Type'] = 'text/xml'; - - $returnData = new stdClass; - $returnData->code = 204; - $returnData->body = $this->sampleString; - - $this->client->expects($this->once()) - ->method('put', $xml, $header) - ->with($path) - ->will($this->returnValue($returnData)); - - $this->assertThat( - $this->object->flagPost($post_id, $flag), - $this->equalTo($returnData) - ); - } - - /** - * Tests the flagPost method - failure - * - * @return void - * - * @expectedException DomainException - * @since 13.1 - */ - public function testFalgPostFailure() - { - $flag = 'promotion'; - $post_id = 'g_12345'; - - $path = '/v1/posts/' . $post_id . '/category/code'; - - $xml = '' . $flag . ''; - - $header['Content-Type'] = 'text/xml'; - - $returnData = new stdClass; - $returnData->code = 401; - $returnData->body = $this->errorString; - - $this->client->expects($this->once()) - ->method('put', $xml, $header) - ->with($path) - ->will($this->returnValue($returnData)); - - $this->object->flagPost($post_id, $flag); - } - - /** - * Tests the deletePost method - * - * @return void - * - * @since 13.1 - */ - public function testDeletePost() - { - $post_id = 'g_12345'; - - $path = '/v1/posts/' . $post_id; - - $returnData = new stdClass; - $returnData->code = 204; - $returnData->body = $this->sampleString; - - $this->client->expects($this->once()) - ->method('delete') - ->with($path) - ->will($this->returnValue($returnData)); - - $this->assertThat( - $this->object->deletePost($post_id), - $this->equalTo($returnData) - ); - } - - /** - * Tests the deletePost method - failure - * - * @return void - * - * @expectedException DomainException - * @since 13.1 - */ - public function testDeletePostFailure() - { - $post_id = 'g_12345'; - - $path = '/v1/posts/' . $post_id; - - $returnData = new stdClass; - $returnData->code = 401; - $returnData->body = $this->errorString; - - $this->client->expects($this->once()) - ->method('delete') - ->with($path) - ->will($this->returnValue($returnData)); - - $this->object->deletePost($post_id); - } - - /** - * Tests the getComment method - * - * @return void - * - * @since 13.1 - */ - public function testGetComment() - { - $comment_id = 'g-12345'; - $fields = '(id,text,creator,creation-timestamp,relation-to-viewer)'; - - // Set request parameters. - $data['format'] = 'json'; - - $path = '/v1/comments/' . $comment_id; - - $path .= ':' . $fields; - - $returnData = new stdClass; - $returnData->code = 200; - $returnData->body = $this->sampleString; - - $path = $this->oauth->toUrl($path, $data); - - $this->client->expects($this->once()) - ->method('get') - ->with($path) - ->will($this->returnValue($returnData)); - - $this->assertThat( - $this->object->getComment($comment_id, $fields), - $this->equalTo(json_decode($this->sampleString)) - ); - } - - /** - * Tests the getComment method - failure - * - * @return void - * - * @expectedException DomainException - * @since 13.1 - */ - public function testGetCommentFailure() - { - $comment_id = 'g-12345'; - $fields = '(id,text,creator,creation-timestamp,relation-to-viewer)'; - - // Set request parameters. - $data['format'] = 'json'; - - $path = '/v1/comments/' . $comment_id; - - $path .= ':' . $fields; - - $returnData = new stdClass; - $returnData->code = 401; - $returnData->body = $this->errorString; - - $path = $this->oauth->toUrl($path, $data); - - $this->client->expects($this->once()) - ->method('get') - ->with($path) - ->will($this->returnValue($returnData)); - - $this->object->getComment($comment_id, $fields); - } - - /** - * Tests the addComment method - * - * @return void - * - * @since 13.1 - */ - public function testAddComment() - { - $post_id = 'g_12345'; - $comment = 'some comment'; - - $path = '/v1/posts/' . $post_id . '/comments'; - - $xml = '' . $comment . ''; - - $header['Content-Type'] = 'text/xml'; - - $returnData = new stdClass; - $returnData->code = 201; - $returnData->body = $this->sampleString; - $returnData->headers = array('Location' => 'https://api.linkedin.com/v1/comments/g_12334_234512'); - - $this->client->expects($this->once()) - ->method('post', $xml, $header) - ->with($path) - ->will($this->returnValue($returnData)); - - $this->assertThat( - $this->object->addComment($post_id, $comment), - $this->equalTo('g_12334_234512') - ); - } - - /** - * Tests the addComment method - failure - * - * @return void - * - * @expectedException DomainException - * @since 13.1 - */ - public function testAddCommentFailure() - { - $post_id = 'g_12345'; - $comment = 'some comment'; - - $path = '/v1/posts/' . $post_id . '/comments'; - - $xml = '' . $comment . ''; - - $header['Content-Type'] = 'text/xml'; - - $returnData = new stdClass; - $returnData->code = 401; - $returnData->body = $this->errorString; - - $this->client->expects($this->once()) - ->method('post', $xml, $header) - ->with($path) - ->will($this->returnValue($returnData)); - - $this->object->addComment($post_id, $comment); - } - - /** - * Tests the deleteComment method - * - * @return void - * - * @since 13.1 - */ - public function testDeleteComment() - { - $comment_id = 'g_12345'; - - $path = '/v1/comments/' . $comment_id; - - $returnData = new stdClass; - $returnData->code = 204; - $returnData->body = $this->sampleString; - - $this->client->expects($this->once()) - ->method('delete') - ->with($path) - ->will($this->returnValue($returnData)); - - $this->assertThat( - $this->object->deleteComment($comment_id), - $this->equalTo($returnData) - ); - } - - /** - * Tests the deleteComment method - failure - * - * @return void - * - * @expectedException DomainException - * @since 13.1 - */ - public function testDeleteCommentFailure() - { - $comment_id = 'g_12345'; - - $path = '/v1/comments/' . $comment_id; - - $returnData = new stdClass; - $returnData->code = 401; - $returnData->body = $this->errorString; - - $this->client->expects($this->once()) - ->method('delete') - ->with($path) - ->will($this->returnValue($returnData)); - - $this->object->deleteComment($comment_id); - } - - /** - * Tests the getSuggested method - * - * @param string $person_id The unique identifier for a user. - * - * @return void - * - * @dataProvider seedId - * @since 13.1 - */ - public function testGetSuggested($person_id) - { - $fields = '(id,name,is-open-to-non-members)'; - - // Set request parameters. - $data['format'] = 'json'; - - // Set the API base - $path = '/v1/people/'; - - if ($person_id) - { - $path .= $person_id . '/suggestions/groups'; - } - else - { - $path .= '~/suggestions/groups'; - } - - $path .= ':' . $fields; - - $returnData = new stdClass; - $returnData->code = 200; - $returnData->body = $this->sampleString; - - $path = $this->oauth->toUrl($path, $data); - - $this->client->expects($this->once()) - ->method('get') - ->with($path) - ->will($this->returnValue($returnData)); - - $this->assertThat( - $this->object->getSuggested($person_id, $fields), - $this->equalTo(json_decode($this->sampleString)) - ); - } - - /** - * Tests the getSuggested method - failure - * - * @param string $person_id The unique identifier for a user. - * - * @return void - * - * @dataProvider seedId - * @expectedException DomainException - * @since 13.1 - */ - public function testGetSuggestedFailure($person_id) - { - $fields = '(id,name,is-open-to-non-members)'; - - // Set request parameters. - $data['format'] = 'json'; - - // Set the API base - $path = '/v1/people/'; - - if ($person_id) - { - $path .= $person_id . '/suggestions/groups'; - } - else - { - $path .= '~/suggestions/groups'; - } - - $path .= ':' . $fields; - - $returnData = new stdClass; - $returnData->code = 401; - $returnData->body = $this->errorString; - - $path = $this->oauth->toUrl($path, $data); - - $this->client->expects($this->once()) - ->method('get') - ->with($path) - ->will($this->returnValue($returnData)); - - $this->object->getSuggested($person_id, $fields); - } - - /** - * Tests the deleteSuggestion method - * - * @param string $person_id The unique identifier for a user. - * - * @return void - * - * @dataProvider seedId - * @since 13.1 - */ - public function testDeleteSuggestion($person_id) - { - $suggestion_id = '12345'; - - // Set the API base - $path = '/v1/people/'; - - if ($person_id) - { - $path .= $person_id . '/suggestions/groups/' . $suggestion_id; - } - else - { - $path .= '~/suggestions/groups/' . $suggestion_id; - } - - $returnData = new stdClass; - $returnData->code = 204; - $returnData->body = $this->sampleString; - - $this->client->expects($this->once()) - ->method('delete') - ->with($path) - ->will($this->returnValue($returnData)); - - $this->assertThat( - $this->object->deleteSuggestion($suggestion_id, $person_id), - $this->equalTo($returnData) - ); - } - - /** - * Tests the deleteSuggestion method - failure - * - * @param string $person_id The unique identifier for a user. - * - * @return void - * - * @dataProvider seedId - * @expectedException DomainException - * @since 13.1 - */ - public function testDeleteSuggestionFailure($person_id) - { - $suggestion_id = '12345'; - - // Set the API base - $path = '/v1/people/'; - - if ($person_id) - { - $path .= $person_id . '/suggestions/groups/' . $suggestion_id; - } - else - { - $path .= '~/suggestions/groups/' . $suggestion_id; - } - - $returnData = new stdClass; - $returnData->code = 401; - $returnData->body = $this->errorString; - - $this->client->expects($this->once()) - ->method('delete') - ->with($path) - ->will($this->returnValue($returnData)); - - $this->object->deleteSuggestion($suggestion_id, $person_id); - } -} diff --git a/tests/unit/suites/libraries/joomla/linkedin/JLinkedinJobsTest.php b/tests/unit/suites/libraries/joomla/linkedin/JLinkedinJobsTest.php deleted file mode 100644 index 0c73e02fd6..0000000000 --- a/tests/unit/suites/libraries/joomla/linkedin/JLinkedinJobsTest.php +++ /dev/null @@ -1,554 +0,0 @@ -options = new JRegistry; - $this->input = new JInput; - $this->client = $this->getMock('JHttp', array('get', 'post', 'delete', 'put')); - $this->oauth = new JLinkedinOauth($this->options, $this->client, $this->input); - $this->oauth->setToken(array('key' => $key, 'secret' => $secret)); - - $this->object = new JLinkedinJobs($this->options, $this->client, $this->oauth); - - $this->options->set('consumer_key', $key); - $this->options->set('consumer_secret', $secret); - $this->options->set('callback', $my_url); - } - - /** - * Tears down the fixture, for example, closes a network connection. - * This method is called after a test is executed. - * - * @return void - */ - protected function tearDown() - { - } - - /** - * Tests the getJob method - * - * @return void - * - * @since 13.1 - */ - public function testGetJob() - { - $id = 12345; - $fields = '(id,company,posting-date)'; - - // Set request parameters. - $data['format'] = 'json'; - - $path = '/v1/jobs/' . $id . ':' . $fields; - - $returnData = new stdClass; - $returnData->code = 200; - $returnData->body = $this->sampleString; - - $path = $this->oauth->toUrl($path, $data); - - $this->client->expects($this->once()) - ->method('get') - ->with($path) - ->will($this->returnValue($returnData)); - - $this->assertThat( - $this->object->getJob($id, $fields), - $this->equalTo(json_decode($this->sampleString)) - ); - } - - /** - * Tests the getJob method - failure - * - * @return void - * - * @expectedException DomainException - * @since 13.1 - */ - public function testGetJobFailure() - { - $id = 12345; - $fields = '(id,company,posting-date)'; - - // Set request parameters. - $data['format'] = 'json'; - - $path = '/v1/jobs/' . $id . ':' . $fields; - - $returnData = new stdClass; - $returnData->code = 401; - $returnData->body = $this->errorString; - - $path = $this->oauth->toUrl($path, $data); - - $this->client->expects($this->once()) - ->method('get') - ->with($path) - ->will($this->returnValue($returnData)); - - $this->object->getJob($id, $fields); - } - - /** - * Tests the getBookmarked method - * - * @return void - * - * @since 13.1 - */ - public function testGetBookmarked() - { - $fields = '(id,position)'; - - // Set request parameters. - $data['format'] = 'json'; - - $path = '/v1/people/~/job-bookmarks:' . $fields; - - $returnData = new stdClass; - $returnData->code = 200; - $returnData->body = $this->sampleString; - - $path = $this->oauth->toUrl($path, $data); - - $this->client->expects($this->once()) - ->method('get') - ->with($path) - ->will($this->returnValue($returnData)); - - $this->assertThat( - $this->object->getBookmarked($fields), - $this->equalTo(json_decode($this->sampleString)) - ); - } - - /** - * Tests the getBookmarked method - failure - * - * @return void - * - * @expectedException DomainException - * @since 13.1 - */ - public function testGetBookmarkedFailure() - { - $fields = '(id,position)'; - - // Set request parameters. - $data['format'] = 'json'; - - $path = '/v1/people/~/job-bookmarks:' . $fields; - - $returnData = new stdClass; - $returnData->code = 401; - $returnData->body = $this->errorString; - - $path = $this->oauth->toUrl($path, $data); - - $this->client->expects($this->once()) - ->method('get') - ->with($path) - ->will($this->returnValue($returnData)); - - $this->object->getBookmarked($fields); - } - - /** - * Tests the bookmark method - * - * @return void - * - * @since 13.1 - */ - public function testBookmark() - { - $id = '12345'; - - $path = '/v1/people/~/job-bookmarks'; - - $xml = '' . $id . ''; - - $header['Content-Type'] = 'text/xml'; - - $returnData = new stdClass; - $returnData->code = 201; - $returnData->body = $this->sampleString; - - $this->client->expects($this->once()) - ->method('post', $xml, $header) - ->with($path) - ->will($this->returnValue($returnData)); - - $this->assertThat( - $this->object->bookmark($id), - $this->equalTo($returnData) - ); - } - - /** - * Tests the bookmark method - failure - * - * @return void - * - * @expectedException DomainException - * @since 13.1 - */ - public function testBookmarkFailure() - { - $id = '12345'; - - $path = '/v1/people/~/job-bookmarks'; - - $xml = '' . $id . ''; - - $header['Content-Type'] = 'text/xml'; - - $returnData = new stdClass; - $returnData->code = 401; - $returnData->body = $this->errorString; - - $this->client->expects($this->once()) - ->method('post', $xml, $header) - ->with($path) - ->will($this->returnValue($returnData)); - - $this->object->bookmark($id); - } - - /** - * Tests the deleteBookmark method - * - * @return void - * - * @since 13.1 - */ - public function testDeleteBookmark() - { - $id = '12345'; - - $path = '/v1/people/~/job-bookmarks/' . $id; - - $returnData = new stdClass; - $returnData->code = 204; - $returnData->body = $this->sampleString; - - $this->client->expects($this->once()) - ->method('delete') - ->with($path) - ->will($this->returnValue($returnData)); - - $this->assertThat( - $this->object->deleteBookmark($id), - $this->equalTo($returnData) - ); - } - - /** - * Tests the deleteBookmark method - failure - * - * @return void - * - * @expectedException DomainException - * @since 13.1 - */ - public function testDeleteBookmarkFailure() - { - $id = '12345'; - - $path = '/v1/people/~/job-bookmarks/' . $id; - - $returnData = new stdClass; - $returnData->code = 401; - $returnData->body = $this->errorString; - - $this->client->expects($this->once()) - ->method('delete') - ->with($path) - ->will($this->returnValue($returnData)); - - $this->object->deleteBookmark($id); - } - - /** - * Tests the getSuggested method - * - * @return void - * - * @since 13.1 - */ - public function testGetSuggested() - { - $fields = '(jobs)'; - $start = 1; - $count = 10; - - // Set request parameters. - $data['format'] = 'json'; - $data['start'] = $start; - $data['count'] = $count; - - $path = '/v1/people/~/suggestions/job-suggestions:' . $fields; - - $returnData = new stdClass; - $returnData->code = 200; - $returnData->body = $this->sampleString; - - $path = $this->oauth->toUrl($path, $data); - - $this->client->expects($this->once()) - ->method('get') - ->with($path) - ->will($this->returnValue($returnData)); - - $this->assertThat( - $this->object->getSuggested($fields, $start, $count), - $this->equalTo(json_decode($this->sampleString)) - ); - } - - /** - * Tests the getSuggested method - failure - * - * @return void - * - * @expectedException DomainException - * @since 13.1 - */ - public function testGetSuggestedFailure() - { - $fields = '(jobs)'; - $start = 1; - $count = 10; - - // Set request parameters. - $data['format'] = 'json'; - $data['start'] = $start; - $data['count'] = $count; - - $path = '/v1/people/~/suggestions/job-suggestions:' . $fields; - - $returnData = new stdClass; - $returnData->code = 401; - $returnData->body = $this->errorString; - - $path = $this->oauth->toUrl($path, $data); - - $this->client->expects($this->once()) - ->method('get') - ->with($path) - ->will($this->returnValue($returnData)); - - $this->object->getSuggested($fields, $start, $count); - } - - /** - * Tests the search method - * - * @return void - * - * @since 13.1 - */ - public function testSearch() - { - $fields = '(facets)'; - $keywords = 'quality, internet'; - $company_name = 'Google'; - $job_title = 'Software Engineer'; - $country_code = 'us'; - $postal_code = 12345; - $distance = 500; - $facets = 'company,date-posted,location,job-function,industry,salary'; - $facet = array('Google', 1232435, 'us:84', 'developer', 6, 1000); - $start = 1; - $count = 50; - $sort = 'R'; - - // Set request parameters. - $data['format'] = 'json'; - $data['keywords'] = $keywords; - $data['company-name'] = $company_name; - $data['job-title'] = $job_title; - $data['country-code'] = $country_code; - $data['postal-code'] = $postal_code; - $data['distance'] = $distance; - $data['facets'] = $facets; - $data['facet'] = array(); - $data['facet'][] = 'company,' . $this->oauth->safeEncode($facet[0]); - $data['facet'][] = 'date-posted,' . $facet[1]; - $data['facet'][] = 'location,' . $facet[2]; - $data['facet'][] = 'job-function,' . $this->oauth->safeEncode($facet[3]); - $data['facet'][] = 'industry,' . $facet[4]; - $data['facet'][] = 'salary,' . $facet[5]; - - $data['start'] = $start; - $data['count'] = $count; - $data['sort'] = $sort; - - $path = '/v1/job-search'; - - $path .= ':' . $fields; - - $returnData = new stdClass; - $returnData->code = 200; - $returnData->body = $this->sampleString; - - $path = $this->oauth->toUrl($path, $data); - - $this->client->expects($this->once()) - ->method('get') - ->with($path) - ->will($this->returnValue($returnData)); - - $this->assertThat( - $this->object->search( - $fields, $keywords, $company_name, $job_title, $country_code, $postal_code, $distance, - $facets, $facet, $start, $count, $sort - ), - $this->equalTo(json_decode($this->sampleString)) - ); - } - - /** - * Tests the search method - failure - * - * @return void - * - * @expectedException DomainException - * @since 13.1 - */ - public function testSearchFailure() - { - $fields = '(facets)'; - $keywords = 'quality, internet'; - $company_name = 'Google'; - $job_title = 'Software Engineer'; - $country_code = 'us'; - $postal_code = 12345; - $distance = 500; - $facets = 'company,date-posted,location,job-function,industry,salary'; - $facet = array('Google', 1232435, 'us:84', 'developer', 6, 1000); - $start = 1; - $count = 50; - $sort = 'R'; - - // Set request parameters. - $data['format'] = 'json'; - $data['keywords'] = $keywords; - $data['company-name'] = $company_name; - $data['job-title'] = $job_title; - $data['country-code'] = $country_code; - $data['postal-code'] = $postal_code; - $data['distance'] = $distance; - $data['facets'] = $facets; - $data['facet'] = array(); - $data['facet'][] = 'company,' . $this->oauth->safeEncode($facet[0]); - $data['facet'][] = 'date-posted,' . $facet[1]; - $data['facet'][] = 'location,' . $facet[2]; - $data['facet'][] = 'job-function,' . $this->oauth->safeEncode($facet[3]); - $data['facet'][] = 'industry,' . $facet[4]; - $data['facet'][] = 'salary,' . $facet[5]; - - $data['start'] = $start; - $data['count'] = $count; - $data['sort'] = $sort; - - $path = '/v1/job-search'; - - $path .= ':' . $fields; - - $returnData = new stdClass; - $returnData->code = 401; - $returnData->body = $this->errorString; - - $path = $this->oauth->toUrl($path, $data); - - $this->client->expects($this->once()) - ->method('get') - ->with($path) - ->will($this->returnValue($returnData)); - - $this->object->search( - $fields, $keywords, $company_name, $job_title, $country_code, $postal_code, $distance, - $facets, $facet, $start, $count, $sort - ); - } -} diff --git a/tests/unit/suites/libraries/joomla/linkedin/JLinkedinOAuthTest.php b/tests/unit/suites/libraries/joomla/linkedin/JLinkedinOAuthTest.php deleted file mode 100644 index fe95c01079..0000000000 --- a/tests/unit/suites/libraries/joomla/linkedin/JLinkedinOAuthTest.php +++ /dev/null @@ -1,150 +0,0 @@ -options = new JRegistry; - $this->input = new JInput; - $this->client = $this->getMock('JHttp', array('get', 'post', 'delete', 'put')); - - $this->options->set('consumer_key', $key); - $this->options->set('consumer_secret', $secret); - $this->options->set('callback', $my_url); - $this->oauth = new JLinkedinOauth($this->options, $this->client, $this->input); - - $this->oauth->setToken(array('key' => $key, 'secret' => $secret)); - } - - /** - * Tears down the fixture, for example, closes a network connection. - * This method is called after a test is executed. - * - * @return void - */ - protected function tearDown() - { - } - - /** - * Provides test data for request format detection. - * - * @return array - * - * @since 13.1 - */ - public function seedVerifyCredentials() - { - // Code, body, expected - return array( - array(200, $this->sampleString, true), - array(401, $this->errorString, false) - ); - } - - /** - * Tests the verifyCredentials method - * - * @param integer $code The return code. - * @param string $body The JSON string. - * @param boolean $expected Expected return value. - * - * @return void - * - * @dataProvider seedVerifyCredentials - * @since 13.1 - */ - public function testVerifyCredentials($code, $body, $expected) - { - - // Set request parameters. - $data['format'] = 'json'; - - $path = 'https://api.linkedin.com/v1/people::(~)'; - - $returnData = new stdClass; - $returnData->code = $code; - $returnData->body = $body; - - $path = $this->oauth->toUrl($path, $data); - - $this->client->expects($this->once()) - ->method('get') - ->with($path) - ->will($this->returnValue($returnData)); - - $this->assertThat( - $this->oauth->verifyCredentials(), - $this->equalTo($expected) - ); - } -} diff --git a/tests/unit/suites/libraries/joomla/linkedin/JLinkedinObjectTest.php b/tests/unit/suites/libraries/joomla/linkedin/JLinkedinObjectTest.php deleted file mode 100644 index a937fab28e..0000000000 --- a/tests/unit/suites/libraries/joomla/linkedin/JLinkedinObjectTest.php +++ /dev/null @@ -1,97 +0,0 @@ -options = new JRegistry; - $this->client = $this->getMock('JHttp', array('get', 'post', 'delete', 'put')); - - $this->object = new JLinkedinObjectMock($this->options, $this->client); - } - - /** - * Tears down the fixture, for example, closes a network connection. - * This method is called after a test is executed. - * - * @access protected - * - * @return void - */ - protected function tearDown() - { - } - - /** - * Tests the setOption method - * - * @return void - * - * @since 13.1 - */ - public function testSetOption() - { - $this->object->setOption('api.url', 'https://example.com/settest'); - - $this->assertThat( - $this->options->get('api.url'), - $this->equalTo('https://example.com/settest') - ); - } -} diff --git a/tests/unit/suites/libraries/joomla/linkedin/JLinkedinPeopleTest.php b/tests/unit/suites/libraries/joomla/linkedin/JLinkedinPeopleTest.php deleted file mode 100644 index 0466d0cc99..0000000000 --- a/tests/unit/suites/libraries/joomla/linkedin/JLinkedinPeopleTest.php +++ /dev/null @@ -1,538 +0,0 @@ -options = new JRegistry; - $this->input = new JInput; - $this->client = $this->getMock('JHttp', array('get', 'post', 'delete', 'put')); - $this->oauth = new JLinkedinOauth($this->options, $this->client, $this->input); - $this->oauth->setToken(array('key' => $key, 'secret' => $secret)); - - $this->object = new JLinkedinPeople($this->options, $this->client, $this->oauth); - - $this->options->set('consumer_key', $key); - $this->options->set('consumer_secret', $secret); - $this->options->set('callback', $my_url); - } - - /** - * Tears down the fixture, for example, closes a network connection. - * This method is called after a test is executed. - * - * @return void - */ - protected function tearDown() - { - } - - /** - * Provides test data for request format detection. - * - * @return array - * - * @since 13.1 - */ - public function seedIdUrl() - { - // Member ID or url - return array( - array('lcnIwDU0S6', null), - array(null, 'http://www.linkedin.com/in/dianaprajescu'), - array(null, null) - ); - } - - /** - * Tests the getProfile method - * - * @param string $id Member id of the profile you want. - * @param string $url The public profile URL. - * - * @return void - * - * @dataProvider seedIdUrl - * @since 13.1 - */ - public function testGetProfile($id, $url) - { - $fields = '(id,first-name,last-name)'; - $language = 'en-US'; - - // Set request parameters. - $data['format'] = 'json'; - - $path = '/v1/people/'; - - if ($url) - { - $path .= 'url=' . $this->oauth->safeEncode($url) . ':public'; - $type = 'public'; - } - else - { - $type = 'standard'; - } - - if ($id) - { - $path .= 'id=' . $id; - } - elseif (!$url) - { - $path .= '~'; - } - - $path .= ':' . $fields; - $header = array('Accept-Language' => $language); - - $returnData = new stdClass; - $returnData->code = 200; - $returnData->body = $this->sampleString; - - $path = $this->oauth->toUrl($path, $data); - - $this->client->expects($this->once()) - ->method('get', $header) - ->with($path) - ->will($this->returnValue($returnData)); - - $this->assertThat( - $this->object->getProfile($id, $url, $fields, $type, $language), - $this->equalTo(json_decode($this->sampleString)) - ); - } - - /** - * Tests the getProfile method - failure - * - * @param string $id Member id of the profile you want. - * @param string $url The public profile URL. - * - * @return void - * - * @dataProvider seedIdUrl - * @since 13.1 - * @expectedException DomainException - */ - public function testGetProfileFailure($id, $url) - { - $fields = '(id,first-name,last-name)'; - $language = 'en-US'; - - // Set request parameters. - $data['format'] = 'json'; - - $path = '/v1/people/'; - - if ($url) - { - $path .= 'url=' . $this->oauth->safeEncode($url) . ':public'; - $type = 'public'; - } - else - { - $type = 'standard'; - } - - if ($id) - { - $path .= 'id=' . $id; - } - elseif (!$url) - { - $path .= '~'; - } - - $path .= ':' . $fields; - $header = array('Accept-Language' => $language); - - $returnData = new stdClass; - $returnData->code = 401; - $returnData->body = $this->errorString; - - $path = $this->oauth->toUrl($path, $data); - - $this->client->expects($this->once()) - ->method('get', $header) - ->with($path) - ->will($this->returnValue($returnData)); - - $this->object->getProfile($id, $url, $fields, $type, $language); - } - - /** - * Tests the getConnections method - * - * @return void - * - * @since 13.1 - */ - public function testGetConnections() - { - $fields = '(id,first-name,last-name)'; - $start = 1; - $count = 50; - $modified = 'new'; - $modified_since = '1267401600000'; - - // Set request parameters. - $data['format'] = 'json'; - $data['start'] = $start; - $data['count'] = $count; - $data['modified'] = $modified; - $data['modified-since'] = $modified_since; - - $path = '/v1/people/~/connections'; - - $path .= ':' . $fields; - - $returnData = new stdClass; - $returnData->code = 200; - $returnData->body = $this->sampleString; - - $path = $this->oauth->toUrl($path, $data); - - $this->client->expects($this->once()) - ->method('get') - ->with($path) - ->will($this->returnValue($returnData)); - - $this->assertThat( - $this->object->getConnections($fields, $start, $count, $modified, $modified_since), - $this->equalTo(json_decode($this->sampleString)) - ); - } - - /** - * Tests the getConnections method - failure - * - * @return void - * - * @since 13.1 - * @expectedException DomainException - */ - public function testGetConnectionsFailure() - { - $fields = '(id,first-name,last-name)'; - $start = 1; - $count = 50; - $modified = 'new'; - $modified_since = '1267401600000'; - - // Set request parameters. - $data['format'] = 'json'; - $data['start'] = $start; - $data['count'] = $count; - $data['modified'] = $modified; - $data['modified-since'] = $modified_since; - - $path = '/v1/people/~/connections'; - - $path .= ':' . $fields; - - $returnData = new stdClass; - $returnData->code = 401; - $returnData->body = $this->errorString; - - $path = $this->oauth->toUrl($path, $data); - - $this->client->expects($this->once()) - ->method('get') - ->with($path) - ->will($this->returnValue($returnData)); - - $this->object->getConnections($fields, $start, $count, $modified, $modified_since); - } - - /** - * Provides test data for request format detection. - * - * @return array - * - * @since 13.1 - */ - public function seedFields() - { - // Fields - return array( - array('(people:(id,first-name,last-name,api-standard-profile-request))'), - array('(people:(id,first-name,last-name))') - ); - } - - /** - * Tests the search method - * - * @param string $fields Request fields beyond the default ones. provide 'api-standard-profile-request' field for out of network profiles. - * - * @return void - * - * @dataProvider seedFields - * @since 13.1 - */ - public function testSearch($fields) - { - $keywords = 'Princess'; - $first_name = 'Clair'; - $last_name = 'Standish'; - $company_name = 'Smth'; - $current_company = true; - $title = 'developer'; - $current_title = true; - $school_name = 'Shermer High School'; - $current_school = true; - $country_code = 'us'; - $postal_code = 12345; - $distance = 500; - $facets = 'location,industry,network,language,current-company,past-company,school'; - $facet = array('us-84', 47, 'F', 'en', 1006, 1028, 2345); - $start = 1; - $count = 50; - $sort = 'distance'; - - // Set request parameters. - $data['format'] = 'json'; - $data['keywords'] = $keywords; - $data['first-name'] = $first_name; - $data['last-name'] = $last_name; - $data['company-name'] = $company_name; - $data['current-company'] = $current_company; - $data['title'] = $title; - $data['current-title'] = $current_title; - $data['school-name'] = $school_name; - $data['current-school'] = $current_school; - $data['country-code'] = $country_code; - $data['postal-code'] = $postal_code; - $data['distance'] = $distance; - $data['facets'] = $facets; - $data['facet'] = array(); - $data['facet'][] = 'location,' . $facet[0]; - $data['facet'][] = 'industry,' . $facet[1]; - $data['facet'][] = 'network,' . $facet[2]; - $data['facet'][] = 'language,' . $facet[3]; - $data['facet'][] = 'current-company,' . $facet[4]; - $data['facet'][] = 'past-company,' . $facet[5]; - $data['facet'][] = 'school,' . $facet[6]; - - $data['start'] = $start; - $data['count'] = $count; - $data['sort'] = $sort; - - $path = '/v1/people-search'; - - $path .= ':' . $fields; - - $returnData = new stdClass; - $returnData->code = 200; - $returnData->body = $this->sampleString; - - $path = $this->oauth->toUrl($path, $data); - - if (strpos($fields, 'api-standard-profile-request') === false) - { - $this->client->expects($this->once()) - ->method('get') - ->with($path) - ->will($this->returnValue($returnData)); - } - else - { - $returnData = new stdClass; - $returnData->code = 200; - $returnData->body = $this->outString; - - $this->client->expects($this->at(0)) - ->method('get') - ->with($path) - ->will($this->returnValue($returnData)); - - $returnData = new stdClass; - $returnData->code = 200; - $returnData->body = $this->sampleString; - - $path = '/v1/people/oAFz-3CZyv'; - $path = $this->oauth->toUrl($path, $data); - - $name = 'x-li-auth-token'; - $value = 'NAME_SEARCH:-Ogn'; - $header[$name] = $value; - - $this->client->expects($this->at(1)) - ->method('get', $header) - ->with($path) - ->will($this->returnValue($returnData)); - } - - $this->assertThat( - $this->object->search( - $fields, $keywords, $first_name, $last_name, $company_name, - $current_company, $title, $current_title, $school_name, $current_school, $country_code, - $postal_code, $distance, $facets, $facet, $start, $count, $sort - ), - $this->equalTo(json_decode($this->sampleString)) - ); - } - - /** - * Tests the search method - failure - * - * @return void - * - * @since 13.1 - * @expectedException DomainException - */ - public function testSearchFailure() - { - $fields = '(id,first-name,last-name)'; - $keywords = 'Princess'; - $first_name = 'Clair'; - $last_name = 'Standish'; - $company_name = 'Smth'; - $current_company = true; - $title = 'developer'; - $current_title = true; - $school_name = 'Shermer High School'; - $current_school = true; - $country_code = 'us'; - $postal_code = 12345; - $distance = 500; - $facets = 'location,industry,network,language,current-company,past-company,school'; - $facet = array('us-84', 47, 'F', 'en', 1006, 1028, 2345); - $start = 1; - $count = 50; - $sort = 'distance'; - - // Set request parameters. - $data['format'] = 'json'; - $data['keywords'] = $keywords; - $data['first-name'] = $first_name; - $data['last-name'] = $last_name; - $data['company-name'] = $company_name; - $data['current-company'] = $current_company; - $data['title'] = $title; - $data['current-title'] = $current_title; - $data['school-name'] = $school_name; - $data['current-school'] = $current_school; - $data['country-code'] = $country_code; - $data['postal-code'] = $postal_code; - $data['distance'] = $distance; - $data['facets'] = $facets; - $data['facet'] = array(); - $data['facet'][] = 'location,' . $facet[0]; - $data['facet'][] = 'industry,' . $facet[1]; - $data['facet'][] = 'network,' . $facet[2]; - $data['facet'][] = 'language,' . $facet[3]; - $data['facet'][] = 'current-company,' . $facet[4]; - $data['facet'][] = 'past-company,' . $facet[5]; - $data['facet'][] = 'school,' . $facet[6]; - - $data['start'] = $start; - $data['count'] = $count; - $data['sort'] = $sort; - - $path = '/v1/people-search'; - - $path .= ':' . $fields; - - $returnData = new stdClass; - $returnData->code = 401; - $returnData->body = $this->errorString; - - $path = $this->oauth->toUrl($path, $data); - - $this->client->expects($this->once()) - ->method('get') - ->with($path) - ->will($this->returnValue($returnData)); - - $this->object->search( - $fields, $keywords, $first_name, $last_name, $company_name, - $current_company, $title, $current_title, $school_name, $current_school, $country_code, - $postal_code, $distance, $facets, $facet, $start, $count, $sort - ); - } -} diff --git a/tests/unit/suites/libraries/joomla/linkedin/JLinkedinStreamTest.php b/tests/unit/suites/libraries/joomla/linkedin/JLinkedinStreamTest.php deleted file mode 100644 index 5229585d08..0000000000 --- a/tests/unit/suites/libraries/joomla/linkedin/JLinkedinStreamTest.php +++ /dev/null @@ -1,1067 +0,0 @@ -options = new JRegistry; - $this->input = new JInput; - $this->client = $this->getMock('JHttp', array('get', 'post', 'delete', 'put')); - $this->oauth = new JLinkedinOauth($this->options, $this->client, $this->input); - $this->oauth->setToken(array('key' => $key, 'secret' => $secret)); - - $this->object = new JLinkedinStream($this->options, $this->client, $this->oauth); - - $this->options->set('consumer_key', $key); - $this->options->set('consumer_secret', $secret); - $this->options->set('callback', $my_url); - } - - /** - * Tears down the fixture, for example, closes a network connection. - * This method is called after a test is executed. - * - * @return void - */ - protected function tearDown() - { - } - - /** - * Provides test data for request format detection. - * - * @return array - * - * @since 13.1 - */ - public function seedShare() - { - // Company comment, title, url, image, description - return array( - array('some comment', 'title example', 'www.example.com', 'www.image-example.com', 'description text'), - array(null, 'title example', null, 'www.image-example.com', 'description text') - ); - } - - /** - * Tests the share method - * - * @param string $comment Text of member's comment. - * @param string $title Title of shared document. - * @param string $url URL for shared content. - * @param string $image URL for image of shared content. - * @param string $description Description of shared content. - * - * @return void - * - * @dataProvider seedShare - * @since 13.1 - */ - public function testShare($comment, $title, $url, $image, $description) - { - $visibility = 'anyone'; - $twitter = true; - - $path = '/v1/people/~/shares?twitter-post=true'; - - // Build xml. - $xml = ' - - ' . $visibility . ' - '; - - // Check if comment specified. - if ($comment) - { - $xml .= '' . $comment . ''; - } - - // Check if title and url are specified. - if ($title && $url) - { - $xml .= ' - ' . $title . ' - ' . $url . ' - ' . $image . ' - ' . $description . ' - '; - } - elseif (!$comment) - { - $this->setExpectedException('RuntimeException'); - $this->object->share($visibility, $comment, $title, $url, $image, $description, $twitter); - } - - $xml .= ''; - - $header['Content-Type'] = 'text/xml'; - - $returnData = new stdClass; - $returnData->code = 201; - $returnData->body = $this->sampleString; - - $this->client->expects($this->once()) - ->method('post', $xml, $header) - ->with($path) - ->will($this->returnValue($returnData)); - - $this->assertThat( - $this->object->share($visibility, $comment, $title, $url, $image, $description, $twitter), - $this->equalTo($returnData) - ); - } - - /** - * Tests the share method - failure - * - * @return void - * - * @expectedException DomainException - * @since 13.1 - */ - public function testShareFailure() - { - $comment = 'some comment'; - $visibility = 'anyone'; - - $path = '/v1/people/~/shares'; - - // Build xml. - $xml = ' - - ' . $visibility . ' - - ' . $comment . ' - '; - - $header['Content-Type'] = 'text/xml'; - - $returnData = new stdClass; - $returnData->code = 401; - $returnData->body = $this->errorString; - - $this->client->expects($this->once()) - ->method('post', $xml, $header) - ->with($path) - ->will($this->returnValue($returnData)); - - $this->object->share($visibility, $comment); - } - - /** - * Tests the reshare method - * - * @return void - * - * @since 13.1 - */ - public function testReshare() - { - $id = 's123435'; - $visibility = 'anyone'; - $comment = 'some comment'; - $twitter = true; - - $path = '/v1/people/~/shares?twitter-post=true'; - - // Build xml. - $xml = ' - - ' . $visibility . ' - '; - - // Check if comment specified. - if ($comment) - { - $xml .= '' . $comment . ''; - } - - $xml .= ' - - ' . $id . ' - - - '; - - $header['Content-Type'] = 'text/xml'; - - $returnData = new stdClass; - $returnData->code = 201; - $returnData->body = $this->sampleString; - - $this->client->expects($this->once()) - ->method('post', $xml, $header) - ->with($path) - ->will($this->returnValue($returnData)); - - $this->assertThat( - $this->object->reshare($visibility, $id, $comment, $twitter), - $this->equalTo($returnData) - ); - } - - /** - * Tests the reshare method - failure - * - * @return void - * - * @expectedException DomainException - * @since 13.1 - */ - public function testReshareFailure() - { - $id = 's123435'; - $visibility = 'anyone'; - $comment = 'some comment'; - $twitter = true; - - $path = '/v1/people/~/shares?twitter-post=true'; - - // Build xml. - $xml = ' - - ' . $visibility . ' - '; - - // Check if comment specified. - if ($comment) - { - $xml .= '' . $comment . ''; - } - - $xml .= ' - - ' . $id . ' - - - '; - - $header['Content-Type'] = 'text/xml'; - - $returnData = new stdClass; - $returnData->code = 401; - $returnData->body = $this->errorString; - - $this->client->expects($this->once()) - ->method('post', $xml, $header) - ->with($path) - ->will($this->returnValue($returnData)); - - $this->object->reshare($visibility, $id, $comment, $twitter); - } - - /** - * Provides test data for request format detection. - * - * @return array - * - * @since 13.1 - */ - public function seedIdUrl() - { - // Member ID or url - return array( - array('lcnIwDU0S6', null), - array(null, 'http://www.linkedin.com/in/dianaprajescu'), - array(null, null) - ); - } - - /** - * Tests the getCurrentShare method - * - * @param string $id Member id of the profile you want. - * @param string $url The public profile URL. - * - * @return void - * - * @dataProvider seedIdUrl - * @since 13.1 - */ - public function testGetCurrentShare($id, $url) - { - // Set request parameters. - $data['format'] = 'json'; - - $path = '/v1/people/'; - - if ($url) - { - $path .= 'url=' . $this->oauth->safeEncode($url); - } - - if ($id) - { - $path .= 'id=' . $id; - } - elseif (!$url) - { - $path .= '~'; - } - - $path .= ':(current-share)'; - - $returnData = new stdClass; - $returnData->code = 200; - $returnData->body = $this->sampleString; - - $path = $this->oauth->toUrl($path, $data); - - $this->client->expects($this->once()) - ->method('get') - ->with($path) - ->will($this->returnValue($returnData)); - - $this->assertThat( - $this->object->getCurrentShare($id, $url), - $this->equalTo(json_decode($this->sampleString)) - ); - } - - /** - * Tests the getCurrentShare method - failure - * - * @return void - * - * @expectedException DomainException - * @since 13.1 - */ - public function testGetCurrentShareFailure() - { - // Set request parameters. - $data['format'] = 'json'; - - $path = '/v1/people/~:(current-share)'; - - $returnData = new stdClass; - $returnData->code = 401; - $returnData->body = $this->errorString; - - $path = $this->oauth->toUrl($path, $data); - - $this->client->expects($this->once()) - ->method('get') - ->with($path) - ->will($this->returnValue($returnData)); - - $this->object->getCurrentShare(); - } - - /** - * Tests the getShareStream method - * - * @param string $id Member id of the profile you want. - * @param string $url The public profile URL. - * - * @return void - * - * @dataProvider seedIdUrl - * @since 13.1 - */ - public function testGetShareStream($id, $url) - { - // Set request parameters. - $data['format'] = 'json'; - $data['type'] = 'SHAR'; - $data['scope'] = 'self'; - - $path = '/v1/people/'; - - if ($url) - { - $path .= 'url=' . $this->oauth->safeEncode($url); - } - - if ($id) - { - $path .= $id; - } - elseif (!$url) - { - $path .= '~'; - } - - $path .= '/network'; - - $returnData = new stdClass; - $returnData->code = 200; - $returnData->body = $this->sampleString; - - $path = $this->oauth->toUrl($path, $data); - - $this->client->expects($this->once()) - ->method('get') - ->with($path) - ->will($this->returnValue($returnData)); - - $this->assertThat( - $this->object->getShareStream($id, $url), - $this->equalTo(json_decode($this->sampleString)) - ); - } - - /** - * Tests the getShareStream method - failure - * - * @return void - * - * @expectedException DomainException - * @since 13.1 - */ - public function testGetShareStreamFailure() - { - // Set request parameters. - $data['format'] = 'json'; - $data['type'] = 'SHAR'; - $data['scope'] = 'self'; - - $path = '/v1/people/~/network'; - - $returnData = new stdClass; - $returnData->code = 401; - $returnData->body = $this->errorString; - - $path = $this->oauth->toUrl($path, $data); - - $this->client->expects($this->once()) - ->method('get') - ->with($path) - ->will($this->returnValue($returnData)); - - $this->object->getShareStream(); - } - - /** - * Provides test data for request format detection. - * - * @return array - * - * @since 13.1 - */ - public function seedId() - { - // Member ID or url - return array( - array('lcnIwDU0S6'), - array(null) - ); - } - - /** - * Tests the getNetworkUpdates method - * - * @param string $id Member id. - * - * @return void - * - * @dataProvider seedId - * @since 13.1 - */ - public function testGetNetworkUpdates($id) - { - $self = true; - $type = array('PICT', 'STAT'); - $count = 50; - $start = 1; - $after = '123346574'; - $before = '123534663'; - $hidden = true; - - // Set request parameters. - $data['format'] = 'json'; - $data['scope'] = 'self'; - $data['type'] = $type; - $data['count'] = $count; - $data['start'] = $start; - $data['after'] = $after; - $data['before'] = $before; - $data['hidden'] = true; - - $path = '/v1/people/'; - - if ($id) - { - $path .= $id; - } - else - { - $path .= '~'; - } - - $path .= '/network/updates'; - - $returnData = new stdClass; - $returnData->code = 200; - $returnData->body = $this->sampleString; - - $path = $this->oauth->toUrl($path, $data); - - $this->client->expects($this->once()) - ->method('get') - ->with($path) - ->will($this->returnValue($returnData)); - - $this->assertThat( - $this->object->getNetworkUpdates($id, $self, $type, $count, $start, $after, $before, $hidden), - $this->equalTo(json_decode($this->sampleString)) - ); - } - - /** - * Tests the getNetworkUpdates method - failure - * - * @return void - * - * @expectedException DomainException - * @since 13.1 - */ - public function testGetNetworkUpdatesFailure() - { - $self = true; - $type = array('PICT', 'STAT'); - $count = 50; - $start = 1; - $after = '123346574'; - $before = '123534663'; - $hidden = true; - - // Set request parameters. - $data['format'] = 'json'; - $data['scope'] = 'self'; - $data['type'] = $type; - $data['count'] = $count; - $data['start'] = $start; - $data['after'] = $after; - $data['before'] = $before; - $data['hidden'] = true; - - $path = '/v1/people/~/network/updates'; - - $returnData = new stdClass; - $returnData->code = 401; - $returnData->body = $this->errorString; - - $path = $this->oauth->toUrl($path, $data); - - $this->client->expects($this->once()) - ->method('get') - ->with($path) - ->will($this->returnValue($returnData)); - - $this->object->getNetworkUpdates(null, $self, $type, $count, $start, $after, $before, $hidden); - } - - /** - * Tests the getNetworkStats method - * - * @return void - * - * @since 13.1 - */ - public function testGetNetworkStats() - { - // Set request parameters. - $data['format'] = 'json'; - - $path = '/v1/people/~/network/network-stats'; - - $returnData = new stdClass; - $returnData->code = 200; - $returnData->body = $this->sampleString; - - $path = $this->oauth->toUrl($path, $data); - - $this->client->expects($this->once()) - ->method('get') - ->with($path) - ->will($this->returnValue($returnData)); - - $this->assertThat( - $this->object->getNetworkStats(), - $this->equalTo(json_decode($this->sampleString)) - ); - } - - /** - * Tests the getNetworkStats method - failure - * - * @return void - * - * @expectedException DomainException - * @since 13.1 - */ - public function testGetNetworkStatsFailure() - { - // Set request parameters. - $data['format'] = 'json'; - - $path = '/v1/people/~/network/network-stats'; - - $returnData = new stdClass; - $returnData->code = 401; - $returnData->body = $this->errorString; - - $path = $this->oauth->toUrl($path, $data); - - $this->client->expects($this->once()) - ->method('get') - ->with($path) - ->will($this->returnValue($returnData)); - - $this->object->getNetworkStats(); - } - - /** - * Tests the postNetworkUpdate method - * - * @return void - * - * @since 13.1 - */ - public function testPostNetworkUpdate() - { - $body = '&lt;a href=&quot;http://www.linkedin.com/profile?viewProfile=&amp;key=3639896&amp;authToken=JdAa&amp; - authType=name&amp;trk=api*a119686*s128146*&quot;&gt;Kirsten Jones&lt;/a&gt; is reading about &lt; - a href=&quot;http://www.tigers.com&quot;&gt;Tigers&lt;/a&gt;http://www.tigers.com&gt;Tigers&lt;/a&gt;..'; - - $path = '/v1/people/~/person-activities'; - - // Build the xml. - $xml = ' - linkedin-html - ' . $body . ' - '; - - $header['Content-Type'] = 'text/xml'; - - $returnData = new stdClass; - $returnData->code = 201; - $returnData->body = $this->sampleString; - - $this->client->expects($this->once()) - ->method('post', $xml, $header) - ->with($path) - ->will($this->returnValue($returnData)); - - $this->assertThat( - $this->object->postNetworkUpdate($body), - $this->equalTo($returnData) - ); - } - - /** - * Tests the postNetworkUpdate method - failure - * - * @return void - * - * @expectedException DomainException - * @since 13.1 - */ - public function testPostNetworkUpdateFailure() - { - $body = '&lt;a href=&quot;http://www.linkedin.com/profile?viewProfile=&amp;key=3639896&amp;authToken=JdAa&amp; - authType=name&amp;trk=api*a119686*s128146*&quot;&gt;Kirsten Jones&lt;/a&gt; is reading about &lt; - a href=&quot;http://www.tigers.com&quot;&gt;Tigers&lt;/a&gt;http://www.tigers.com&gt;Tigers&lt;/a&gt;..'; - - $path = '/v1/people/~/person-activities'; - - // Build the xml. - $xml = ' - linkedin-html - ' . $body . ' - '; - - $header['Content-Type'] = 'text/xml'; - - $returnData = new stdClass; - $returnData->code = 401; - $returnData->body = $this->errorString; - - $this->client->expects($this->once()) - ->method('post', $xml, $header) - ->with($path) - ->will($this->returnValue($returnData)); - - $this->object->postNetworkUpdate($body); - } - - /** - * Tests the getComments method - * - * @return void - * - * @since 13.1 - */ - public function testGetComments() - { - $key = 'APPM-187317358-5635333363205165056-196773'; - - // Set request parameters. - $data['format'] = 'json'; - - $path = '/v1/people/~/network/updates/key=' . $key . '/update-comments'; - - $returnData = new stdClass; - $returnData->code = 200; - $returnData->body = $this->sampleString; - - $path = $this->oauth->toUrl($path, $data); - - $this->client->expects($this->once()) - ->method('get') - ->with($path) - ->will($this->returnValue($returnData)); - - $this->assertThat( - $this->object->getComments($key), - $this->equalTo(json_decode($this->sampleString)) - ); - } - - /** - * Tests the getComments method - failure - * - * @return void - * - * @expectedException DomainException - * @since 13.1 - */ - public function testGetCommentsFailure() - { - $key = 'APPM-187317358-5635333363205165056-196773'; - - // Set request parameters. - $data['format'] = 'json'; - - $path = '/v1/people/~/network/updates/key=' . $key . '/update-comments'; - - $returnData = new stdClass; - $returnData->code = 401; - $returnData->body = $this->errorString; - - $path = $this->oauth->toUrl($path, $data); - - $this->client->expects($this->once()) - ->method('get') - ->with($path) - ->will($this->returnValue($returnData)); - - $this->object->getComments($key); - } - - /** - * Tests the postComment method - * - * @return void - * - * @since 13.1 - */ - public function testPostComment() - { - $key = 'APPM-187317358-5635333363205165056-196773'; - $comment = 'Comment text'; - - $path = '/v1/people/~/network/updates/key=' . $key . '/update-comments'; - - // Build the xml. - $xml = ' - ' . $comment . ' - '; - - $header['Content-Type'] = 'text/xml'; - - $returnData = new stdClass; - $returnData->code = 201; - $returnData->body = $this->sampleString; - - $this->client->expects($this->once()) - ->method('post', $xml, $header) - ->with($path) - ->will($this->returnValue($returnData)); - - $this->assertThat( - $this->object->postComment($key, $comment), - $this->equalTo($returnData) - ); - } - - /** - * Tests the postComment method - failure - * - * @return void - * - * @expectedException DomainException - * @since 13.1 - */ - public function testPostCommentFailure() - { - $key = 'APPM-187317358-5635333363205165056-196773'; - $comment = 'Comment text'; - - $path = '/v1/people/~/network/updates/key=' . $key . '/update-comments'; - - // Build the xml. - $xml = ' - ' . $comment . ' - '; - - $header['Content-Type'] = 'text/xml'; - - $returnData = new stdClass; - $returnData->code = 401; - $returnData->body = $this->errorString; - - $this->client->expects($this->once()) - ->method('post', $xml, $header) - ->with($path) - ->will($this->returnValue($returnData)); - - $this->object->postComment($key, $comment); - } - - /** - * Tests the geLikes method - * - * @return void - * - * @since 13.1 - */ - public function testGetLikes() - { - $key = 'APPM-187317358-5635333363205165056-196773'; - - // Set request parameters. - $data['format'] = 'json'; - - $path = '/v1/people/~/network/updates/key=' . $key . '/likes'; - - $returnData = new stdClass; - $returnData->code = 200; - $returnData->body = $this->sampleString; - - $path = $this->oauth->toUrl($path, $data); - - $this->client->expects($this->once()) - ->method('get') - ->with($path) - ->will($this->returnValue($returnData)); - - $this->assertThat( - $this->object->getLikes($key), - $this->equalTo(json_decode($this->sampleString)) - ); - } - - /** - * Tests the geLikes method - failure - * - * @return void - * - * @expectedException DomainException - * @since 13.1 - */ - public function testGetLikesFailure() - { - $key = 'APPM-187317358-5635333363205165056-196773'; - - // Set request parameters. - $data['format'] = 'json'; - - $path = '/v1/people/~/network/updates/key=' . $key . '/likes'; - - $returnData = new stdClass; - $returnData->code = 401; - $returnData->body = $this->errorString; - - $path = $this->oauth->toUrl($path, $data); - - $this->client->expects($this->once()) - ->method('get') - ->with($path) - ->will($this->returnValue($returnData)); - - $this->object->getLikes($key); - } - - /** - * Tests the _likeUnlike method - * - * @return void - * - * @since 13.1 - */ - public function test_likeUnlike() - { - // Method tested via requesting classes - $this->markTestSkipped('This method is tested via requesting classes.'); - } - - /** - * Tests the like method - * - * @return void - * - * @since 13.1 - */ - public function testLike() - { - $key = 'APPM-187317358-5635333363205165056-196773'; - - $path = '/v1/people/~/network/updates/key=' . $key . '/is-liked'; - - $xml = 'true'; - - $header['Content-Type'] = 'text/xml'; - - $returnData = new stdClass; - $returnData->code = 204; - $returnData->body = $this->sampleString; - - $this->client->expects($this->once()) - ->method('put', $xml, $header) - ->with($path) - ->will($this->returnValue($returnData)); - - $this->assertThat( - $this->object->like($key), - $this->equalTo($returnData) - ); - } - - /** - * Tests the like method - failure - * - * @return void - * - * @expectedException DomainException - * @since 13.1 - */ - public function testLikeFailure() - { - $key = 'APPM-187317358-5635333363205165056-196773'; - - $path = '/v1/people/~/network/updates/key=' . $key . '/is-liked'; - - $xml = 'true'; - - $header['Content-Type'] = 'text/xml'; - - $returnData = new stdClass; - $returnData->code = 401; - $returnData->body = $this->errorString; - - $this->client->expects($this->once()) - ->method('put', $xml, $header) - ->with($path) - ->will($this->returnValue($returnData)); - - $this->object->like($key); - } - - /** - * Tests the unlike method - * - * @return void - * - * @since 13.1 - */ - public function testUnlike() - { - $key = 'APPM-187317358-5635333363205165056-196773'; - - $path = '/v1/people/~/network/updates/key=' . $key . '/is-liked'; - - $xml = 'false'; - - $header['Content-Type'] = 'text/xml'; - - $returnData = new stdClass; - $returnData->code = 204; - $returnData->body = $this->sampleString; - - $this->client->expects($this->once()) - ->method('put', $xml, $header) - ->with($path) - ->will($this->returnValue($returnData)); - - $this->assertThat( - $this->object->unlike($key), - $this->equalTo($returnData) - ); - } -} diff --git a/tests/unit/suites/libraries/joomla/linkedin/JLinkedinTest.php b/tests/unit/suites/libraries/joomla/linkedin/JLinkedinTest.php deleted file mode 100644 index e2242bef27..0000000000 --- a/tests/unit/suites/libraries/joomla/linkedin/JLinkedinTest.php +++ /dev/null @@ -1,210 +0,0 @@ -options = new JRegistry; - $this->client = $this->getMock('JHttp', array('get', 'post', 'delete', 'put')); - - $this->object = new JLinkedin($this->oauth, $this->options, $this->client); - } - - /** - * Tears down the fixture, for example, closes a network connection. - * This method is called after a test is executed. - * - * @return void - */ - protected function tearDown() - { - } - - /** - * Tests the magic __get method - people - * - * @return void - * - * @since 13.1 - */ - public function test__GetPeople() - { - $this->assertThat( - $this->object->people, - $this->isInstanceOf('JLinkedinPeople') - ); - } - - /** - * Tests the magic __get method - groups - * - * @return void - * - * @since 13.1 - */ - public function test__GetGroups() - { - $this->assertThat( - $this->object->groups, - $this->isInstanceOf('JLinkedinGroups') - ); - } - - /** - * Tests the magic __get method - companies - * - * @return void - * - * @since 13.1 - */ - public function test__GetCompanies() - { - $this->assertThat( - $this->object->companies, - $this->isInstanceOf('JLinkedinCompanies') - ); - } - - /** - * Tests the magic __get method - jobs - * - * @return void - * - * @since 13.1 - */ - public function test__GetJobs() - { - $this->assertThat( - $this->object->jobs, - $this->isInstanceOf('JLinkedinJobs') - ); - } - - /** - * Tests the magic __get method - stream - * - * @return void - * - * @since 13.1 - */ - public function test__GetStream() - { - $this->assertThat( - $this->object->stream, - $this->isInstanceOf('JLinkedinStream') - ); - } - - /** - * Tests the magic __get method - communications - * - * @return void - * - * @since 13.1 - */ - public function test__GetCommunications() - { - $this->assertThat( - $this->object->communications, - $this->isInstanceOf('JLinkedinCommunications') - ); - } - - /** - * Tests the magic __get method - other (non existant) - * - * @return void - * - * @since 13.1 - * @expectedException InvalidArgumentException - */ - public function test__GetOther() - { - $this->object->other; - } - - /** - * Tests the setOption method - * - * @return void - * - * @since 13.1 - */ - public function testSetOption() - { - $this->object->setOption('api.url', 'https://example.com/settest'); - - $this->assertThat( - $this->options->get('api.url'), - $this->equalTo('https://example.com/settest') - ); - } - - /** - * Tests the getOption method - * - * @return void - * - * @since 13.1 - */ - public function testGetOption() - { - $this->options->set('api.url', 'https://example.com/gettest'); - - $this->assertThat( - $this->object->getOption('api.url', 'https://example.com/gettest'), - $this->equalTo('https://example.com/gettest') - ); - } -} diff --git a/tests/unit/suites/libraries/joomla/linkedin/stubs/JLinkedinObjectMock.php b/tests/unit/suites/libraries/joomla/linkedin/stubs/JLinkedinObjectMock.php deleted file mode 100644 index d1d6efc0f1..0000000000 --- a/tests/unit/suites/libraries/joomla/linkedin/stubs/JLinkedinObjectMock.php +++ /dev/null @@ -1,17 +0,0 @@ -