CommentTestHelper   A
last analyzed

Complexity

Total Complexity 3

Size/Duplication

Total Lines 20
Duplicated Lines 0 %

Importance

Changes 0
Metric Value
eloc 8
dl 0
loc 20
rs 10
c 0
b 0
f 0
wmc 3

2 Methods

Rating   Name   Duplication   Size   Complexity  
A assertFieldsForTab() 0 5 1
A assertFieldNames() 0 7 2
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