xref: /plugin/oauth/_test/MergeGroupsTest.php (revision f81e58d4c2bb1fa34f924f1062c39c9f06439e52)
1*f81e58d4SAndreas Gohr<?php
2*f81e58d4SAndreas Gohr
3*f81e58d4SAndreas Gohrnamespace dokuwiki\plugin\oauth\test;
4*f81e58d4SAndreas Gohr
5*f81e58d4SAndreas Gohruse dokuwiki\plugin\oauth\Exception;
6*f81e58d4SAndreas Gohruse dokuwiki\plugin\oauth\OAuthManager;
7*f81e58d4SAndreas Gohruse DokuWikiTest;
8*f81e58d4SAndreas Gohr
9*f81e58d4SAndreas Gohr/**
10*f81e58d4SAndreas Gohr * user data validation tests for the oauth plugin
11*f81e58d4SAndreas Gohr *
12*f81e58d4SAndreas Gohr * @group plugin_oauth
13*f81e58d4SAndreas Gohr * @group plugins
14*f81e58d4SAndreas Gohr */
15*f81e58d4SAndreas Gohrclass MergeGroupsTest extends DokuWikiTest
16*f81e58d4SAndreas Gohr{
17*f81e58d4SAndreas Gohr
18*f81e58d4SAndreas Gohr    protected $pluginsEnabled = ['oauth'];
19*f81e58d4SAndreas Gohr
20*f81e58d4SAndreas Gohr    /**
21*f81e58d4SAndreas Gohr     * @see testMergeGroups
22*f81e58d4SAndreas Gohr     */
23*f81e58d4SAndreas Gohr    public function provideTestData()
24*f81e58d4SAndreas Gohr    {
25*f81e58d4SAndreas Gohr        return [
26*f81e58d4SAndreas Gohr            [
27*f81e58d4SAndreas Gohr                ['hello', 'provider1', 'service', 'user'],
28*f81e58d4SAndreas Gohr                ['provider1', 'provider2'],
29*f81e58d4SAndreas Gohr                ['service', 'service2'],
30*f81e58d4SAndreas Gohr                false,
31*f81e58d4SAndreas Gohr                ['hello', 'provider1', 'provider2', 'service', 'user']
32*f81e58d4SAndreas Gohr            ],
33*f81e58d4SAndreas Gohr            [
34*f81e58d4SAndreas Gohr                ['hello', 'provider1', 'service', 'user'],
35*f81e58d4SAndreas Gohr                ['provider1', 'provider2'],
36*f81e58d4SAndreas Gohr                ['service', 'service2'],
37*f81e58d4SAndreas Gohr                true,
38*f81e58d4SAndreas Gohr                ['provider1', 'provider2', 'service', 'user']
39*f81e58d4SAndreas Gohr            ],
40*f81e58d4SAndreas Gohr            [
41*f81e58d4SAndreas Gohr                ['hello', 'provider1', 'service', 'user'],
42*f81e58d4SAndreas Gohr                [],
43*f81e58d4SAndreas Gohr                ['service', 'service2'],
44*f81e58d4SAndreas Gohr                false,
45*f81e58d4SAndreas Gohr                ['hello', 'provider1', 'service', 'user']
46*f81e58d4SAndreas Gohr            ],
47*f81e58d4SAndreas Gohr            [
48*f81e58d4SAndreas Gohr                ['hello', 'provider1', 'service', 'user'],
49*f81e58d4SAndreas Gohr                [],
50*f81e58d4SAndreas Gohr                ['service', 'service2'],
51*f81e58d4SAndreas Gohr                true,
52*f81e58d4SAndreas Gohr                ['service', 'user']
53*f81e58d4SAndreas Gohr            ]
54*f81e58d4SAndreas Gohr        ];
55*f81e58d4SAndreas Gohr    }
56*f81e58d4SAndreas Gohr
57*f81e58d4SAndreas Gohr    /**
58*f81e58d4SAndreas Gohr     * @dataProvider provideTestData
59*f81e58d4SAndreas Gohr     */
60*f81e58d4SAndreas Gohr    public function testMergeGroups($localGroups, $providerGroups, $services, $overwrite, $expect)
61*f81e58d4SAndreas Gohr    {
62*f81e58d4SAndreas Gohr        $oauthMgr = new OAuthManager();
63*f81e58d4SAndreas Gohr        $result = $this->callInaccessibleMethod(
64*f81e58d4SAndreas Gohr            $oauthMgr, 'mergeGroups',
65*f81e58d4SAndreas Gohr            [$localGroups, $providerGroups, $services, $overwrite]
66*f81e58d4SAndreas Gohr        );
67*f81e58d4SAndreas Gohr        sort($expect);
68*f81e58d4SAndreas Gohr        sort($result);
69*f81e58d4SAndreas Gohr
70*f81e58d4SAndreas Gohr        $this->assertEquals($expect, $result);
71*f81e58d4SAndreas Gohr    }
72*f81e58d4SAndreas Gohr
73*f81e58d4SAndreas Gohr}
74