CommentTestHelper::assertFieldsForTab()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 5
Code Lines 3

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
cc 1
eloc 3
nc 1
nop 4
dl 0
loc 5
rs 10
c 0
b 0
f 0
1
<?php
2
3
namespace SilverStripe\Comments\Tests;
4
5
use SilverStripe\Dev\TestOnly;
6
use SilverStripe\Forms\FieldGroup;
7
8
class CommentTestHelper implements TestOnly
9
{
10
    /**
11
     * This only works if the last section is not a field group, e.g. a Comments
12
     * field group inside of a Root.Settings tab will not work
13
     */
14
    public static function assertFieldsForTab($context, $tabName, $expected, $fields)
15
    {
16
        $tab = $fields->findOrMakeTab($tabName);
17
        $fields = $tab->FieldList();
18
        self::assertFieldNames($context, $expected, $fields);
19
    }
20
21
    public static function assertFieldNames($context, $expected, $fields)
22
    {
23
        $actual = array();
24
        foreach ($fields as $field) {
25
            array_push($actual, $field->getName());
26
        }
27
        $context->assertEquals($expected, $actual);
28
    }
29
}
30