public function NameAutocompleteTest::testLogNameAutocompleteMultipleLogs in Log entity 2.x
Tests the order of logs returned.
File
- tests/
src/ Kernel/ NameAutocompleteTest.php, line 180
Class
- NameAutocompleteTest
- Tests name autocomplete for logs.
Namespace
Drupal\Tests\log\KernelCode
public function testLogNameAutocompleteMultipleLogs() {
// Add a duplicate log that should be on top of the results.
$this->logs[] = $this
->createLogEntity([
'name' => 'Z log',
'uid' => $this->adminAccount
->id(),
]);
$this->logs[] = $this
->createLogEntity([
'name' => 'Z log',
'uid' => $this->adminAccount
->id(),
]);
$this->container
->get('current_user')
->setAccount($this->adminAccount);
$result = $this
->getAutocompleteResult('log');
$this
->assertEqual(count($this->logs) - 1, count($result), 'Duplicated log is not duplicated in the autocomplete results.');
$expected_order = [
'Z log',
'First log',
'Second log',
'Third log',
];
$this
->assertEqual($result, $expected_order, 'Order of results is as expected.');
}