public function MixitUpFiltersFormTest::testBuildForm in MixItUp Views 8.2
Same name and namespace in other branches
- 8 tests/src/Kernel/MixitUpFiltersFormTest.php \Drupal\Tests\mixitup_views\Kernel\MixitUpFiltersFormTest::testBuildForm()
Covers buildForm method in MixitupFiltersForm class.
@covers \Drupal\mixitup_views\Form\MixitupFiltersForm::buildForm
File
- tests/
src/ Kernel/ MixitUpFiltersFormTest.php, line 103
Class
- MixitUpFiltersFormTest
- Class MixitUpFiltersFormTest.
Namespace
Drupal\Tests\mixitup_views\KernelCode
public function testBuildForm() {
// Creating MixItUpFunc Service instance with one of nodes.
$this->mixitupFunc
->getRowClasses(5);
// Defining options array.
$options = [
'grouping' => [],
'row_class' => '',
'default_row_class' => TRUE,
'uses_fields' => FALSE,
'selectors_target' => '.mix',
'selectors_filter' => '.filter',
'selectors_sort' => '.sort',
'load_filter' => 'all',
'load_sort' => 'default:asc',
'animation_enable' => 1,
'animation_effects' => 'fade scale',
'animation_duration' => '600',
'animation_easing' => 'ease',
'animation_perspectiveDistance' => '3000px',
'animation_perspectiveOrigin' => '50% 50%',
'animation_queue' => 1,
'animation_queueLimit' => '1',
'restrict_vocab' => 0,
'restrict_vocab_ids' => [],
'filter_type' => 'checkboxes',
'agregation_type' => 'or',
'use_sort' => 0,
'sorts' => [
'node_field_data_created' => 'Created',
],
'hide_unchecked_chekboxes' => 0,
];
// Tests build form.
$form = [];
$form_state = new FormState();
$form = $this->testObject
->buildForm($form, $form_state, $options);
self::assertEquals('<a href="#reset" id="reset">Reset filters</a>', $form['reset']['#markup']);
self::assertEquals('checkboxes', $form['filter_tags']['#type']);
$filter_options = [
'.tid_2' => 'test name1',
'.tid_3' => 'test name2',
];
self::assertEquals($filter_options, $form['filter_tags']['#options']);
self::assertEquals('tags', $form['filter_tags']['#attributes']['vid']);
// Creating MixItUpFunc Service instance with one of nodes.
$this->mixitupFunc
->getRowClasses(4);
// Tests build form.
$form = [];
$form_state = new FormState();
$form = $this->testObject
->buildForm($form, $form_state, $options);
$filter_options = [
'.tid_1' => 'test name0',
'.tid_4' => 'test name3',
'.tid_2' => 'test name1',
'.tid_3' => 'test name2',
];
self::assertEquals($filter_options, $form['filter_tags']['#options']);
// Creating MixItUpFunc Service instance with one of nodes.
$this->mixitupFunc
->getRowClasses(3);
// Tests build form.
$form = [];
$form_state = new FormState();
$form = $this->testObject
->buildForm($form, $form_state, $options);
unset($filter_options);
$filter_options = [
'.tid_1' => 'test name0',
'.tid_5' => 'test name4',
'.tid_4' => 'test name3',
'.tid_2' => 'test name1',
'.tid_3' => 'test name2',
];
self::assertEquals($filter_options, $form['filter_tags']['#options']);
// Creating MixItUpFunc Service instance with one of nodes.
$this->mixitupFunc
->getRowClasses(2);
// Tests build form.
$form = [];
$form_state = new FormState();
$form = $this->testObject
->buildForm($form, $form_state, $options);
unset($filter_options);
$filter_options = [
'.tid_3' => 'test name2',
'.tid_4' => 'test name3',
'.tid_1' => 'test name0',
'.tid_5' => 'test name4',
'.tid_2' => 'test name1',
];
self::assertEquals($filter_options, $form['filter_tags']['#options']);
// Creating MixItUpFunc Service instance with one of nodes.
$this->mixitupFunc
->getRowClasses(1);
// Tests build form.
$form = [];
$form_state = new FormState();
$form = $this->testObject
->buildForm($form, $form_state, $options);
unset($filter_options);
$filter_options = [
'.tid_2' => 'test name1',
'.tid_4' => 'test name3',
'.tid_3' => 'test name2',
'.tid_1' => 'test name0',
'.tid_5' => 'test name4',
];
self::assertEquals($filter_options, $form['filter_tags']['#options']);
}