Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
23 changes: 21 additions & 2 deletions Tests/Package/Issues/EventsTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@

use Joomla\Github\Package\Issues\Events;
use Joomla\Github\Tests\Stub\GitHubTestCase;
use PHPUnit\Framework\Attributes\IgnoreDeprecations;

/**
* Test class for the GitHub API package.
Expand Down Expand Up @@ -67,17 +68,35 @@ public function testGetListRepository()
{
$this->client->expects($this->once())
->method('get')
->with('/repos/joomla/joomla-platform/issues/1/comments', [], 0)
->with('/repos/joomla/joomla-platform/issues/events?page=2&per_page=50', [], 0)
->willReturn($this->response);

$response = json_decode((string) $this->response->getBody());

$this->assertEquals(
$response,
$this->object->getListRepository('joomla', 'joomla-platform', '1')
$this->object->getListRepository('joomla', 'joomla-platform', page: 2, limit: 50)
);
}

/**
* Tests that the ignored issue ID of the getListRepository method is deprecated
*
* @return void
*/
#[IgnoreDeprecations]
public function testGetListRepositoryWithIssueId()
{
$this->expectUserDeprecationMessageMatches('/The \$issueId parameter of .*getListRepository\(\) is ignored/');

$this->client->expects($this->once())
->method('get')
->with('/repos/joomla/joomla-platform/issues/events', [], 0)
->willReturn($this->response);

$this->object->getListRepository('joomla', 'joomla-platform', '1');
}

/**
* Tests the get method
*
Expand Down
3 changes: 2 additions & 1 deletion composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,8 @@
"php": "^8.3.0",
"joomla/http": "^4.0",
"joomla/registry": "^4.0",
"joomla/uri": "^4.0"
"joomla/uri": "^4.0",
"symfony/deprecation-contracts": "^2|^3"
},
"require-dev": {
"phpunit/phpunit": "^12.2.7",
Expand Down
10 changes: 10 additions & 0 deletions docs/overview.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,13 @@
# Github API package

TODO

## Issue events of a repository

`$github->issues->events->getListRepository($owner, $repo)` lists the issue events of a whole repository
(`/repos/{owner}/{repo}/issues/events`). It used to request the comments of one issue instead. The third parameter,
`$issueId`, is ignored and deprecated; pass `$page` and `$limit` as named arguments:

```php
$events = $github->issues->events->getListRepository('joomla', 'joomla-cms', page: 2, limit: 100);
```
23 changes: 16 additions & 7 deletions src/Package/Issues/Events.php
Original file line number Diff line number Diff line change
Expand Up @@ -49,18 +49,27 @@ public function getList($owner, $repo, $issueNumber, $page = 0, $limit = 0)
/**
* List events for a repository.
*
* @param string $owner The name of the owner of the GitHub repository.
* @param string $repo The name of the GitHub repository.
* @param integer $issueId The issue number.
* @param integer $page The page number from which to get items.
* @param integer $limit The number of items on a page.
* @param string $owner The name of the owner of the GitHub repository.
* @param string $repo The name of the GitHub repository.
* @param integer|null $issueId Ignored. Deprecated, will be removed in 5.0.
* @param integer $page The page number from which to get items.
* @param integer $limit The number of items on a page.
*
* @return object
*/
public function getListRepository($owner, $repo, $issueId, $page = 0, $limit = 0)
public function getListRepository($owner, $repo, $issueId = null, $page = 0, $limit = 0)
{
if ($issueId !== null) {
trigger_deprecation(
'joomla/github',
'__DEPLOY_VERSION__',
'The $issueId parameter of %s() is ignored and will be removed in 5.0.',
__METHOD__
);
}

// Build the request path.
$path = '/repos/' . $owner . '/' . $repo . '/issues/' . (int) $issueId . '/comments';
$path = '/repos/' . $owner . '/' . $repo . '/issues/events';

// Send the request.
return $this->processResponse(
Expand Down
Loading