function OrderByTest::testInvalidDirection

Same name and namespace in other branches
  1. 9 core/tests/Drupal/Tests/Core/Database/OrderByTest.php \Drupal\Tests\Core\Database\OrderByTest::testInvalidDirection()
  2. 8.9.x core/tests/Drupal/Tests/Core/Database/OrderByTest.php \Drupal\Tests\Core\Database\OrderByTest::testInvalidDirection()
  3. 10 core/tests/Drupal/Tests/Core/Database/OrderByTest.php \Drupal\Tests\Core\Database\OrderByTest::testInvalidDirection()

Checks that invalid sort directions in ORDER BY get converted to ASC.

File

core/tests/Drupal/Tests/Core/Database/OrderByTest.php, line 40

Class

OrderByTest
Tests the orderBy() method of select queries.

Namespace

Drupal\Tests\Core\Database

Code

public function testInvalidDirection() : void {
    $this->query
        ->orderBy('test', 'invalid direction');
    $order_bys = $this->query
        ->getOrderBy();
    $this->assertEquals('ASC', $order_bys['test'], 'Invalid order by direction is converted to ASC.');
}

Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.