Closed samsonasik closed 2 years ago
upgraded laminas-form to 3.1 as laminas-form 3.1 that support php 8.1
PHPUnit seems got error:
Running ./vendor/bin/phpunit
PHPUnit 9.5.10 by Sebastian Bergmann and contributors.
Warning: Your XML configuration validates against a deprecated schema.
Suggestion: Migrate your XML configuration using "--migrate-configuration"!
..........Call to a member function getStorage() on null
The issue seems on laminas-session, even use latest laminas-session
2.12.0
Got full stack trace when downgrade to phpunit 9.3.0
Fatal error: Uncaught Error: Call to a member function getStorage() on null in /Users/samsonasik/www/oss-contribute/laminas-mvc-plugin-fileprg/vendor/laminas/laminas-session/src/AbstractContainer.php:172
Stack trace:
#0 /Users/samsonasik/www/oss-contribute/laminas-mvc-plugin-fileprg/vendor/laminas/laminas-session/src/AbstractContainer.php(199): Laminas\Session\AbstractContainer->getStorage()
#1 /Users/samsonasik/www/oss-contribute/laminas-mvc-plugin-fileprg/vendor/laminas/laminas-session/src/AbstractContainer.php(480): Laminas\Session\AbstractContainer->verifyNamespace()
#2 /Users/samsonasik/www/oss-contribute/laminas-mvc-plugin-fileprg/vendor/laminas/laminas-stdlib/src/ArrayObject.php(480): Laminas\Session\AbstractContainer->exchangeArray(Array)
#3 [internal function]: Laminas\Stdlib\ArrayObject->__unserialize(Array)
#4 /Users/samsonasik/www/oss-contribute/laminas-mvc-plugin-fileprg/vendor/phpunit/phpunit/src/Util/PHP/AbstractPhpProcess.php(288): unserialize('a:4:{s:10:"test...')
#5 /Users/samsonasik/www/oss-contribute/laminas-mvc-plugin-fileprg/vendor/phpunit/phpunit/src/Util/PHP/AbstractPhpProcess.php(187): PHPUnit\Util\PHP\AbstractPhpProcess->processChildResult(Object(LaminasTest\Mvc\Plugin\FilePrg\FilePrgDataMergingTest), Object(PHPUnit\Framework\TestResult), 'a:4:{s:10:"test...', '')
#6 /Users/samsonasik/www/oss-contribute/laminas-mvc-plugin-fileprg/vendor/phpunit/phpunit/src/Framework/TestCase.php(878): PHPUnit\Util\PHP\AbstractPhpProcess->runTestJob('<?php\nuse PHPUn...', Object(LaminasTest\Mvc\Plugin\FilePrg\FilePrgDataMergingTest), Object(PHPUnit\Framework\TestResult))
#7 /Users/samsonasik/www/oss-contribute/laminas-mvc-plugin-fileprg/vendor/phpunit/phpunit/src/Framework/TestSuite.php(665): PHPUnit\Framework\TestCase->run(Object(PHPUnit\Framework\TestResult))
#8 /Users/samsonasik/www/oss-contribute/laminas-mvc-plugin-fileprg/vendor/phpunit/phpunit/src/Framework/TestSuite.php(665): PHPUnit\Framework\TestSuite->run(Object(PHPUnit\Framework\TestResult))
#9 /Users/samsonasik/www/oss-contribute/laminas-mvc-plugin-fileprg/vendor/phpunit/phpunit/src/Framework/TestSuite.php(665): PHPUnit\Framework\TestSuite->run(Object(PHPUnit\Framework\TestResult))
#10 /Users/samsonasik/www/oss-contribute/laminas-mvc-plugin-fileprg/vendor/phpunit/phpunit/src/TextUI/TestRunner.php(671): PHPUnit\Framework\TestSuite->run(Object(PHPUnit\Framework\TestResult))
#11 /Users/samsonasik/www/oss-contribute/laminas-mvc-plugin-fileprg/vendor/phpunit/phpunit/src/TextUI/Command.php(148): PHPUnit\TextUI\TestRunner->run(Object(PHPUnit\Framework\TestSuite), Array, Array, true)
#12 /Users/samsonasik/www/oss-contribute/laminas-mvc-plugin-fileprg/vendor/phpunit/phpunit/src/TextUI/Command.php(101): PHPUnit\TextUI\Command->run(Array, true)
#13 /Users/samsonasik/www/oss-contribute/laminas-mvc-plugin-fileprg/vendor/phpunit/phpunit/phpunit(61): PHPUnit\TextUI\Command::main()
#14 {main}
Next PHPUnit\TextUI\Exception: Call to a member function getStorage() on null in /Users/samsonasik/www/oss-contribute/laminas-mvc-plugin-fileprg/vendor/phpunit/phpunit/src/TextUI/Command.php:103
Stack trace:
#0 /Users/samsonasik/www/oss-contribute/laminas-mvc-plugin-fileprg/vendor/phpunit/phpunit/phpunit(61): PHPUnit\TextUI\Command::main()
#1 {main}
thrown in /Users/samsonasik/www/oss-contribute/laminas-mvc-plugin-fileprg/vendor/phpunit/phpunit/src/TextUI/Command.php on line 103
I created PR https://github.com/laminas/laminas-session/pull/47 for it, but even with PR https://github.com/laminas/laminas-session/pull/47, it still got another error:
1) LaminasTest\Mvc\Plugin\FilePrg\FilePrgDataMergingTest::testCorrectInputDataMerging
Failed asserting that two arrays are equal.
--- Expected
+++ Actual
@@ @@
'name' => 'test.jpg'
'type' => 'image/jpeg'
'size' => 20480
- 'tmp_name' => '/Users/samsonasik/www/oss-contribute/laminas-mvc-plugin-fileprg/test/TestAsset/testfile.jpg'
+ 'tmp_name' => '/Users/samsonasik/www/oss-contribute/laminas-mvc-plugin-fileprg/test/TestAsset/nullfile_copy'
I did a git bisect, and literally your very first commit introduces the problem, which tells me it's a dependency issue.
My guess is that there's some subtle behavior change in one or more of the following:
I'm going to try locking those to earlier versions to see which one is the issue.
Problem was introduced with laminas-validator 2.14.5.
The diff between 2.14.4 and 2.14.5 is ENORMOUS, which doesn't make sense considering the small number of actual PRs. But it's definitely a regression in that library causing the error.
If I have a chance to look into it tomorrow, I will.
Error indicates unserialization of session object from main test process in child test process. I would guess laminas-session is initialized in parent process in a different test, then $_SESSION
superglobal is serialized to be sent to child process where it fails to unserialize.
What could work:
Error indicates unserialization of session object from main test process in child test process. I would guess laminas-session is initialized in parent process in a different test, then
$_SESSION
superglobal is serialized to be sent to child process where it fails to unserialize.
That doesn't make sense with my findings. As I noted above, the error occurs with laminas-validator versions > 2.14.4; it has nothing to do with superglobal state between tests.
After some sleuthing with @Xerkus, we discovered that the tests in question were using the fact that we were NOT importing global functions in the Laminas\Filter\File\RenameUpload
and Laminas\Validator\File\UploadFile
class files. This allowed us to mock Laminas\Filter\File\move_uploaded_file()
and Laminas\Validator\File\is_uploaded_file()
during testing. By bumping the minimum supported versions of these libraries, however, we bumped to versions that DO import global functions, thus breaking tests here.
To re-enable this behavior, I've added a test bootstrap that copies those class files from the vendor directory, comments out the relevant global function imports, and adds a development autoloading rule to use the local polyfills.
Thanks @weierophinney!
Description
Fixes https://github.com/laminas/laminas-mvc-plugin-fileprg/issues/16