Skip to content

Commit

Permalink
switch to use UTC.
Browse files Browse the repository at this point in the history
update test cases.
  • Loading branch information
vistart committed Mar 24, 2017
1 parent 6b81243 commit d57cf35
Show file tree
Hide file tree
Showing 65 changed files with 480 additions and 318 deletions.
1 change: 1 addition & 0 deletions tests/TestCase.php
Expand Up @@ -82,6 +82,7 @@ protected function mockWebApplication($config = [], $appClass = '\yii\web\Applic
'id' => 'testapp',
'basePath' => __DIR__,
'vendorPath' => dirname(__DIR__) . '/vendor',
'timeZone' => 'Asia/Shanghai',
'components' => [
'request' => [
'cookieValidationKey' => 'wefJDF8sfdsfSDefwqdxj9oq',
Expand Down
9 changes: 5 additions & 4 deletions tests/data/ar/AdditionalAccount.php
Expand Up @@ -13,23 +13,24 @@
namespace rhosocial\base\models\tests\data\ar;

/**
* @version 1.0
* @author vistart <i@vistart.me>
*/
class AdditionalAccount extends \rhosocial\base\models\models\BaseAdditionalAccountModel
{
public $seperateLoginAttribute = 'seperate_login';

public function __construct($config = array())
{
$this->hostClass = User::class;
parent::__construct($config);
}

public static function tableName()
{
return '{{%user_additional_account}}';
}

/**
*
* @return \rhosocial\base\models\queries\BaseUserQuery
Expand Down Expand Up @@ -59,4 +60,4 @@ public function attributeLabels()
'updated_at' => Yii::t('app', 'Updated At'),
];
}
}
}
9 changes: 5 additions & 4 deletions tests/data/ar/BaseMessage.php
Expand Up @@ -16,6 +16,7 @@
use rhosocial\base\models\queries\BaseMongoBlameableQuery;

/**
* @version 1.0
* @author vistart <i@vistart.me>
*/
class MongoMessage extends BaseMongoMessageModel
Expand All @@ -25,17 +26,17 @@ public function init()
$this->expiredRemovingCallback = [$this, 'removeExpired'];
parent::init();
}

public static function removeExpired($model)
{
return $model->delete();
}

public static function collectionName()
{
return ['yii2-base-models', 'message'];
}

/**
* Friendly to IDE.
* @return BaseMongoBlameableQuery
Expand All @@ -44,4 +45,4 @@ public static function find()
{
return parent::find();
}
}
}
6 changes: 5 additions & 1 deletion tests/data/ar/Entity.php
Expand Up @@ -14,10 +14,14 @@

use rhosocial\base\models\models\BaseEntityModel;

/**
* @version 1.0
* @author vistart <i@vistart.me>
*/
class Entity extends BaseEntityModel
{
public static function tableName()
{
return '{{%entity}}';
}
}
}
2 changes: 1 addition & 1 deletion tests/data/ar/EntityAI.php
Expand Up @@ -24,4 +24,4 @@ public static function tableName()
{
return '{{%entity_ai}}';
}
}
}
6 changes: 3 additions & 3 deletions tests/data/ar/EntityUtc.php → tests/data/ar/EntityLocal.php
Expand Up @@ -16,7 +16,7 @@
* @version 1.0
* @author vistart <i@vistart.me>
*/
class EntityUtc extends Entity
class EntityLocal extends Entity
{
public $timeType = 0;
}
public $timeType = 1;
}
10 changes: 7 additions & 3 deletions tests/data/ar/ExpiredCallbackEntity.php
Expand Up @@ -14,6 +14,10 @@

use yii\base\ModelEvent;

/**
* @version 1.0
* @author vistart <i@vistart.me>
*/
class ExpiredCallbackEntity extends ExpiredEntity
{
public function init()
Expand All @@ -22,17 +26,17 @@ public function init()
$this->on(static::$eventExpiredRemoved, [$this, 'checkInitDatetime']);
parent::init();
}

public function checkInitDatetime($event)
{
$sender = $event->sender;
/* @var $sender static */
return $sender->isInitDatetime($sender->getCreatedAt());
}

public function removingCallback($model)
{
/* @var $sender ExpiredEntity */
return $model->getInitDatetime(new ModelEvent(['sender' => $model]));
}
}
}
6 changes: 5 additions & 1 deletion tests/data/ar/ExpiredEntity.php
Expand Up @@ -12,7 +12,11 @@

namespace rhosocial\base\models\tests\data\ar;

/**
* @version 1.0
* @author vistart <i@vistart.me>
*/
class ExpiredEntity extends Entity
{
public $expiredAfterAttribute = 'expired_after';
}
}
3 changes: 2 additions & 1 deletion tests/data/ar/ExpiredUser.php
Expand Up @@ -13,9 +13,10 @@
namespace rhosocial\base\models\tests\data\ar;

/**
* @version 1.0
* @author vistart <i@vistart.me>
*/
class ExpiredUser extends User
{
public $expiredAfterAttribute = 'expired_after';
}
}
3 changes: 2 additions & 1 deletion tests/data/ar/GUIDRedisEntity.php
Expand Up @@ -13,9 +13,10 @@
namespace rhosocial\base\models\tests\data\ar;

