"Call to a member function setAjax() on null" when testing #12883

Closed
xpdavid opened this Issue Jan 9, 2017 · 16 comments

Projects

None yet

3 participants

@xpdavid
xpdavid commented Jan 9, 2017

Steps to reproduce

  1. Go through the step in TestingEnvironment
  2. Run command ./vendor/bin/phpunit -c phpunit.xml.nocoverage

Expected behaviour

All test cases passed

Actual behaviour

Several test cases are skipped and produce errors.
A Fatal error is caused.
screen shot 2017-01-09 at 11 37 34 pm

I try to search the similar issue and got one #12819 but it doesn't works.

Server configuration

Operating system: Mac OS X EI Capitan

Web server: MAMP PRO 3.4

Database: MYSQL 5.6

PHP version: PHP 5.6.10

phpMyAdmin version: Master Branch up to this commit

Client configuration

Browser: FireFox 46.0

Operating system: Mac OS X EI Capitan

@ibennetch
Contributor
@ibennetch
Contributor
@ibennetch
Contributor
ibennetch commented Jan 9, 2017 edited

Git bisect suggests that b56f10 may be the first bad commit.

@nijel
Member
nijel commented Jan 18, 2017

Can you run it verbosely, so that we know which test is falling?

Or can you add backtrace printing to the failing method?

--- a/libraries/Response.php
+++ b/libraries/Response.php
@@ -113,6 +113,9 @@ class Response
     public function setAjax($isAjax)
     {
         $this->_isAjax = (boolean) $isAjax;
+        if (is_null($this->_header)) {
+            debug_print_backtrace();
+        }
         $this->_header->setAjax($this->_isAjax);
         $this->_footer->setAjax($this->_isAjax);
     }

This is probably caused by some test not properly restoring Response mock. I'd bet on the first failed test.

@nijel nijel added the bug label Jan 18, 2017
@nijel
Member
nijel commented Jan 18, 2017

PS: There might be some improvements in this due to changes done in #12079, so testing with latest version might help as well.

@ibennetch
Contributor

I didn't need to modify libraries/Response.php to get better output (I get the same output with the modifications, by the way). Running in verbose mode doesn't get me any more information. This is not the same message I got last week, though I suppose that doesn't matter anymore.

......................................................SSPHP Fatal error:  Call to a member function query() on null in /var/www/pma-dev/fork/test/selenium/TestBase.php on line 338
PHP Stack trace:
PHP   1. {main}() /usr/bin/phpunit:0
PHP   2. PHPUnit_TextUI_Command::main() /usr/bin/phpunit:42
PHP   3. PHPUnit_TextUI_Command->run() /usr/share/php/PHPUnit/TextUI/Command.php:138
PHP   4. PHPUnit_TextUI_TestRunner->doRun() /usr/share/php/PHPUnit/TextUI/Command.php:186
PHP   5. PHPUnit_Framework_TestSuite->run() /var/www/pma-dev/fork/vendor/phpunit/phpunit/src/TextUI/TestRunner.php:440
PHP   6. PHPUnit_Framework_TestSuite->run() /var/www/pma-dev/fork/vendor/phpunit/phpunit/src/Framework/TestSuite.php:722
PHP   7. PHPUnit_Framework_TestSuite->run() /var/www/pma-dev/fork/vendor/phpunit/phpunit/src/Framework/TestSuite.php:722
PHP   8. PHPUnit_Extensions_Selenium2TestCase->run() /var/www/pma-dev/fork/vendor/phpunit/phpunit/src/Framework/TestSuite.php:722
PHP   9. PHPUnit_Framework_TestCase->run() /var/www/pma-dev/fork/vendor/phpunit/phpunit-selenium/PHPUnit/Extensions/Selenium2TestCase.php:264
PHP  10. PHPUnit_Framework_TestResult->run() /var/www/pma-dev/fork/vendor/phpunit/phpunit/src/Framework/TestCase.php:724
PHP  11. PHPUnit_Framework_TestCase->runBare() /var/www/pma-dev/fork/vendor/phpunit/phpunit/src/Framework/TestResult.php:612
PHP  12. PMA_SeleniumDbEventsTest->tearDown() /var/www/pma-dev/fork/vendor/phpunit/phpunit/src/Framework/TestCase.php:805
PHP  13. PMA_SeleniumBase->dbQuery() /var/www/pma-dev/fork/test/selenium/PmaSeleniumDbEventsTest.php:69
@nijel
Member
nijel commented Jan 20, 2017

Sorry, I've meant running with --debug to see what is the first failed test (which probably fails to restore the environment).

Anyway this is different error than the originally reported one as this one is in Selenium tests, while the previous one was in Response mocking.

Do you get any error if you exclude Selenium tests? These seems to be broken in Travis as well, so it's probably good idea to skip them for now. You can do it using --exclude-group selenium.

@ibennetch
Contributor

Ah, sure:

There was 1 error:

1) SanitizeTest::testRemoveRequestVars
Undefined variable: _POST

/var/www/pma-dev/fork/libraries/Sanitize.php:427
/var/www/pma-dev/fork/test/classes/SanitizeTest.php:283
/usr/share/php/PHPUnit/TextUI/Command.php:186
/usr/share/php/PHPUnit/TextUI/Command.php:138
@nijel nijel added a commit that referenced this issue Jan 20, 2017
@nijel nijel Do not try to unset not set array
Issue #12883

Signed-off-by: Michal Čihař <michal@cihar.com>
1a72482
@nijel
Member
nijel commented Jan 20, 2017

Okay, this one should be fixed now. I'm still curious if the original error was fixed by changes for #12079 or is still happening. @xpdavid can you still reproduce this issue with current master?

