mirror of
https://github.com/elyby/accounts.git
synced 2025-05-31 14:11:46 +05:30
Рефакторинг common unit тестов
This commit is contained in:
@@ -13,23 +13,19 @@ class DataBehaviorTest extends TestCase {
|
||||
use ProtectedCaller;
|
||||
|
||||
public function testSetKey() {
|
||||
$this->specify('setting value should change model data field', function() {
|
||||
$model = $this->createModel();
|
||||
/** @var DataBehavior $behavior */
|
||||
$behavior = $model->behaviors['dataBehavior'];
|
||||
$this->callProtected($behavior, 'setKey', 'my-key', 'my-value');
|
||||
expect($model->_data)->equals(serialize(['my-key' => 'my-value']));
|
||||
});
|
||||
$model = $this->createModel();
|
||||
/** @var DataBehavior $behavior */
|
||||
$behavior = $model->behaviors['dataBehavior'];
|
||||
$this->callProtected($behavior, 'setKey', 'my-key', 'my-value');
|
||||
$this->assertEquals(serialize(['my-key' => 'my-value']), $model->_data);
|
||||
}
|
||||
|
||||
public function testGetKey() {
|
||||
$this->specify('getting value from exists data should work', function() {
|
||||
$model = $this->createModel();
|
||||
$model->_data = serialize(['some-key' => 'some-value']);
|
||||
/** @var DataBehavior $behavior */
|
||||
$behavior = $model->behaviors['dataBehavior'];
|
||||
expect($this->callProtected($behavior, 'getKey', 'some-key'))->equals('some-value');
|
||||
});
|
||||
$model = $this->createModel();
|
||||
$model->_data = serialize(['some-key' => 'some-value']);
|
||||
/** @var DataBehavior $behavior */
|
||||
$behavior = $model->behaviors['dataBehavior'];
|
||||
$this->assertEquals('some-value', $this->callProtected($behavior, 'getKey', 'some-key'));
|
||||
}
|
||||
|
||||
public function testGetData() {
|
||||
|
@@ -12,12 +12,10 @@ class EmailActivationExpirationBehaviorTest extends TestCase {
|
||||
use ProtectedCaller;
|
||||
|
||||
public function testCalculateTime() {
|
||||
$this->specify('just use create_time and plus passed time', function() {
|
||||
$behavior = $this->createBehavior();
|
||||
$time = time();
|
||||
$behavior->owner->created_at = $time;
|
||||
expect($this->callProtected($behavior, 'calculateTime', 10))->equals($time + 10);
|
||||
});
|
||||
$behavior = $this->createBehavior();
|
||||
$time = time();
|
||||
$behavior->owner->created_at = $time;
|
||||
$this->assertEquals($time + 10, $this->callProtected($behavior, 'calculateTime', 10));
|
||||
}
|
||||
|
||||
public function testCompareTime() {
|
||||
|
Reference in New Issue
Block a user