SyntaxTest.php

Same filename in this branch
  1. 11.x core/modules/sqlite/tests/src/Kernel/sqlite/SyntaxTest.php
  2. 11.x core/modules/mysql/tests/src/Kernel/mysql/SyntaxTest.php
  3. 11.x core/modules/pgsql/tests/src/Kernel/pgsql/SyntaxTest.php
Same filename and directory in other branches
  1. 10 core/modules/sqlite/tests/src/Kernel/sqlite/SyntaxTest.php
  2. 10 core/modules/mysql/tests/src/Kernel/mysql/SyntaxTest.php
  3. 10 core/modules/pgsql/tests/src/Kernel/pgsql/SyntaxTest.php

Namespace

Drupal\Tests\mysqli\Kernel\mysqli

File

core/modules/mysqli/tests/src/Kernel/mysqli/SyntaxTest.php

View source
<?php

declare (strict_types=1);
namespace Drupal\Tests\mysqli\Kernel\mysqli;

use Drupal\KernelTests\Core\Database\DriverSpecificSyntaxTestBase;
use PHPUnit\Framework\Attributes\Group;

/**
 * Tests MySql syntax interpretation.
 */
class SyntaxTest extends DriverSpecificSyntaxTestBase {
  
  /**
   * Tests string concatenation with separator, with field values.
   */
  public function testConcatWsFields() : void {
    $result = $this->connection
      ->query("SELECT CONCAT_WS('-', CONVERT(:a1 USING utf8mb4), [name], CONVERT(:a2 USING utf8mb4), [age]) FROM {test} WHERE [age] = :age", [
      ':a1' => 'name',
      ':a2' => 'age',
      ':age' => 25,
    ]);
    $this->assertSame('name-John-age-25', $result->fetchField());
  }

}

Classes

Title Deprecated Summary
SyntaxTest Tests MySql syntax interpretation.

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