protected function SortTimestampIdTest::setUp in Log entity 2.x
Parameters
bool $import_test_views: Should the views specified on the test class be imported. If you need to setup some additional stuff, like fields, you need to call false and then call createTestViews for your own.
Overrides ViewsKernelTestBase::setUp
File
- tests/
src/ Kernel/ SortTimestampIdTest.php, line 48
Class
- SortTimestampIdTest
- Tests for Drupal\log\Plugin\views\sort\LogTimestampIdSort handler.
Namespace
Drupal\Tests\log\KernelCode
protected function setUp($import_test_views = TRUE) {
parent::setUp();
$this
->installEntitySchema('log');
$this
->installConfig([
'log',
'log_test',
]);
ViewTestData::createTestViews(get_class($this), [
'log_test',
]);
// Establish two different timestamps so the sort is meaningful.
$first_timestamp = 376185600;
$second_timestamp = 386121600;
// Three entities is the minimum amount to test two with the same timestamp
// and different ID and one with unique timestamp.
$first_entity = $this
->createLogEntity([
'name' => 'First',
'timestamp' => $first_timestamp,
]);
$second_entity = $this
->createLogEntity([
'name' => 'Second',
'timestamp' => $first_timestamp,
]);
$third_entity = $this
->createLogEntity([
'name' => 'Third',
'timestamp' => $second_timestamp,
]);
// Fill the expected results for the combinations.
$this->expectedResultASC = [
[
'name' => $first_entity
->get('name')->value,
'id' => $first_entity
->id(),
],
[
'name' => $second_entity
->get('name')->value,
'id' => $second_entity
->id(),
],
[
'name' => $third_entity
->get('name')->value,
'id' => $third_entity
->id(),
],
];
$this->expectedResultDESC = [
[
'name' => $third_entity
->get('name')->value,
'id' => $third_entity
->id(),
],
[
'name' => $second_entity
->get('name')->value,
'id' => $second_entity
->id(),
],
[
'name' => $first_entity
->get('name')->value,
'id' => $first_entity
->id(),
],
];
}