Prevent source path disclosure when form is represented by an anonymous class

This commit is contained in:
SilverFire - Dmitry Naumenko
2017-12-22 12:21:32 +02:00
parent 9e0f19ace7
commit 072ef77ea5
4 changed files with 27 additions and 0 deletions

View File

@@ -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