github.com/dolthub/go-mysql-server@v0.18.0/_integration/php/tests/MySQLTest.php (about)

     1  <?php
     2  declare(strict_types=1);
     3  
     4  use PHPUnit\Framework\TestCase;
     5  
     6  final class MySQLTest extends TestCase
     7  {
     8      public function testConnection(): void {
     9          try {
    10              $conn = new PDO("mysql:host=127.0.0.1:3306;dbname=mydb", "root", "");
    11              $conn->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION);
    12  
    13              $stmt = $conn->query('SELECT name, email FROM mytable ORDER BY name, email');
    14              $result = $stmt->fetchAll(PDO::FETCH_ASSOC);
    15  
    16              $expected = [
    17                  ["name" => "Evil Bob", "email" => "evilbob@gmail.com"],
    18                  ["name" => "Jane Doe", "email" => "jane@doe.com"],
    19                  ["name" => "John Doe", "email" => "john@doe.com"],
    20                  ["name" => "John Doe", "email" => "johnalt@doe.com"],
    21              ];
    22  
    23              $this->assertEquals($expected, $result);
    24          } catch (\PDOException $e) {
    25              $this->assertFalse(true, $e->getMessage());
    26          }
    27      }
    28  }