-
Notifications
You must be signed in to change notification settings - Fork 4
/
test-mastodon-app.php
52 lines (47 loc) · 1.54 KB
/
test-mastodon-app.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
<?php
/**
* Class Test_Apps_Endpoint
*
* @package Enable_Mastodon_Apps
*/
namespace Enable_Mastodon_Apps;
/**
* A testcase for the apps endpoint.
*
* @package
*/
class MastodonApp_Test extends \WP_UnitTestCase {
public function test_create_app() {
$app = Mastodon_App::save( 'test', array( Mastodon_OAuth::OOB_REDIRECT_URI ), 'read', '' );
$this->assertInstanceOf( Mastodon_App::class, $app );
}
public function test_create_app_with_empty_scope() {
$this->expectException( \Exception::class );
$app = Mastodon_App::save( 'test', array( Mastodon_OAuth::OOB_REDIRECT_URI ), '', '' );
}
/**
* Scopes to test
*
* @param string $app_scopes The application scopes.
* @param string $scope_to_test The scope to test.
* @param bool $has_scope Indicates if the test should assume the scope to be existent.
* @dataProvider scopes
*/
public function test_scope_given( $app_scopes, $scope_to_test, $has_scope ) {
$app = Mastodon_App::save( 'test', array( Mastodon_OAuth::OOB_REDIRECT_URI ), $app_scopes, '' );
$this->assertEquals( $has_scope, $app->has_scope( $scope_to_test ) );
}
public function scopes() {
return array(
array( 'read', 'read', true ),
array( 'read', 'read:accounts', true ),
array( 'read:accounts', 'read:accounts', true ),
array( 'read:accounts', 'read', false ),
array( 'write', 'read', false ),
array( 'read', 'write', false ),
array( 'read write', 'write', true ),
array( 'read write push', 'write', true ),
array( 'read', 'write:accounts', false ),
);
}
}