Skip to content

Commit

Permalink
Merge pull request #195 from akirk/test-php-compatibility
Browse files Browse the repository at this point in the history
Update PHPCompatibility and restrict PHPUnit
  • Loading branch information
akirk authored Feb 8, 2025
2 parents 695e681 + eadb023 commit 2e70cf2
Show file tree
Hide file tree
Showing 9 changed files with 76 additions and 68 deletions.
99 changes: 49 additions & 50 deletions composer.json
Original file line number Diff line number Diff line change
@@ -1,52 +1,51 @@
{
"name": "akirk/enable-mastodon-apps",
"description": "A WordPress plugin that implements the Mastodon API to enable access through Mastodon apps",
"type": "wordpress-plugin",
"license": "GPL-2.0-or-later",
"require-dev": {
"dealerdirect/phpcodesniffer-composer-installer": "*",
"phpcompatibility/php-compatibility": "*",
"wp-coding-standards/wpcs": "*",
"yoast/phpunit-polyfills": "*",
"php-parallel-lint/php-parallel-lint": "^1.3",
"phpunit/phpunit": "*",
"akirk/extract-wp-hooks": "*"
},
"config": {
"allow-plugins": {
"dealerdirect/phpcodesniffer-composer-installer": true
}
},
"prefer-stable": true,
"scripts": {
"lint7": [
"@php ./vendor/php-parallel-lint/php-parallel-lint/parallel-lint . -e php --exclude vendor --exclude .git --exclude src/Exceptions/Error.php --exclude src/Exceptions/TypeError.php --exclude tests/Polyfills/Fixtures/ValueObjectUnion.php --exclude tests/Polyfills/Fixtures/ValueObjectUnionNoReturnType.php"
],
"lint-lt70": [
"@php ./vendor/php-parallel-lint/php-parallel-lint/parallel-lint . -e php --exclude vendor --exclude .git --exclude src/TestCases/TestCasePHPUnitGte8.php --exclude src/TestListeners/TestListenerDefaultImplementationPHPUnitGte7.php --exclude tests/Polyfills/Fixtures/ChildValueObject.php --exclude tests/Polyfills/Fixtures/ValueObject.php --exclude tests/Polyfills/Fixtures/ValueObjectUnion.php --exclude tests/Polyfills/Fixtures/ValueObjectUnionNoReturnType.php"
],
"lint-gte80": [
"@php ./vendor/php-parallel-lint/php-parallel-lint/parallel-lint . -e php --exclude vendor --exclude .git"
],
"check-cs": [
"@php ./vendor/bin/phpcs"
],
"fix-cs": [
"@php ./vendor/bin/phpcbf"
],
"test": [
"@php ./vendor/phpunit/phpunit/phpunit --testdox --no-coverage"
],
"docker-test": [
"composer install",
"bin/install-wp-tests.sh ema-test root ema-test test-db latest true",
"@php ./vendor/phpunit/phpunit/phpunit --no-coverage"
],
"update-wiki": [
"test -d ../enable-mastodon-apps.wiki && php ./vendor/akirk/extract-wp-hooks/extract-wp-hooks.php && cd ../enable-mastodon-apps.wiki/ && git add . && git commit -m 'Update hooks'; git push"
]
},
"require": {
"bshaffer/oauth2-server-php": "^1.10"
}
"name": "akirk/enable-mastodon-apps",
"description": "A WordPress plugin that implements the Mastodon API to enable access through Mastodon apps",
"license": "GPL-2.0-or-later",
"require-dev": {
"phpcompatibility/php-compatibility": "dev-develop as 9.99.99",
"phpcompatibility/phpcompatibility-wp": "*",
"wp-coding-standards/wpcs": "*",
"yoast/phpunit-polyfills": "*",
"php-parallel-lint/php-parallel-lint": "^1.3",
"phpunit/phpunit": "9.*",
"akirk/extract-wp-hooks": "*"
},
"config": {
"allow-plugins": {
"dealerdirect/phpcodesniffer-composer-installer": true
}
},
"prefer-stable": true,
"scripts": {
"lint7": [
"@php ./vendor/php-parallel-lint/php-parallel-lint/parallel-lint . -e php --exclude vendor --exclude .git --exclude src/Exceptions/Error.php --exclude src/Exceptions/TypeError.php --exclude tests/Polyfills/Fixtures/ValueObjectUnion.php --exclude tests/Polyfills/Fixtures/ValueObjectUnionNoReturnType.php"
],
"lint-lt70": [
"@php ./vendor/php-parallel-lint/php-parallel-lint/parallel-lint . -e php --exclude vendor --exclude .git --exclude src/TestCases/TestCasePHPUnitGte8.php --exclude src/TestListeners/TestListenerDefaultImplementationPHPUnitGte7.php --exclude tests/Polyfills/Fixtures/ChildValueObject.php --exclude tests/Polyfills/Fixtures/ValueObject.php --exclude tests/Polyfills/Fixtures/ValueObjectUnion.php --exclude tests/Polyfills/Fixtures/ValueObjectUnionNoReturnType.php"
],
"lint-gte80": [
"@php ./vendor/php-parallel-lint/php-parallel-lint/parallel-lint . -e php --exclude vendor --exclude .git"
],
"check-cs": [
"@php ./vendor/bin/phpcs"
],
"fix-cs": [
"@php ./vendor/bin/phpcbf"
],
"test": [
"@php ./vendor/phpunit/phpunit/phpunit --no-coverage"
],
"docker-test": [
"composer install",
"bin/install-wp-tests.sh ema-test root ema-test test-db latest true",
"@php ./vendor/phpunit/phpunit/phpunit --no-coverage"
],
"update-wiki": [
"test -d ../enable-mastodon-apps.wiki && php ./vendor/akirk/extract-wp-hooks/extract-wp-hooks.php && cd ../enable-mastodon-apps.wiki/ && git add . && git commit -m 'Update hooks'; git push"
]
},
"require": {
"bshaffer/oauth2-server-php": "^1.10"
}
}
15 changes: 12 additions & 3 deletions tests/test-activitypub.php
Original file line number Diff line number Diff line change
Expand Up @@ -158,9 +158,18 @@ public function test_activitypub_submit_status_reply() {
$this->assertTrue( \ActivityPub\should_comment_be_federated( $comment ) );

$type = 'Create';
$schedule = \wp_next_scheduled( 'activitypub_send_comment', array( $comment->comment_ID, $type ) );
$this->assertNotFalse( $schedule );
do_action( 'activitypub_send_comment', $comment->comment_ID, $type );
$outbox = \get_posts(
array(
'post_type' => \Activitypub\Collection\Outbox::POST_TYPE,
'posts_per_page' => 1,
'post_status' => 'pending',
'orderby' => 'date',
'order' => 'DESC',
)
);
$this->assertNotEmpty( $outbox );
$this->assertEquals( $outbox[0]->post_title, home_url( '?c=' . $comment->comment_ID ) );
do_action( 'activitypub_process_outbox' );

$this->assertEquals( 'federate', substr( get_comment_meta( $comment->comment_ID, 'activitypub_status', true ), 0, 8 ) );

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -112,7 +112,7 @@ public function getClientId()
*
* @ingroup oauth2_section_2
*/
public function getClientCredentials(RequestInterface $request, ResponseInterface $response = null)
public function getClientCredentials(RequestInterface $request, ?ResponseInterface $response = null)
{
if (!is_null($request->headers('PHP_AUTH_USER')) && !is_null($request->headers('PHP_AUTH_PW'))) {
return array('client_id' => $request->headers('PHP_AUTH_USER'), 'client_secret' => $request->headers('PHP_AUTH_PW'));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,7 @@ class AuthorizeController implements AuthorizeControllerInterface
* );
* @endcode
*/
public function __construct(ClientInterface $clientStorage, array $responseTypes = array(), array $config = array(), ScopeInterface $scopeUtil = null)
public function __construct(ClientInterface $clientStorage, array $responseTypes = array(), array $config = array(), ?ScopeInterface $scopeUtil = null)
{
$this->clientStorage = $clientStorage;
$this->responseTypes = $responseTypes;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ class ResourceController implements ResourceControllerInterface
* @param array $config
* @param ScopeInterface $scopeUtil
*/
public function __construct(TokenTypeInterface $tokenType, AccessTokenInterface $tokenStorage, $config = array(), ScopeInterface $scopeUtil = null)
public function __construct(TokenTypeInterface $tokenType, AccessTokenInterface $tokenStorage, $config = array(), ?ScopeInterface $scopeUtil = null)
{
$this->tokenType = $tokenType;
$this->tokenStorage = $tokenStorage;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ class TokenController implements TokenControllerInterface
* @param ScopeInterface $scopeUtil
* @throws InvalidArgumentException
*/
public function __construct(AccessTokenInterface $accessToken, ClientInterface $clientStorage, array $grantTypes = array(), ClientAssertionTypeInterface $clientAssertionType = null, ScopeInterface $scopeUtil = null)
public function __construct(AccessTokenInterface $accessToken, ClientInterface $clientStorage, array $grantTypes = array(), ?ClientAssertionTypeInterface $clientAssertionType = null, ?ScopeInterface $scopeUtil = null)
{
if (is_null($clientAssertionType)) {
foreach ($grantTypes as $grantType) {
Expand Down
4 changes: 2 additions & 2 deletions vendor/bshaffer/oauth2-server-php/src/OAuth2/Request.php
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ class Request implements RequestInterface
*
* @api
*/
public function __construct(array $query = array(), array $request = array(), array $attributes = array(), array $cookies = array(), array $files = array(), array $server = array(), $content = null, array $headers = null)
public function __construct(array $query = array(), array $request = array(), array $attributes = array(), array $cookies = array(), array $files = array(), array $server = array(), $content = null, ?array $headers = null)
{
$this->initialize($query, $request, $attributes, $cookies, $files, $server, $content, $headers);
}
Expand All @@ -55,7 +55,7 @@ public function __construct(array $query = array(), array $request = array(), ar
*
* @api
*/
public function initialize(array $query = array(), array $request = array(), array $attributes = array(), array $cookies = array(), array $files = array(), array $server = array(), $content = null, array $headers = null)
public function initialize(array $query = array(), array $request = array(), array $attributes = array(), array $cookies = array(), array $files = array(), array $server = array(), $content = null, ?array $headers = null)
{
$this->request = $request;
$this->query = $query;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ class AccessToken implements AccessTokenInterface
* );
* @endcode
*/
public function __construct(AccessTokenStorageInterface $tokenStorage, RefreshTokenInterface $refreshStorage = null, array $config = array())
public function __construct(AccessTokenStorageInterface $tokenStorage, ?RefreshTokenInterface $refreshStorage = null, ?array $config = array())
{
$this->tokenStorage = $tokenStorage;
$this->refreshStorage = $refreshStorage;
Expand Down
16 changes: 8 additions & 8 deletions vendor/bshaffer/oauth2-server-php/src/OAuth2/Server.php
Original file line number Diff line number Diff line change
Expand Up @@ -150,7 +150,7 @@ class Server implements ResourceControllerInterface,
*
* @ingroup oauth2_section_7
*/
public function __construct($storage = array(), array $config = array(), array $grantTypes = array(), array $responseTypes = array(), TokenTypeInterface $tokenType = null, ScopeInterface $scopeUtil = null, ClientAssertionTypeInterface $clientAssertionType = null)
public function __construct($storage = array(), array $config = array(), array $grantTypes = array(), array $responseTypes = array(), ?TokenTypeInterface $tokenType = null, ?ScopeInterface $scopeUtil = null, ?ClientAssertionTypeInterface $clientAssertionType = null)
{
$storage = is_array($storage) ? $storage : array($storage);
$this->storages = array();
Expand Down Expand Up @@ -289,7 +289,7 @@ public function setUserInfoController(UserInfoControllerInterface $userInfoContr
*
* @see http://openid.net/specs/openid-connect-core-1_0.html#UserInfo
*/
public function handleUserInfoRequest(RequestInterface $request, ResponseInterface $response = null)
public function handleUserInfoRequest(RequestInterface $request, ?ResponseInterface $response = null)
{
$this->response = is_null($response) ? new Response() : $response;
$this->getUserInfoController()->handleUserInfoRequest($request, $this->response);
Expand All @@ -315,7 +315,7 @@ public function handleUserInfoRequest(RequestInterface $request, ResponseInterfa
*
* @ingroup oauth2_section_4
*/
public function handleTokenRequest(RequestInterface $request, ResponseInterface $response = null)
public function handleTokenRequest(RequestInterface $request, ?ResponseInterface $response = null)
{
$this->response = is_null($response) ? new Response() : $response;
$this->getTokenController()->handleTokenRequest($request, $this->response);
Expand All @@ -328,7 +328,7 @@ public function handleTokenRequest(RequestInterface $request, ResponseInterface
* @param ResponseInterface $response - Response object
* @return mixed
*/
public function grantAccessToken(RequestInterface $request, ResponseInterface $response = null)
public function grantAccessToken(RequestInterface $request, ?ResponseInterface $response = null)
{
$this->response = is_null($response) ? new Response() : $response;
$value = $this->getTokenController()->grantAccessToken($request, $this->response);
Expand All @@ -346,7 +346,7 @@ public function grantAccessToken(RequestInterface $request, ResponseInterface $r
* @param ResponseInterface $response
* @return Response|ResponseInterface
*/
public function handleRevokeRequest(RequestInterface $request, ResponseInterface $response = null)
public function handleRevokeRequest(RequestInterface $request, ?ResponseInterface $response = null)
{
$this->response = is_null($response) ? new Response() : $response;
$this->getTokenController()->handleRevokeRequest($request, $this->response);
Expand Down Expand Up @@ -408,7 +408,7 @@ public function handleAuthorizeRequest(RequestInterface $request, ResponseInterf
*
* @ingroup oauth2_section_3
*/
public function validateAuthorizeRequest(RequestInterface $request, ResponseInterface $response = null)
public function validateAuthorizeRequest(RequestInterface $request, ?ResponseInterface $response = null)
{
$this->response = is_null($response) ? new Response() : $response;
$value = $this->getAuthorizeController()->validateAuthorizeRequest($request, $this->response);
Expand All @@ -422,7 +422,7 @@ public function validateAuthorizeRequest(RequestInterface $request, ResponseInte
* @param string $scope - Scope
* @return mixed
*/
public function verifyResourceRequest(RequestInterface $request, ResponseInterface $response = null, $scope = null)
public function verifyResourceRequest(RequestInterface $request, ?ResponseInterface $response = null, $scope = null)
{
$this->response = is_null($response) ? new Response() : $response;
$value = $this->getResourceController()->verifyResourceRequest($request, $this->response, $scope);
Expand All @@ -435,7 +435,7 @@ public function verifyResourceRequest(RequestInterface $request, ResponseInterfa
* @param ResponseInterface $response - Response object
* @return mixed
*/
public function getAccessTokenData(RequestInterface $request, ResponseInterface $response = null)
public function getAccessTokenData(RequestInterface $request, ?ResponseInterface $response = null)
{
$this->response = is_null($response) ? new Response() : $response;
$value = $this->getResourceController()->getAccessTokenData($request, $this->response);
Expand Down

0 comments on commit 2e70cf2

Please sign in to comment.