test: Separate FormHelperTest::testSecuredFileInput() by PHP Version.

Added 'full_path' key
https://www.php.net/manual/en/migration81.new-features.php#migration81.new-features.core.upload-full-path-key
This commit is contained in:
Koji Tanaka 2023-02-09 23:59:44 +09:00 committed by Kamil Wylegala
parent 9115ec765f
commit 7df7fefca4

View file

@ -1699,11 +1699,13 @@ class FormHelperTest extends CakeTestCase {
}
/**
* Tests that the correct keys are added to the field hash index
* Tests that the correct keys are added to the field hash index (For PHP < 8.1)
*
* @return void
*/
public function testSecuredFileInput() {
$this->skipIf(version_compare(PHP_VERSION, '8.1.0', '>='));
$this->Form->request['_Token'] = array('key' => 'testKey');
$this->assertEquals(array(), $this->Form->fields);
@ -1715,6 +1717,28 @@ class FormHelperTest extends CakeTestCase {
$this->assertEquals($expected, $this->Form->fields);
}
/**
* Tests that the correct keys are added to the field hash index (For PHP >= 8.1)
*
* Added full_path key
*
* @see https://www.php.net/manual/en/migration81.new-features.php#migration81.new-features.core.upload-full-path-key
* @return void
*/
public function testSecuredFileInputForPhp81Plus() {
$this->skipIf(version_compare(PHP_VERSION, '8.1.0', '<'));
$this->Form->request['_Token'] = array('key' => 'testKey');
$this->assertEquals(array(), $this->Form->fields);
$this->Form->file('Attachment.file');
$expected = array(
'Attachment.file.name', 'Attachment.file.type', 'Attachment.file.tmp_name',
'Attachment.file.error', 'Attachment.file.size', 'Attachment.file.full_path'
);
$this->assertEquals($expected, $this->Form->fields);
}
/**
* test that multiple selects keys are added to field hash
*