LoginContext   A
last analyzed

Complexity

Total Complexity 3

Size/Duplication

Total Lines 25
Duplicated Lines 0 %

Importance

Changes 0
Metric Value
eloc 11
dl 0
loc 25
rs 10
c 0
b 0
f 0
wmc 3

1 Method

Rating   Name   Duplication   Size   Complexity  
A pagesShouldBeEditableBy() 0 14 3
1
<?php
2
3
namespace SilverStripe\CMS\Tests\Behaviour;
4
5
use Page;
0 ignored issues
show
Bug introduced by
The type Page was not found. Maybe you did not declare it correctly or list all dependencies?

The issue could also be caused by a filter entry in the build configuration. If the path has been excluded in your configuration, e.g. excluded_paths: ["lib/*"], you can move it to the dependency path list as follows:

filter:
    dependency_paths: ["lib/*"]

For further information see https://scrutinizer-ci.com/docs/tools/php/php-scrutinizer/#list-dependency-paths

Loading history...
6
use SilverStripe\BehatExtension\Context\LoginContext as BehatLoginContext;
0 ignored issues
show
Bug introduced by
The type SilverStripe\BehatExtension\Context\LoginContext was not found. Maybe you did not declare it correctly or list all dependencies?

The issue could also be caused by a filter entry in the build configuration. If the path has been excluded in your configuration, e.g. excluded_paths: ["lib/*"], you can move it to the dependency path list as follows:

filter:
    dependency_paths: ["lib/*"]

For further information see https://scrutinizer-ci.com/docs/tools/php/php-scrutinizer/#list-dependency-paths

Loading history...
7
8
class LoginContext extends BehatLoginContext
9
{
10
    /**
11
    *
12
    * Check if the user can edit a page
13
    *
14
    * Example: Then pages should be editable by "Admin"
15
    * Then pages should not be editable by "Admin"
16
    *
17
    * @Then /^pages should( not? |\s*)be editable by "([^"]*)"$/
18
    */
19
    public function pagesShouldBeEditableBy($negative, $permCode)
20
    {
21
        // Reset permission cache
22
        $page = Page::get()->First();
23
        assertNotNull($page, 'A page exists');
0 ignored issues
show
Bug introduced by
The function assertNotNull was not found. Maybe you did not declare it correctly or list all dependencies? ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-call  annotation

23
        /** @scrutinizer ignore-call */ 
24
        assertNotNull($page, 'A page exists');
Loading history...
24
        $email = "{$permCode}@example.org";
25
        $password = 'Password!456';
26
        $member = $this->generateMemberWithPermission($email, $password, $permCode);
27
        $canEdit = strstr($negative, 'not') ? false : true;
28
29
        if ($canEdit) {
30
            assertTrue($page->canEdit($member), 'The member can edit this page');
0 ignored issues
show
Bug introduced by
The function assertTrue was not found. Maybe you did not declare it correctly or list all dependencies? ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-call  annotation

30
            /** @scrutinizer ignore-call */ 
31
            assertTrue($page->canEdit($member), 'The member can edit this page');
Loading history...
31
        } else {
32
            assertFalse($page->canEdit($member), 'The member cannot edit this page');
0 ignored issues
show
Bug introduced by
The function assertFalse was not found. Maybe you did not declare it correctly or list all dependencies? ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-call  annotation

32
            /** @scrutinizer ignore-call */ 
33
            assertFalse($page->canEdit($member), 'The member cannot edit this page');
Loading history...
33
        }
34
    }
35
}
36