# 查询单条数据.findOne

Testing Is Documentation

tests/Database/Read/FindOneTest.php

Uses

<?php

use Tests\Database\DatabaseTestCase as TestCase;

# findOne 查询单条数据

public function testBaseUse(): void
{
    $connect = $this->createDatabaseConnectMock();
    $sql = <<<'eot'
        [
            "SELECT `test`.* FROM `test` LIMIT 1",
            [],
            false
        ]
        eot;

    $this->assertSame(
        $sql,
        $this->varJson(
            $connect
                ->sql()
                ->table('test')
                ->findOne()
        )
    );
}

# one.find 查询单条数据

public function testOneFind(): void
{
    $connect = $this->createDatabaseConnectMock();
    $sql = <<<'eot'
        [
            "SELECT `test`.* FROM `test` LIMIT 1",
            [],
            false
        ]
        eot;

    $this->assertSame(
        $sql,
        $this->varJson(
            $connect
                ->sql()
                ->table('test')
                ->one()
                ->find()
        )
    );
}