From 795c74100dc7fc3a01706b63bcd8872469be9a90 Mon Sep 17 00:00:00 2001 From: Carsten Brandt Date: Thu, 26 Dec 2013 01:18:55 +0100 Subject: [PATCH] reverted #1598 and added a test for it --- framework/yii/db/Query.php | 2 +- tests/unit/framework/db/QueryTest.php | 11 +++++++++++ 2 files changed, 12 insertions(+), 1 deletion(-) diff --git a/framework/yii/db/Query.php b/framework/yii/db/Query.php index 2baa78c..ee24c2f 100644 --- a/framework/yii/db/Query.php +++ b/framework/yii/db/Query.php @@ -148,7 +148,7 @@ class Query extends Component implements QueryInterface * Executes the query and returns a single row of result. * @param Connection $db the database connection used to generate the SQL statement. * If this parameter is not given, the `db` application component will be used. - * @return array|boolean the first row (in terms of an array) of the query result. Null is returned if the query + * @return array|boolean the first row (in terms of an array) of the query result. False is returned if the query * results in nothing. */ public function one($db = null) diff --git a/tests/unit/framework/db/QueryTest.php b/tests/unit/framework/db/QueryTest.php index 77c1ac0..199b6a2 100644 --- a/tests/unit/framework/db/QueryTest.php +++ b/tests/unit/framework/db/QueryTest.php @@ -112,4 +112,15 @@ class QueryTest extends DatabaseTestCase public function testUnion() { } + + public function testOne() + { + $db = $this->getConnection(); + + $result = (new Query)->from('tbl_customer')->where(['status' => 2])->one($db); + $this->assertEquals('user3', $result['name']); + + $result = (new Query)->from('tbl_customer')->where(['status' => 3])->one($db); + $this->assertFalse($result); + } }