2016-01-07 07:59:10 +01:00
|
|
|
<?php
|
|
|
|
|
2017-01-16 20:57:37 +01:00
|
|
|
namespace SilverStripe\Comments\Tests;
|
|
|
|
|
|
|
|
use SilverStripe\Dev\TestOnly;
|
|
|
|
use SilverStripe\Forms\FieldGroup;
|
|
|
|
|
|
|
|
class CommentTestHelper implements TestOnly
|
2016-02-19 01:48:25 +01:00
|
|
|
{
|
2017-01-16 20:57:37 +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-01-07 07:59:10 +01:00
|
|
|
*/
|
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();
|
2017-01-16 20:57:37 +01:00
|
|
|
self::assertFieldNames($context, $expected, $fields);
|
2016-01-07 07:59:10 +01:00
|
|
|
}
|
|
|
|
|
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) {
|
2017-01-16 20:57:37 +01:00
|
|
|
array_push($actual, $field->getName());
|
2016-01-07 07:59:10 +01:00
|
|
|
}
|
|
|
|
$context->assertEquals($expected, $actual);
|
|
|
|
}
|
|
|
|
}
|