StaffTest   A
last analyzed

Complexity

Total Complexity 3

Size/Duplication

Total Lines 27
Duplicated Lines 0 %

Coupling/Cohesion

Components 0
Dependencies 2
Metric Value
wmc 3
lcom 0
cbo 2
dl 0
loc 27
rs 10

2 Methods

Rating   Name   Duplication   Size   Complexity  
A testGetCMSFields() 0 12 1
A getFieldnamesForTab() 0 9 2
1
<?php
2
3
class StaffTest extends SapphireTest
0 ignored issues
show
Coding Style Compatibility introduced by
PSR1 recommends that each class must be in a namespace of at least one level to avoid collisions.

You can fix this by adding a namespace to your class:

namespace YourVendor;

class YourClass { }

When choosing a vendor namespace, try to pick something that is not too generic to avoid conflicts with other libraries.

Loading history...
4
{
5
    public function testGetCMSFields()
6
    {
7
        $staff = new Staff();
8
        $fields = $staff->getCMSFields();
9
        $imageFields = $this->getFieldNamesForTab($fields, 'Root.Image');
10
        $this->assertEquals(array('Photo'), $imageFields);
0 ignored issues
show
Bug introduced by
The method assertEquals() does not seem to exist on object<StaffTest>.

This check looks for calls to methods that do not seem to exist on a given type. It looks for the method on the type itself as well as in inherited classes or implemented interfaces.

This is most likely a typographical error or the method has been renamed.

Loading history...
11
12
        $jobFields = $this->getFieldNamesForTab($fields, 'Root.JobDetail');
13
        $expected = array('JobTitle', 'Email', 'TelephoneNumberDesk',
14
                                'TelephoneNumberMobile');
15
        $this->assertEquals($expected, $jobFields);
0 ignored issues
show
Bug introduced by
The method assertEquals() does not seem to exist on object<StaffTest>.

This check looks for calls to methods that do not seem to exist on a given type. It looks for the method on the type itself as well as in inherited classes or implemented interfaces.

This is most likely a typographical error or the method has been renamed.

Loading history...
16
    }
17
18
19
    private function getFieldnamesForTab($fields, $tabName) {
20
        $tab = $fields->findOrMakeTab($tabName);
21
        $fields = $tab->fieldList();
22
        $names = array();
23
        foreach ($fields as $field) {
24
            array_push($names, $field->getName());
25
        }
26
        return $names;
27
    }
28
29
}
30