Skip to content

Commit

Permalink
[update] use field filter constants in tests
Browse files Browse the repository at this point in the history
  • Loading branch information
georgehristov committed Aug 6, 2020
1 parent 5e29bfa commit 2c70758
Showing 1 changed file with 6 additions and 6 deletions.
12 changes: 6 additions & 6 deletions tests/FieldTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -781,19 +781,19 @@ public function testGetFields()
$model->addField('not_editable', ['ui' => ['editable' => false]]);

$this->assertSame(['system', 'editable', 'editable_system', 'visible', 'visible_system', 'not_editable'], array_keys($model->getFields()));
$this->assertSame(['system', 'editable_system', 'visible_system'], array_keys($model->getFields('system')));
$this->assertSame(['editable', 'visible', 'not_editable'], array_keys($model->getFields('not system')));
$this->assertSame(['editable', 'editable_system', 'visible'], array_keys($model->getFields('editable')));
$this->assertSame(['editable', 'visible', 'visible_system', 'not_editable'], array_keys($model->getFields('visible')));
$this->assertSame(['editable', 'editable_system', 'visible', 'visible_system', 'not_editable'], array_keys($model->getFields(['editable', 'visible'])));
$this->assertSame(['system', 'editable_system', 'visible_system'], array_keys($model->getFields(Model::FIELD_FILTER_SYSTEM)));
$this->assertSame(['editable', 'visible', 'not_editable'], array_keys($model->getFields(Model::FIELD_FILTER_NOT_SYSTEM)));
$this->assertSame(['editable', 'editable_system', 'visible'], array_keys($model->getFields(Model::FIELD_FILTER_EDITABLE)));
$this->assertSame(['editable', 'visible', 'visible_system', 'not_editable'], array_keys($model->getFields(Model::FIELD_FILTER_VISIBLE)));
$this->assertSame(['editable', 'editable_system', 'visible', 'visible_system', 'not_editable'], array_keys($model->getFields([Model::FIELD_FILTER_EDITABLE, Model::FIELD_FILTER_VISIBLE])));

$model->onlyFields(['system', 'visible', 'not_editable']);

// getFields() is unaffected by only_fields, will always return all fields
$this->assertSame(['system', 'editable', 'editable_system', 'visible', 'visible_system', 'not_editable'], array_keys($model->getFields()));

// only return subset of only_fields
$this->assertSame(['visible', 'not_editable'], array_keys($model->getFields('visible')));
$this->assertSame(['visible', 'not_editable'], array_keys($model->getFields(Model::FIELD_FILTER_VISIBLE)));

$this->expectExceptionMessage('not supported');
$model->getFields('foo');
Expand Down

0 comments on commit 2c70758

Please sign in to comment.