summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
Diffstat (limited to 'OAuth/tests/phpunit/Entity/Mock_ClientEntity.php')
-rw-r--r--OAuth/tests/phpunit/Entity/Mock_ClientEntity.php40
1 files changed, 40 insertions, 0 deletions
diff --git a/OAuth/tests/phpunit/Entity/Mock_ClientEntity.php b/OAuth/tests/phpunit/Entity/Mock_ClientEntity.php
new file mode 100644
index 00000000..a99ffdb8
--- /dev/null
+++ b/OAuth/tests/phpunit/Entity/Mock_ClientEntity.php
@@ -0,0 +1,40 @@
+<?php
+
+namespace MediaWiki\Extensions\OAuth\Tests\Entity;
+
+use MediaWiki\Extensions\OAuth\Backend\Consumer;
+use MediaWiki\Extensions\OAuth\Entity\ClientEntity;
+use MWRestrictions;
+use User;
+
+class Mock_ClientEntity extends ClientEntity {
+ public static function newMock( User $user, $values = [] ) {
+ $now = wfTimestampNow();
+ return ClientEntity::newFromArray( array_merge( [
+ 'id' => null,
+ 'consumerKey' => '123456789',
+ 'userId' => $user->getId(),
+ 'name' => 'Test client',
+ 'description' => 'Test application',
+ 'wiki' => 'TestWiki',
+ 'version' => '1.0',
+ 'email' => $user->getEmail(),
+ 'emailAuthenticated' => $now,
+ 'callbackUrl' => 'https://example.com',
+ 'callbackIsPrefix' => true,
+ 'developerAgreement' => 1,
+ 'secretKey' => 'secretKey',
+ 'registration' => $now,
+ 'stage' => Consumer::STAGE_APPROVED,
+ 'stageTimestamp' => $now,
+ 'grants' => [ 'editpage', 'highvolume' ],
+ 'restrictions' => MWRestrictions::newDefault(),
+ 'deleted' => 0,
+ 'rsaKey' => '',
+ 'oauthVersion' => Consumer::OAUTH_VERSION_2,
+ 'ownerOnly' => false,
+ 'oauth2IsConfidential' => true,
+ 'oauth2GrantTypes' => [ 'authorization_code', 'refresh_token' ]
+ ], $values ) );
+ }
+}