mirror of
https://github.com/yiisoft/yii2.git
synced 2026-03-19 05:37:54 +01:00
Prevent source path disclosure when form is represented by an anonymous class
This commit is contained in:
@@ -474,6 +474,21 @@ class ModelTest extends TestCase
|
||||
$this->assertTrue($model->validate('name'), 'Should validate only name attribute');
|
||||
$this->assertFalse($model->validate(), 'Should validate all attributes');
|
||||
}
|
||||
|
||||
public function testFormNameWithAnonymousClass()
|
||||
{
|
||||
if (PHP_VERSION_ID < 70000) {
|
||||
$this->markTestSkipped('Can not be tested on PHP < 7.0');
|
||||
return;
|
||||
}
|
||||
|
||||
$model = include 'stub/AnonymousModelClass.php';
|
||||
|
||||
$this->expectException('yii\base\InvalidConfigException');
|
||||
$this->expectExceptionMessage('The "formName()" method should be explicitly defined for anonymous models');
|
||||
|
||||
$model->formName();
|
||||
}
|
||||
}
|
||||
|
||||
class ComplexModel1 extends Model
|
||||
|
||||
Reference in New Issue
Block a user