Use ::class instead of ::className() in tests. (#20612)

This commit is contained in:
Wilmer Arambula
2025-10-14 13:26:35 -03:00
committed by GitHub
parent 4c3deb055b
commit c960f93dfe
89 changed files with 528 additions and 528 deletions

View File

@ -50,9 +50,9 @@ class ValidatorTest extends TestCase
$model = FakedValidationModel::createWithAttributes(['attr_test1' => 'abc', 'attr_test2' => '2013']);
/** @var NumberValidator $numberVal */
$numberVal = TestValidator::createValidator('number', $model, ['attr_test1']);
$this->assertInstanceOf(NumberValidator::className(), $numberVal);
$this->assertInstanceOf(NumberValidator::class, $numberVal);
$numberVal = TestValidator::createValidator('integer', $model, ['attr_test2']);
$this->assertInstanceOf(NumberValidator::className(), $numberVal);
$this->assertInstanceOf(NumberValidator::class, $numberVal);
$this->assertTrue($numberVal->integerOnly);
$val = TestValidator::createValidator(
'boolean',
@ -60,7 +60,7 @@ class ValidatorTest extends TestCase
['attr_test1', 'attr_test2'],
['on' => ['a', 'b']]
);
$this->assertInstanceOf(BooleanValidator::className(), $val);
$this->assertInstanceOf(BooleanValidator::class, $val);
$this->assertSame(['a', 'b'], $val->on);
$this->assertSame(['attr_test1', 'attr_test2'], $val->attributes);
$val = TestValidator::createValidator(
@ -69,11 +69,11 @@ class ValidatorTest extends TestCase
['attr_test1', 'attr_test2'],
['on' => ['a', 'b'], 'except' => ['c', 'd', 'e']]
);
$this->assertInstanceOf(BooleanValidator::className(), $val);
$this->assertInstanceOf(BooleanValidator::class, $val);
$this->assertSame(['a', 'b'], $val->on);
$this->assertSame(['c', 'd', 'e'], $val->except);
$val = TestValidator::createValidator('inlineVal', $model, ['val_attr_a'], ['params' => ['foo' => 'bar']]);
$this->assertInstanceOf(InlineValidator::className(), $val);
$this->assertInstanceOf(InlineValidator::class, $val);
$this->assertSame('inlineVal', $val->method[1]);
$this->assertSame(['foo' => 'bar'], $val->params);
}
@ -87,7 +87,7 @@ class ValidatorTest extends TestCase
$validator = TestValidator::createValidator('required', $model, ['firstAttribute']);
$this->assertInstanceOf(RequiredValidator::className(), $validator);
$this->assertInstanceOf(RequiredValidator::class, $validator);
}
public function testValidateAttributes(): void
@ -196,7 +196,7 @@ class ValidatorTest extends TestCase
public function testValidateValue(): void
{
$this->expectException('yii\base\NotSupportedException');
$this->expectExceptionMessage(TestValidator::className() . ' does not support validateValue().');
$this->expectExceptionMessage(TestValidator::class . ' does not support validateValue().');
$val = new TestValidator();
$val->validate('abc');
}
@ -215,7 +215,7 @@ class ValidatorTest extends TestCase
$this->assertEquals('val_attr_a', $args[0]);
$this->assertEquals('a', $args[3]);
$this->assertEquals(['foo' => 'bar'], $args[1]);
$this->assertInstanceOf(InlineValidator::className(), $args[2]);
$this->assertInstanceOf(InlineValidator::class, $args[2]);
}
public function testClientValidateAttribute(): void
@ -236,7 +236,7 @@ class ValidatorTest extends TestCase
$this->assertCount(5, $args);
$this->assertEquals('val_attr_a', $args[0]);
$this->assertEquals(['foo' => 'bar'], $args[1]);
$this->assertInstanceOf(InlineValidator::className(), $args[2]);
$this->assertInstanceOf(InlineValidator::class, $args[2]);
}
public function testIsActive(): void
@ -322,7 +322,7 @@ class ValidatorTest extends TestCase
{
$model = new DynamicModel();
$model->defineAttribute(1);
$model->addRule([1], SafeValidator::className());
$model->addRule([1], SafeValidator::class);
$this->assertNull($model->{1});
$this->assertTrue($model->validate([1]));