/**
  * Verify the default values for the log entry object.
  *
  * @return  void
  *
  * @since   1.0
  * @covers  Joomla\Log\LogEntry::__construct
  */
 public function testDefaultValues()
 {
     $tmp = new LogEntry('Lorem ipsum dolor sit amet');
     $date = new Date('now');
     // Message.
     $this->assertThat($tmp->message, $this->equalTo('Lorem ipsum dolor sit amet'), 'Line: ' . __LINE__ . '.');
     // Priority.
     $this->assertThat($tmp->priority, $this->equalTo(Log::INFO), 'Line: ' . __LINE__ . '.');
     // Category.
     $this->assertThat($tmp->category, $this->equalTo(''), 'Line: ' . __LINE__ . '.');
     // Date.
     $this->assertThat($tmp->date->toISO8601(), $this->equalTo($date->toISO8601()), 'Line: ' . __LINE__ . '.');
 }
Example #2
0
 /**
  * Method to get the list of comments in a repository.
  *
  * @param   string  $owner      The name of the owner of the GitHub repository.
  * @param   string  $repo       The name of the GitHub repository.
  * @param   string  $sort       The sort field - created or updated.
  * @param   string  $direction  The sort order- asc or desc. Ignored without sort parameter.
  * @param   Date    $since      A timestamp in ISO 8601 format.
  *
  * @throws \UnexpectedValueException
  * @throws \DomainException
  * @since  1.0
  *
  * @return  array
  */
 public function getRepositoryList($owner, $repo, $sort = 'created', $direction = 'asc', Date $since = null)
 {
     // Build the request path.
     $path = '/repos/' . $owner . '/' . $repo . '/issues/comments';
     if (false == in_array($sort, array('created', 'updated'))) {
         throw new \UnexpectedValueException(sprintf('%1$s - sort field must be "created" or "updated"', __METHOD__));
     }
     if (false == in_array($direction, array('asc', 'desc'))) {
         throw new \UnexpectedValueException(sprintf('%1$s - direction field must be "asc" or "desc"', __METHOD__));
     }
     $path .= '?sort=' . $sort;
     $path .= '&direction=' . $direction;
     if ($since) {
         $path .= '&since=' . $since->toISO8601();
     }
     // Send the request.
     return $this->processResponse($this->client->get($this->fetchUrl($path)));
 }
Example #3
0
 /**
  * Method to list commits for a repository.
  *
  * A special note on pagination: Due to the way Git works, commits are paginated based on SHA
  * instead of page number.
  * Please follow the link headers as outlined in the pagination overview instead of constructing
  * page links yourself.
  *
  * @param   string  $user    The name of the owner of the GitHub repository.
  * @param   string  $repo    The name of the GitHub repository.
  * @param   string  $sha     Sha or branch to start listing commits from.
  * @param   string  $path    Only commits containing this file path will be returned.
  * @param   string  $author  GitHub login, name, or email by which to filter by commit author.
  * @param   Date    $since   ISO 8601 Date - Only commits after this date will be returned.
  * @param   Date    $until   ISO 8601 Date - Only commits before this date will be returned.
  *
  * @throws \DomainException
  * @since    1.0
  *
  * @return  array
  */
 public function getList($user, $repo, $sha = '', $path = '', $author = '', Date $since = null, Date $until = null)
 {
     // Build the request path.
     $rPath = '/repos/' . $user . '/' . $repo . '/commits?';
     $rPath .= $sha ? '&sha=' . $sha : '';
     $rPath .= $path ? '&path=' . $path : '';
     $rPath .= $author ? '&author=' . $author : '';
     $rPath .= $since ? '&since=' . $since->toISO8601() : '';
     $rPath .= $until ? '&until=' . $until->toISO8601() : '';
     // Send the request.
     $response = $this->client->get($this->fetchUrl($rPath));
     // Validate the response code.
     if ($response->code != 200) {
         // Decode the error response and throw an exception.
         $error = json_decode($response->body);
         throw new \DomainException($error->message, $response->code);
     }
     return json_decode($response->body);
 }
