public function EntityQueryTest::testTableSort in Zircon Profile 8
Same name and namespace in other branches
- 8.0 core/modules/system/src/Tests/Entity/EntityQueryTest.php \Drupal\system\Tests\Entity\EntityQueryTest::testTableSort()
Test tablesort().
File
- core/
modules/ system/ src/ Tests/ Entity/ EntityQueryTest.php, line 409 - Contains \Drupal\system\Tests\Entity\EntityQueryTest.
Class
- EntityQueryTest
- Tests Entity Query functionality.
Namespace
Drupal\system\Tests\EntityCode
public function testTableSort() {
// While ordering on bundles do not give us a definite order, we can still
// assert that all entities from one bundle are after the other as the
// order dictates.
$request = Request::createFromGlobals();
$request->query
->replace(array(
'sort' => 'asc',
'order' => 'Type',
));
\Drupal::getContainer()
->get('request_stack')
->push($request);
$header = array(
'id' => array(
'data' => 'Id',
'specifier' => 'id',
),
'type' => array(
'data' => 'Type',
'specifier' => 'type',
),
);
$this->queryResults = array_values($this->factory
->get('entity_test_mulrev')
->tableSort($header)
->execute());
$this
->assertBundleOrder('asc');
$request->query
->add(array(
'sort' => 'desc',
));
\Drupal::getContainer()
->get('request_stack')
->push($request);
$header = array(
'id' => array(
'data' => 'Id',
'specifier' => 'id',
),
'type' => array(
'data' => 'Type',
'specifier' => 'type',
),
);
$this->queryResults = array_values($this->factory
->get('entity_test_mulrev')
->tableSort($header)
->execute());
$this
->assertBundleOrder('desc');
// Ordering on ID is definite, however.
$request->query
->add(array(
'order' => 'Id',
));
\Drupal::getContainer()
->get('request_stack')
->push($request);
$this->queryResults = $this->factory
->get('entity_test_mulrev')
->tableSort($header)
->execute();
$this
->assertResult(range(15, 1));
}