/**
* @version 1.0
* @author vistart <i@vistart.me>
*/
class GUIDRedisEntity extends RedisEntity
{
public $guidAttribute = 'guid';
}
}
7 changes: 4 additions & 3 deletions tests/data/ar/MongoBlameable.php
Expand Up @@ -15,19 +15,20 @@
use rhosocial\base\models\models\BaseMongoBlameableModel;

/**
* @version 1.0
* @author vistart <i@vistart.me>
*/
class MongoBlameable extends BaseMongoBlameableModel
{
public static function collectionName() {
return ['yii2-base-models', 'blameable'];
}

public function init() {
$this->hostClass = User::class;
parent::init();
}

/**
*
* @return \rhosocial\base\models\queries\BaseMongoBlameableQuery;
Expand All @@ -36,4 +37,4 @@ public static function find()
{
return parent::find();
}
}
}
7 changes: 3 additions & 4 deletions tests/data/ar/MongoEntity.php
Expand Up @@ -16,7 +16,6 @@
use rhosocial\base\models\queries\BaseMongoEntityQuery;

/**
*
* @version 1.0
* @author vistart <i@vistart.me>
*/
Expand All @@ -28,11 +27,11 @@ class MongoEntity extends BaseMongoEntityModel
public static function collectionName() {
return ['yii2-base-models', 'entity'];
}

public static function primaryKey() {
return [static::buildNoInitModel()->guidAttribute];
}

/**
*
* @return BaseMongoEntityQuery
Expand All @@ -41,4 +40,4 @@ public static function find()
{
return parent::find();
}
}
}
9 changes: 5 additions & 4 deletions tests/data/ar/RedisBlameable.php
Expand Up @@ -13,23 +13,24 @@
namespace rhosocial\base\models\tests\data\ar;

/**
* @version 1.0
* @author vistart <i@vistart.me>
*/
class RedisBlameable extends \rhosocial\base\models\models\BaseRedisBlameableModel
{
public $guidAttribute = false;
public $idAttribute = 'alpha2';

public function init() {
$this->hostClass = User::class;
parent::init();
}

public static function primaryKey()
{
return ['alpha2'];
}

/**
* Friendly to IDE.
* @return \rhosocial\base\models\queries\BaseRedisBlameableQuery
Expand All @@ -38,4 +39,4 @@ public static function find()
{
return parent::find();
}
}
}
5 changes: 3 additions & 2 deletions tests/data/ar/RedisEntity.php
Expand Up @@ -15,15 +15,16 @@
use rhosocial\base\models\models\BaseRedisEntityModel;

/**
* @version 1.0
* @author vistart <i@vistart.me>
*/
class RedisEntity extends BaseRedisEntityModel
{
public $guidAttribute = false;
public $idAttribute = 'alpha2';

public function attributes()
{
return array_merge(parent::attributes(), ['content']);
}
}
}
6 changes: 5 additions & 1 deletion tests/data/ar/RedisMeta.php
Expand Up @@ -12,7 +12,11 @@

namespace rhosocial\base\models\tests\data\ar;

/**
* @version 1.0
* @author vistart <i@vistart.me>
*/
class RedisMeta extends \rhosocial\base\models\models\BaseRedisMetaModel
{

}
}
16 changes: 8 additions & 8 deletions tests/data/ar/User.php
Expand Up @@ -24,19 +24,19 @@
* @author vistart <i@vistart.me>
* @since 1.0
*/
class User extends \rhosocial\base\models\models\BaseUserModel {
class User extends \rhosocial\base\models\models\BaseUserModel
{
public $idAttributePrefix = '4';
public $idAttributeType = 1;
public $idAttributeLength = 8;

/**
* @inheritdoc
*/
public static function tableName() {
return '{{%user}}';
}

/**
* @inheritdoc
*/
Expand All @@ -56,21 +56,21 @@ public function attributeLabels() {
'source' => Yii::t('app', 'Source'),
];
}

/**
* @return BaseBlameableQuery
*/
public function getEmails() {
return $this->hasMany(UserEmail::class, ['user_guid' => 'guid'])->inverseOf('user');
}

/**
* @return BaseBlameableQuery
*/
public function getAdditionalAccounts() {
return $this->hasMany(AdditionalAccount::class, ['user_guid' => 'guid'])->inverseOf('user');
}

/**
* Friendly to IDE.
* @return BaseUserQuery
Expand All @@ -79,4 +79,4 @@ public static function find()
{
return parent::find();
}
}
}
6 changes: 3 additions & 3 deletions tests/data/ar/UserComment.php
Expand Up @@ -25,15 +25,15 @@
class UserComment extends \rhosocial\base\models\models\BaseBlameableModel
{
public $parentAttribute = 'parent_guid';

/**
* @inheritdoc
*/
public static function tableName()
{
return '{{%user_comment}}';
}

public function init()
{
$this->userClass = User::class;
Expand All @@ -60,7 +60,7 @@ public function attributeLabels()
'confirm_code' => Yii::t('app', 'Confirm Code'),
];
}

/**
* Friendly to IDE.
* @return \rhosocial\base\models\queries\BaseBlameableQuery
Expand Down

0 comments on commit d57cf35

Please sign in to comment.