diff --git a/core/modules/file/src/Tests/FileManagedFileElementTest.php b/core/modules/file/src/Tests/FileManagedFileElementTest.php index 61c00de..0de2ded 100644 --- a/core/modules/file/src/Tests/FileManagedFileElementTest.php +++ b/core/modules/file/src/Tests/FileManagedFileElementTest.php @@ -6,6 +6,7 @@ */ namespace Drupal\file\Tests; +use Drupal\Component\Utility\Bytes; use Drupal\Component\Utility\SafeMarkup; use Drupal\file\Entity\File; @@ -110,12 +111,11 @@ function testManagedFile() { $this->assertRaw(t('The file ids are %fids.', array('%fids' => '')), 'Submission after file upload and removal was successful.'); // Upload a file which exceeds the configured post_max_size limit. - $post_max_size_init = ini_get('post_max_size'); - if ($post_max_size_init) { - // Parse the upload size in order to produce a file bigger as it. - $regex = '/^([0-9]+)([bkmgtpezy])$/i'; - preg_match($regex, $post_max_size_init, $match); - $post_max_size = round($match[1] * pow(1024, stripos('bkmgtpezy', strtolower($match[2])))); + $post_max_size_ini = ini_get('post_max_size'); + if ($post_max_size_ini) { + $this->assertTrue(FALSE, ini_get('post_max_size')); + $this->assertTrue(FALSE, ini_get('upload_max_filesize')); + $post_max_size = Bytes::toInt($post_max_size_ini); $big_test_data = str_repeat('a', $post_max_size * 1.1); file_put_contents('public://test.dat', $big_test_data);