コード例 #1
0
 public function testDefault()
 {
     $model = new TestModel();
     $model->fieldArray = '[{}]';
     $model->trigger(ActiveRecord::EVENT_AFTER_FIND);
     $this->assertContainsOnlyInstancesOf(JsonTest::className(), $model->fieldArray);
     $this->assertEquals('default test', $model->fieldArray[0]->hello);
 }
コード例 #2
0
 public function behaviors()
 {
     return ['field' => ['class' => JsonObjectBehavior::className(), 'attribute' => 'field', 'objectClass' => JsonTest::className(), 'init' => true], 'fields' => ['class' => JsonObjectBehavior::className(), 'attribute' => 'fieldArray', 'array' => true, 'init' => true, 'default' => ['class' => JsonTest::className(), 'hello' => 'default test']]];
 }