From 3db7a075340043915695418d4ea15f229803d8d2 Mon Sep 17 00:00:00 2001 From: Paul Klimov Date: Tue, 3 Dec 2013 11:17:51 +0200 Subject: [PATCH] Method "yii\sphinx\ActiveRecord::find()" removed in favour of "BaseActiveRecord::find()". --- extensions/sphinx/ActiveRecord.php | 27 ----------------------- tests/unit/extensions/sphinx/ActiveRecordTest.php | 9 ++++---- 2 files changed, 4 insertions(+), 32 deletions(-) diff --git a/extensions/sphinx/ActiveRecord.php b/extensions/sphinx/ActiveRecord.php index f766d6d..7128b79 100644 --- a/extensions/sphinx/ActiveRecord.php +++ b/extensions/sphinx/ActiveRecord.php @@ -79,33 +79,6 @@ abstract class ActiveRecord extends BaseActiveRecord } /** - * Creates an [[ActiveQuery]] instance for query purpose. - * - * @param mixed $q the query parameter. This can be one of the followings: - * - * - a string: fulltext query by a query string and return the list - * of matching records. - * - an array of name-value pairs: query by a set of column values and return a single record matching all of them. - * - null: return a new [[ActiveQuery]] object for further query purpose. - * - * @return ActiveQuery|ActiveRecord[]|ActiveRecord|null When `$q` is null, a new [[ActiveQuery]] instance - * is returned; when `$q` is a string, an array of ActiveRecord objects matching it will be returned; - * when `$q` is an array, an ActiveRecord object matching it will be returned (null - * will be returned if there is no matching). - * @see createQuery() - */ - public static function find($q = null) - { - $query = static::createQuery(); - if (is_array($q)) { - return $query->where($q)->one(); - } elseif ($q !== null) { - return $query->match($q)->all(); - } - return $query; - } - - /** * Creates an [[ActiveQuery]] instance with a given SQL statement. * * Note that because the SQL statement is already specified, calling additional diff --git a/tests/unit/extensions/sphinx/ActiveRecordTest.php b/tests/unit/extensions/sphinx/ActiveRecordTest.php index d86c141..67afe27 100644 --- a/tests/unit/extensions/sphinx/ActiveRecordTest.php +++ b/tests/unit/extensions/sphinx/ActiveRecordTest.php @@ -41,10 +41,9 @@ class ActiveRecordTest extends SphinxTestCase $this->assertTrue($articles[1] instanceof ArticleIndex); // find fulltext - $articles = ArticleIndex::find('cats'); - $this->assertEquals(1, count($articles)); - $this->assertTrue($articles[0] instanceof ArticleIndex); - $this->assertEquals(1, $articles[0]->id); + $article = ArticleIndex::find(2); + $this->assertTrue($article instanceof ArticleIndex); + $this->assertEquals(2, $article->id); // find by column values $article = ArticleIndex::find(['id' => 2, 'author_id' => 2]); @@ -168,7 +167,7 @@ class ActiveRecordTest extends SphinxTestCase $record = RuntimeIndex::find(['id' => 2]); $record->content = 'Test content with ' . $query; $record->save(); - $rows = RuntimeIndex::find($query); + $rows = RuntimeIndex::find()->match($query); $this->assertNotEmpty($rows); // updateAll