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