These results are based on our legacy PHP analysis, consider migrating to our new PHP analysis engine instead. Learn more
1 | <?php |
||
2 | |||
3 | namespace AdvancedLearning\Oauth2Server\Tests; |
||
4 | |||
5 | use AdvancedLearning\Oauth2Server\Extensions\GroupExtension; |
||
6 | use AdvancedLearning\Oauth2Server\Services\ScopeService; |
||
7 | use SilverStripe\Core\Config\Config; |
||
8 | use SilverStripe\Dev\SapphireTest; |
||
9 | use SilverStripe\Security\Group; |
||
10 | use SilverStripe\Security\Member; |
||
11 | |||
12 | class ScopeTest extends SapphireTest |
||
13 | { |
||
14 | protected static $fixture_file = 'tests/OauthFixture.yml'; |
||
15 | |||
16 | /** |
||
17 | * Setup test environment. |
||
18 | */ |
||
19 | public function setUp() |
||
20 | { |
||
21 | // add GroupExtension for scopes |
||
22 | Config::forClass(Group::class)->merge('extensions', [GroupExtension::class]); |
||
23 | |||
24 | parent::setUp(); |
||
25 | } |
||
26 | |||
27 | View Code Duplication | public function testHasScope() |
|
0 ignored issues
–
show
|
|||
28 | { |
||
29 | $service = new ScopeService(); |
||
30 | $member = $this->objFromFixture(Member::class, 'member1'); |
||
31 | |||
32 | $this->assertTrue($service->hasScope('scope1', $member, 'Member should have scope1')); |
||
33 | $this->assertFalse($service->hasScope('scope2', $member, 'Member should have scope2')); |
||
34 | } |
||
35 | } |
Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.
You can also find more detailed suggestions in the “Code” section of your repository.