public function DateRecurOccurrenceTableTest::testOccurrenceTableValues in Recurring Dates Field 3.0.x
Same name and namespace in other branches
- 8.2 tests/src/Kernel/DateRecurOccurrenceTableTest.php \Drupal\Tests\date_recur\Kernel\DateRecurOccurrenceTableTest::testOccurrenceTableValues()
- 3.x tests/src/Kernel/DateRecurOccurrenceTableTest.php \Drupal\Tests\date_recur\Kernel\DateRecurOccurrenceTableTest::testOccurrenceTableValues()
- 3.1.x tests/src/Kernel/DateRecurOccurrenceTableTest.php \Drupal\Tests\date_recur\Kernel\DateRecurOccurrenceTableTest::testOccurrenceTableValues()
Tests values of occurrence table.
File
- tests/
src/ Kernel/ DateRecurOccurrenceTableTest.php, line 140
Class
- DateRecurOccurrenceTableTest
- Tests occurrence tables values.
Namespace
Drupal\Tests\date_recur\KernelCode
public function testOccurrenceTableValues() {
$columnNameValue = $this->fieldName . '_value';
$columnNameEndValue = $this->fieldName . '_end_value';
$entity = $this
->createEntity();
$entityTypeId = $entity
->getEntityTypeId();
$entity->{$this->fieldName} = [
[
'value' => '2014-06-17T23:00:00',
'end_value' => '2014-06-18T07:00:00',
'rrule' => 'FREQ=WEEKLY;BYDAY=MO,TU,WE,TH,FR;COUNT=5',
'infinite' => '0',
'timezone' => 'Australia/Sydney',
],
[
'value' => '2015-07-17T02:00:00',
'end_value' => '2015-07-18T10:00:00',
'rrule' => 'FREQ=WEEKLY;BYDAY=MO,TU,WE,TH,FR;COUNT=2',
'infinite' => '0',
'timezone' => 'Indian/Cocos',
],
];
$entity
->save();
$tableName = 'date_recur__' . $entityTypeId . '__' . $this->fieldName;
$fields = [
'entity_id',
'revision_id',
'field_delta',
'delta',
$columnNameValue,
$columnNameEndValue,
];
$results = $this->container
->get('database')
->select($tableName, 'occurences')
->fields('occurences', $fields)
->execute()
->fetchAll();
$this
->assertCount(7, $results);
$assertExpected = [
[
'entity_id' => $entity
->id(),
'revision_id' => $entity
->getRevisionId(),
'field_delta' => 0,
'delta' => 0,
$columnNameValue => '2014-06-17T23:00:00',
$columnNameEndValue => '2014-06-18T07:00:00',
],
[
'entity_id' => $entity
->id(),
'revision_id' => $entity
->getRevisionId(),
'field_delta' => 0,
'delta' => 1,
$columnNameValue => '2014-06-18T23:00:00',
$columnNameEndValue => '2014-06-19T07:00:00',
],
[
'entity_id' => $entity
->id(),
'revision_id' => $entity
->getRevisionId(),
'field_delta' => 0,
'delta' => 2,
$columnNameValue => '2014-06-19T23:00:00',
$columnNameEndValue => '2014-06-20T07:00:00',
],
[
'entity_id' => $entity
->id(),
'revision_id' => $entity
->getRevisionId(),
'field_delta' => 0,
'delta' => 3,
$columnNameValue => '2014-06-22T23:00:00',
$columnNameEndValue => '2014-06-23T07:00:00',
],
[
'entity_id' => $entity
->id(),
'revision_id' => $entity
->getRevisionId(),
'field_delta' => 0,
'delta' => 4,
$columnNameValue => '2014-06-23T23:00:00',
$columnNameEndValue => '2014-06-24T07:00:00',
],
[
'entity_id' => $entity
->id(),
'revision_id' => $entity
->getRevisionId(),
'field_delta' => '1',
'delta' => '0',
$columnNameValue => '2015-07-17T02:00:00',
$columnNameEndValue => '2015-07-18T10:00:00',
],
[
'entity_id' => $entity
->id(),
'revision_id' => $entity
->getRevisionId(),
'field_delta' => '1',
'delta' => '1',
$columnNameValue => '2015-07-20T02:00:00',
$columnNameEndValue => '2015-07-21T10:00:00',
],
];
foreach ($results as $actualIndex => $actualValues) {
$expectedValues = $assertExpected[$actualIndex];
$actualValues = (array) $actualValues;
$this
->assertEquals($expectedValues, $actualValues);
}
}