diff --git a/tests/framework/helpers/ArrayHelperTest.php b/tests/framework/helpers/ArrayHelperTest.php index 593d4007be..f450b281f7 100644 --- a/tests/framework/helpers/ArrayHelperTest.php +++ b/tests/framework/helpers/ArrayHelperTest.php @@ -136,12 +136,14 @@ class ArrayHelperTest extends TestCase } /** - * @requires PHP < 8.1 - * * @return void */ public function testRemoveWithFloat() { + if (version_compare(PHP_VERSION, '8.1.0', '>=')) { + $this->markTestSkipped('Using floats as array key is deprecated.'); + } + $array = ['name' => 'b', 'age' => 3, 1.1 => null]; $name = ArrayHelper::remove($array, 'name'); @@ -525,12 +527,14 @@ class ArrayHelperTest extends TestCase } /** - * @requires PHP < 8.1 - * * @see https://github.com/yiisoft/yii2/pull/11549 */ public function testGetValueWithFloatKeys() { + if (version_compare(PHP_VERSION, '8.1.0', '>=')) { + $this->markTestSkipped('Using floats as array key is deprecated.'); + } + $array = []; $array[1.1] = 'some value'; $array[2.1] = null; @@ -750,11 +754,12 @@ class ArrayHelperTest extends TestCase $this->assertFalse(ArrayHelper::keyExists('c', $array, false)); } - /** - * @requires PHP < 8.1 - */ public function testKeyExistsWithFloat() { + if (version_compare(PHP_VERSION, '8.1.0', '>=')) { + $this->markTestSkipped('Using floats as array key is deprecated.'); + } + $array = [ 1 => 3, 2.2 => 4, // Note: Floats are cast to ints, which means that the fractional part will be truncated.