Commit 0699eaad by Alexander Makarov

Fixed test breaks

parent 53e96b29
<?php
namespace yiiunit\data\ar;
use yii\db\ActiveQuery;
use yiiunit\framework\db\ActiveRecordTest;
/**
......@@ -29,15 +30,15 @@ class Customer extends ActiveRecord
return $this->hasMany(Order::className(), ['customer_id' => 'id'])->orderBy('id');
}
public static function active($query)
{
$query->andWhere('status=1');
}
public function afterSave($insert)
{
ActiveRecordTest::$afterSaveInsert = $insert;
ActiveRecordTest::$afterSaveNewRecord = $this->isNewRecord;
parent::afterSave($insert);
}
public static function createQuery()
{
return new CustomerQuery(['modelClass' => get_called_class()]);
}
}
<?php
namespace yiiunit\data\ar;
use yii\db\ActiveQuery;
/**
* CustomerQuery
*/
class CustomerQuery extends ActiveQuery
{
public static function active($query)
{
$query->andWhere('status=1');
}
}
\ No newline at end of file
......@@ -2,6 +2,8 @@
namespace yiiunit\data\ar\mongodb;
use yii\mongodb\ActiveQuery;
class Customer extends ActiveRecord
{
public static function collectionName()
......@@ -20,13 +22,13 @@ class Customer extends ActiveRecord
];
}
public static function activeOnly($query)
public function getOrders()
{
$query->andWhere(['status' => 2]);
return $this->hasMany(CustomerOrder::className(), ['customer_id' => '_id']);
}
public function getOrders()
public static function createQuery()
{
return $this->hasMany(CustomerOrder::className(), ['customer_id' => '_id']);
return new CustomerQuery(['modelClass' => get_called_class()]);
}
}
\ No newline at end of file
<?php
namespace yiiunit\data\ar\mongodb;
use yii\mongodb\ActiveQuery;
/**
* CustomerQuery
*/
class CustomerQuery extends ActiveQuery
{
public static function activeOnly($query)
{
$query->andWhere(['status' => 2]);
}
}
\ No newline at end of file
<?php
namespace yiiunit\data\ar\sphinx;
use yii\db\ActiveRelation;
use yii\sphinx\ActiveQuery;
class ArticleIndex extends ActiveRecord
{
......@@ -13,11 +12,6 @@ class ArticleIndex extends ActiveRecord
return 'yii2_test_article_index';
}
public static function favoriteAuthor($query)
{
$query->andWhere('author_id=1');
}
public function getSource()
{
return $this->hasOne(ArticleDb::className(), ['id' => 'id']);
......@@ -32,4 +26,9 @@ class ArticleIndex extends ActiveRecord
{
return $this->source->content;
}
public static function createQuery()
{
return new ArticleIndexQuery(['modelClass' => get_called_class()]);
}
}
\ No newline at end of file
<?php
namespace yiiunit\data\ar\sphinx;
use yii\sphinx\ActiveQuery;
/**
* ArticleIndexQuery
*/
class ArticleIndexQuery extends ActiveQuery
{
public static function favoriteAuthor($query)
{
$query->andWhere('author_id=1');
}
}
\ 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