Commit af385858 by Alexander Makarov

Fixed tests for elasticsearch, mongo, redis

parent ed97632f
...@@ -35,10 +35,7 @@ class Customer extends ActiveRecord ...@@ -35,10 +35,7 @@ class Customer extends ActiveRecord
return $this->hasMany(Order::className(), array('customer_id' => 'id'))->orderBy('create_time'); return $this->hasMany(Order::className(), array('customer_id' => 'id'))->orderBy('create_time');
} }
public static function active($query)
{
$query->andWhere(array('status' => 1));
}
public function afterSave($insert) public function afterSave($insert)
{ {
...@@ -67,4 +64,9 @@ class Customer extends ActiveRecord ...@@ -67,4 +64,9 @@ class Customer extends ActiveRecord
]); ]);
} }
public static function createQuery()
{
return new CustomerQuery(['modelClass' => get_called_class()]);
}
} }
<?php
namespace yiiunit\data\ar\elasticsearch;
use yii\elasticsearch\ActiveQuery;
/**
* CustomerQuery
*/
class CustomerQuery extends ActiveQuery
{
public function active()
{
$this->andWhere(array('status' => 1));
return $this;
}
}
\ No newline at end of file
...@@ -2,6 +2,9 @@ ...@@ -2,6 +2,9 @@
namespace yiiunit\data\ar\mongodb\file; namespace yiiunit\data\ar\mongodb\file;
use yii\mongodb\file\ActiveQuery;
use yiiunit\data\ar\redis\CustomerQuery;
class CustomerFile extends ActiveRecord class CustomerFile extends ActiveRecord
{ {
public static function collectionName() public static function collectionName()
...@@ -20,8 +23,8 @@ class CustomerFile extends ActiveRecord ...@@ -20,8 +23,8 @@ class CustomerFile extends ActiveRecord
); );
} }
public static function activeOnly($query) public static function createQuery()
{ {
$query->andWhere(['status' => 2]); return new CustomerQuery(['modelClass' => get_called_class()]);
} }
} }
\ No newline at end of file
<?php
namespace yiiunit\data\ar\mongodb\file;
use yii\mongodb\file\ActiveQuery;
/**
* CustomerFileQuery
*/
class CustomerFileQuery extends ActiveQuery
{
public function activeOnly()
{
$this->andWhere(['status' => 2]);
return $this;
}
}
\ No newline at end of file
...@@ -2,6 +2,7 @@ ...@@ -2,6 +2,7 @@
namespace yiiunit\data\ar\redis; namespace yiiunit\data\ar\redis;
use yii\redis\ActiveQuery;
use yiiunit\extensions\redis\ActiveRecordTest; use yiiunit\extensions\redis\ActiveRecordTest;
class Customer extends ActiveRecord class Customer extends ActiveRecord
...@@ -24,15 +25,15 @@ class Customer extends ActiveRecord ...@@ -24,15 +25,15 @@ class Customer extends ActiveRecord
return $this->hasMany(Order::className(), ['customer_id' => 'id']); return $this->hasMany(Order::className(), ['customer_id' => 'id']);
} }
public static function active($query)
{
$query->andWhere(['status' => 1]);
}
public function afterSave($insert) public function afterSave($insert)
{ {
ActiveRecordTest::$afterSaveInsert = $insert; ActiveRecordTest::$afterSaveInsert = $insert;
ActiveRecordTest::$afterSaveNewRecord = $this->isNewRecord; ActiveRecordTest::$afterSaveNewRecord = $this->isNewRecord;
parent::afterSave($insert); parent::afterSave($insert);
} }
public static function createQuery()
{
return new CustomerQuery(['modelClass' => get_called_class()]);
}
} }
\ No newline at end of file
<?php
namespace yiiunit\data\ar\redis;
use yii\redis\ActiveQuery;
/**
* CustomerQuery
*/
class CustomerQuery extends ActiveQuery
{
public function active()
{
$this->andWhere(['status' => 1]);
return $this;
}
}
\ No newline at end of file
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment