public function DateRecurViewsOccurrenceFilterTest::testInvalidInput in Recurring Dates Field 3.0.x
Same name and namespace in other branches
- 8.2 tests/src/Kernel/DateRecurViewsOccurrenceFilterTest.php \Drupal\Tests\date_recur\Kernel\DateRecurViewsOccurrenceFilterTest::testInvalidInput()
- 3.x tests/src/Kernel/DateRecurViewsOccurrenceFilterTest.php \Drupal\Tests\date_recur\Kernel\DateRecurViewsOccurrenceFilterTest::testInvalidInput()
- 3.1.x tests/src/Kernel/DateRecurViewsOccurrenceFilterTest.php \Drupal\Tests\date_recur\Kernel\DateRecurViewsOccurrenceFilterTest::testInvalidInput()
Tests date recur filter plugin.
If asserting successful validation, the raw input must be set up to return one result matching the test entity.
@dataProvider providerInvalidInput
Parameters
string $granularity: Granularity.
string $rawInput: User input.
bool $successfulValidate: Whether the validation was successful.
File
- tests/
src/ Kernel/ DateRecurViewsOccurrenceFilterTest.php, line 638
Class
- DateRecurViewsOccurrenceFilterTest
- Tests the results of 'date_recur_occurrences_filter' filter plugin.
Namespace
Drupal\Tests\date_recur\KernelCode
public function testInvalidInput($granularity, $rawInput, $successfulValidate) {
// Create a test entity.
$entity = $this
->createEntity();
$entity->{$this->fieldName} = [
[
'value' => '2014-09-12T23:00:00',
'end_value' => '2014-09-13T07:00:00',
'rrule' => 'FREQ=DAILY;COUNT=1',
'infinite' => '1',
'timezone' => 'Australia/Sydney',
],
];
$entity
->save();
$exposedIdentifier = 'dr_occurrences';
$filterOptions = [
'operator' => '=',
'value' => '',
'value_granularity' => $granularity,
'exposed' => TRUE,
'expose' => [
'identifier' => $exposedIdentifier,
'operator' => 'dr_occurrences_op',
'use_operator' => FALSE,
'required' => FALSE,
],
];
$input = [
$exposedIdentifier => $rawInput,
];
/** @var \Drupal\views\ViewEntityInterface $view */
$view = View::load('dr_entity_test_list');
$executable = $view
->getExecutable();
$executable
->addHandler('default', 'filter', 'dr_entity_test', $this->fieldName . '_occurrences', $filterOptions);
$executable
->setExposedInput($input);
$executable
->execute();
if ($successfulValidate) {
$this
->assertTrue(!isset($executable->build_info['abort']));
$expectedRowWithEntity = [
[
'id' => $entity
->id(),
],
];
$this
->assertFilter($input, $expectedRowWithEntity, $filterOptions);
}
else {
$this
->assertTrue(isset($executable->build_info['abort']));
}
}