2016-01-07 07:59:10 +01:00
|
|
|
<?php
|
|
|
|
|
2016-02-19 01:48:25 +01:00
|
|
|
class CommentTestHelper
|
|
|
|
{
|
2016-01-07 07:59:10 +01:00
|
|
|
/*
|
|
|
|
This only works if the last section is not a field group, e.g. a Comments
|
|
|
|
field group inside of a Root.Settings tab will not work
|
|
|
|
*/
|
2016-02-19 01:48:25 +01:00
|
|
|
public static function assertFieldsForTab($context, $tabName, $expected, $fields)
|
|
|
|
{
|
2016-01-07 07:59:10 +01:00
|
|
|
$tab = $fields->findOrMakeTab($tabName);
|
|
|
|
$fields = $tab->FieldList();
|
|
|
|
CommentTestHelper::assertFieldNames($context, $expected, $fields);
|
|
|
|
}
|
|
|
|
|
2016-02-19 01:48:25 +01:00
|
|
|
public static function assertFieldNames($context, $expected, $fields)
|
|
|
|
{
|
2016-01-07 07:59:10 +01:00
|
|
|
$actual = array();
|
|
|
|
foreach ($fields as $field) {
|
|
|
|
if (get_class($field) == 'FieldGroup') {
|
|
|
|
array_push($actual, $field->Name());
|
|
|
|
} else {
|
|
|
|
array_push($actual, $field->getName());
|
|
|
|
}
|
|
|
|
}
|
|
|
|
$context->assertEquals($expected, $actual);
|
|
|
|
}
|
|
|
|
}
|