SelectLeastTest.php

Same filename in other branches
  1. 9 core/tests/Drupal/KernelTests/Core/Database/SelectLeastTest.php
  2. 11.x core/tests/Drupal/KernelTests/Core/Database/SelectLeastTest.php

Namespace

Drupal\KernelTests\Core\Database

File

core/tests/Drupal/KernelTests/Core/Database/SelectLeastTest.php

View source
<?php

declare (strict_types=1);
namespace Drupal\KernelTests\Core\Database;


/**
 * Tests the SQL LEAST operator.
 *
 * @group Database
 */
class SelectLeastTest extends DatabaseTestBase {
    
    /**
     * Tests the SQL LEAST operator.
     *
     * @dataProvider selectLeastProvider
     */
    public function testSelectLeast($values, $expected) : void {
        $least = $this->connection
            ->query("SELECT LEAST(:values[])", [
            ':values[]' => $values,
        ])
            ->fetchField();
        $this->assertEquals($expected, $least);
    }
    public static function selectLeastProvider() {
        return [
            [
                [
                    1,
                    2,
                    3,
                    4,
                    5,
                    6,
                ],
                1,
            ],
            [
                [
                    'A',
                    'B',
                    'C',
                    'NULL',
                    'F',
                ],
                'A',
            ],
            [
                [
                    'NULL',
                    'NULL',
                ],
                'NULL',
            ],
            [
                [
                    'TRUE',
                    'FALSE',
                ],
                'FALSE',
            ],
            [
                [
                    'A',
                    'B',
                    'C',
                    'NULL',
                ],
                'A',
            ],
        ];
    }

}

Classes

Title Deprecated Summary
SelectLeastTest Tests the SQL LEAST operator.

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