@nijel nijel self-assigned this Jan 20, 2017
@nijel nijel added this to the 4.7.0 milestone Jan 20, 2017
@nijel nijel added a commit to nijel/phpmyadmin that referenced this issue Jan 20, 2017
@nijel nijel Run Travis CI tests on OS X as well
Issue #12883

Signed-off-by: Michal Čihař <michal@cihar.com>
e575a27
@nijel nijel referenced this issue Jan 20, 2017
Merged

Run Travis CI tests on OS X as well #12909

4 of 4 tasks complete
@nijel nijel added a commit to nijel/phpmyadmin that referenced this issue Jan 20, 2017
@nijel nijel Run Travis CI tests on OS X as well
Issue #12883

Signed-off-by: Michal Čihař <michal@cihar.com>
2d1186e
@nijel nijel added a commit to nijel/phpmyadmin that referenced this issue Jan 20, 2017
@nijel nijel Run Travis CI tests on OS X as well
Issue #12883

Signed-off-by: Michal Čihař <michal@cihar.com>
7402881
@xpdavid
xpdavid commented Jan 20, 2017 edited

Thanks @nijel The original error was fixed. But there is a new error, same as @ibennetch

...
Starting test 'PMA_SysInfoTest::testGetSysInfo'.
.
Starting test 'PMA_SysInfoTest::testGetSysInfoSupported'.
.
Starting test 'Environment_Test::testPhpVersion'.
.
Starting test 'Environment_Test::testMySQL'.
S
Starting test 'PMA_SeleniumCreateDropDatabaseTest::testCreateDropDatabase'.
S
Starting test 'PMA_SeleniumCreateRemoveUserTest::testCreateRemoveUser'.
S
Starting test 'PMA_SeleniumDbEventsTest::testAddEvent'.
PHP Fatal error:  Call to a member function query() on null in /Users/XP/Documents/phpmyadmin-git/test/selenium/TestBase.php on line 338

Fatal error: Call to a member function query() on null in /Users/XP/Documents/phpmyadmin-git/test/selenium/TestBase.php on line 338
@nijel nijel added a commit that closed this issue Jan 20, 2017
@nijel nijel Do not execute tearDown if not configured
Apparently the tearDown method can be executed for skipped tests in some
cases and it will fail due to failed initilization.

Fixes #12883

Signed-off-by: Michal Čihař <michal@cihar.com>
3d056bc
@nijel nijel closed this in 3d056bc Jan 20, 2017
@nijel
Member
nijel commented Jan 20, 2017

Should be fixed now. In case you see another error, please open separate bug.

PS: I still wonder why this happens on OSX, but not on Linux....

@nijel nijel added a commit to nijel/phpmyadmin that referenced this issue Jan 20, 2017
@nijel nijel Run Travis CI tests on OS X as well
Issue #12883

Signed-off-by: Michal Čihař <michal@cihar.com>
c113fae
@ibennetch
Contributor

Even more strange, I wasn't running the tests on OSX, but on Debian.

@nijel
Member
nijel commented Jan 20, 2017

Okay, then we can probably rule out OSX :-). Maybe it depends on phpunit version then?

@nijel nijel added a commit to nijel/phpmyadmin that referenced this issue Jan 20, 2017
@nijel nijel Run Travis CI tests on OS X as well
Issue #12883

Signed-off-by: Michal Čihař <michal@cihar.com>
012e87b
@nijel nijel added a commit to nijel/phpmyadmin that referenced this issue Jan 20, 2017
@nijel nijel Run Travis CI tests on OS X as well
Issue #12883

Signed-off-by: Michal Čihař <michal@cihar.com>
4297ab6
@nijel nijel added a commit to nijel/phpmyadmin that referenced this issue Jan 20, 2017
@nijel nijel Run Travis CI tests on OS X as well
Issue #12883

Signed-off-by: Michal Čihař <michal@cihar.com>
5946766
@ibennetch
Contributor
ibennetch commented Jan 20, 2017 edited

I'm using PHPUnit 4.2.6, which is rather old but is the Debian distributed version.

@nijel nijel added a commit to nijel/phpmyadmin that referenced this issue Jan 21, 2017
@nijel nijel Run Travis CI tests on OS X as well
Issue #12883

Signed-off-by: Michal Čihař <michal@cihar.com>
d9d0ff4
@nijel nijel added a commit to nijel/phpmyadmin that referenced this issue Jan 21, 2017
@nijel nijel Run Travis CI tests on OS X as well
Issue #12883

Signed-off-by: Michal Čihař <michal@cihar.com>
eafbe2e
@nijel nijel added a commit to nijel/phpmyadmin that referenced this issue Jan 21, 2017
@nijel nijel Run Travis CI tests on OS X as well
- install dependencies using brew
- manuall start MariaDB server

Issue #12883

Signed-off-by: Michal Čihař <michal@cihar.com>
3c3920e
@nijel nijel added a commit to nijel/phpmyadmin that referenced this issue Jan 21, 2017
@nijel nijel Run Travis CI tests on OS X as well
- install dependencies using brew
- manuall start MariaDB server

Issue #12883

Signed-off-by: Michal Čihař <michal@cihar.com>
a64b8ed
@nijel
Member
nijel commented Jan 21, 2017

Okay, handling of tearDown has changed in phpunit 4.3.0 - sebastianbergmann/phpunit@dfe2cf1...

@nijel nijel added a commit to nijel/phpmyadmin that referenced this issue Jan 21, 2017
@nijel nijel Run Travis CI tests on OS X as well
- install dependencies using brew
- manuall start MariaDB server

Issue #12883

Signed-off-by: Michal Čihař <michal@cihar.com>
9ecda41
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment