2016-01-21 02:44:29 +05:30
|
|
|
<?php
|
2019-02-21 01:28:52 +05:30
|
|
|
namespace api\tests\_support\models\base;
|
2016-01-21 02:44:29 +05:30
|
|
|
|
2016-03-20 05:03:49 +05:30
|
|
|
use api\models\base\ApiForm;
|
2019-02-21 01:28:52 +05:30
|
|
|
use api\tests\unit\TestCase;
|
2016-01-21 02:44:29 +05:30
|
|
|
|
2016-03-20 05:03:49 +05:30
|
|
|
class ApiFormTest extends TestCase {
|
|
|
|
|
2016-01-21 02:44:29 +05:30
|
|
|
public function testLoad() {
|
2016-03-20 05:03:49 +05:30
|
|
|
$model = new DummyApiForm();
|
2016-10-29 03:17:31 +05:30
|
|
|
$this->assertTrue($model->load(['field' => 'test-data']), 'model successful load data without prefix');
|
2019-02-26 04:56:02 +05:30
|
|
|
$this->assertSame('test-data', $model->field, 'field is set as passed data');
|
2016-01-21 02:44:29 +05:30
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
|
2016-03-20 05:03:49 +05:30
|
|
|
class DummyApiForm extends ApiForm {
|
2016-01-21 02:44:29 +05:30
|
|
|
|
|
|
|
public $field;
|
|
|
|
|
|
|
|
public function rules() {
|
|
|
|
return [
|
|
|
|
['field', 'safe'],
|
|
|
|
];
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|