Example #4
0
 /**
  * Method to list issues.
  *
  * @param   string   $user       The name of the owner of the GitHub repository.
  * @param   string   $repo       The name of the GitHub repository.
  * @param   string   $milestone  The milestone number, 'none', or *.
  * @param   string   $state      The optional state to filter requests by. [open, closed]
  * @param   string   $assignee   The assignee name, 'none', or *.
  * @param   string   $mentioned  The GitHub user name.
  * @param   string   $labels     The list of comma separated Label names. Example: bug,ui,@high.
  * @param   string   $sort       The sort order: created, updated, comments, default: created.
  * @param   string   $direction  The list direction: asc or desc, default: desc.
  * @param   Date     $since      The date/time since when issues should be returned.
  * @param   integer  $page       The page number from which to get items.
  * @param   integer  $limit      The number of items on a page.
  *
  * @return  object
  *
  * @since   1.0
  * @throws  \DomainException
  */
 public function getListByRepository($user, $repo, $milestone = null, $state = null, $assignee = null, $mentioned = null, $labels = null, $sort = null, $direction = null, Date $since = null, $page = 0, $limit = 0)
 {
     // Build the request path.
     $path = '/repos/' . $user . '/' . $repo . '/issues';
     $uri = new Uri($this->fetchUrl($path, $page, $limit));
     if ($milestone) {
         $uri->setVar('milestone', $milestone);
     }
     if ($state) {
         $uri->setVar('state', $state);
     }
     if ($assignee) {
         $uri->setVar('assignee', $assignee);
     }
     if ($mentioned) {
         $uri->setVar('mentioned', $mentioned);
     }
     if ($labels) {
         $uri->setVar('labels', $labels);
     }
     if ($sort) {
         $uri->setVar('sort', $sort);
     }
     if ($direction) {
         $uri->setVar('direction', $direction);
     }
     if ($since) {
         $uri->setVar('since', $since->toISO8601());
     }
     // Send the request.
     $response = $this->client->get((string) $uri);
     // Validate the response code.
     if ($response->code != 200) {
         // Decode the error response and throw an exception.
         $error = json_decode($response->body);
         throw new \DomainException($error->message, $response->code);
     }
     return json_decode($response->body);
 }
Example #5
0
 /**
  * Testing toISO8601
  *
  * @param   mixed    $tz        Which time zone? (can be string or numeric
  * @param   string   $setTime   What time should be set?
  * @param   boolean  $local     Local (true) or GMT?
  * @param   string   $expected  What should the resulting time string look like?
  *
  * @return  void
  *
  * @dataProvider seedTestToISO8601
  * @since   1.0
  * @covers  Joomla\Date\Date::toISO8601
  */
 public function testToISO8601($tz, $setTime, $local, $expected)
 {
     if (is_null($tz)) {
         $testDate = new Date($setTime);
     } else {
         $testDate = new Date($setTime, $tz);
     }
     $this->assertThat($testDate->toISO8601($local), $this->equalTo($expected));
 }
 /**
  * Mark notifications as read in a repository.
  *
  * Marking all notifications in a repository as “read” removes them from the default view on GitHub.com.
  *
  * @param   string   $owner         Repository owner.
  * @param   string   $repo          Repository name.
  * @param   boolean  $unread        Changes the unread status of the threads.
  * @param   boolean  $read          Inverse of “unread”.
  * @param   Date     $last_read_at  Describes the last point that notifications were checked.
  *                                  Anything updated since this time will not be updated. Default: Now. Expected in ISO 8601 format.
  *
  * @return  object
  *
  * @since   1.0
  */
 public function markReadRepository($owner, $repo, $unread, $read, Date $last_read_at = null)
 {
     // Build the request path.
     $path = '/repos/' . $owner . '/' . $repo . '/notifications';
     $data = array('unread' => $unread, 'read' => $read);
     if ($last_read_at) {
         $data['last_read_at'] = $last_read_at->toISO8601();
     }
     return $this->processResponse($this->client->put($this->fetchUrl($path), json_encode($data)), 205);
 }
Example #7
0
 /**
  * Method to list issues.
  *
  * @param   string   $user       The name of the owner of the GitHub repository.
  * @param   string   $repo       The name of the GitHub repository.
  * @param   string   $milestone  The milestone number, 'none', or *.
  * @param   string   $state      The optional state to filter requests by. [open, closed]
  * @param   string   $assignee   The assignee name, 'none', or *.
  * @param   string   $mentioned  The GitHub user name.
  * @param   string   $labels     The list of comma separated Label names. Example: bug,ui,@high.
  * @param   string   $sort       The sort order: created, updated, comments, default: created.
  * @param   string   $direction  The list direction: asc or desc, default: desc.
  * @param   Date     $since      The date/time since when issues should be returned.
  * @param   integer  $page       The page number from which to get items.
  * @param   integer  $limit      The number of items on a page.
  *
  * @return  object
  *
  * @since   1.0
  * @throws  \DomainException
  */
 public function getListByRepository($user, $repo, $milestone = null, $state = null, $assignee = null, $mentioned = null, $labels = null, $sort = null, $direction = null, Date $since = null, $page = 0, $limit = 0)
 {
     // Build the request path.
     $path = '/repos/' . $user . '/' . $repo . '/issues';
     $uri = new Uri($this->fetchUrl($path, $page, $limit));
     if ($milestone) {
         $uri->setVar('milestone', $milestone);
     }
     if ($state) {
         $uri->setVar('state', $state);
     }
     if ($assignee) {
         $uri->setVar('assignee', $assignee);
     }
     if ($mentioned) {
         $uri->setVar('mentioned', $mentioned);
     }
     if ($labels) {
         $uri->setVar('labels', $labels);
     }
     if ($sort) {
         $uri->setVar('sort', $sort);
     }
     if ($direction) {
         $uri->setVar('direction', $direction);
     }
     if ($since) {
         $uri->setVar('since', $since->toISO8601());
     }
     // Send the request.
     return $this->processResponse($this->client->get((string) $uri));
 }