This Bugzilla instance is a read-only archive of historic NetBeans bug reports. To report a bug in NetBeans please follow the project's instructions for reporting issues.

Bug 270820 - PHPUnit doesn't work for PHP 7.0 and PHPUnit 6.2.1
Summary: PHPUnit doesn't work for PHP 7.0 and PHPUnit 6.2.1
Status: RESOLVED FIXED
Alias: None
Product: php
Classification: Unclassified
Component: PHPUnit (show other bugs)
Version: 8.2
Hardware: All All
: P2 normal (vote)
Assignee: Tomas Mysik
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2017-06-06 19:40 UTC by rweaver
Modified: 2017-06-08 16:31 UTC (History)
2 users (show)

See Also:
Issue Type: DEFECT
Exception Reporter:


Attachments
Screen shot of the PHP interpreter settings. (198.75 KB, image/png)
2017-06-06 19:40 UTC, rweaver
Details

Note You need to log in before you can comment on or make changes to this bug.
Description rweaver 2017-06-06 19:40:35 UTC
Created attachment 164480 [details]
Screen shot of the PHP interpreter settings.

Setting the php version to be 7.0 on the project, but when running tests I get an error that indicates it is using the wrong PHP.

"/usr/local/bin/phpunit" "--colors" "--log-json" "/var/folders/pr/59hffzcn3xn3rl2tv8tr27t00000gn/T/nb-phpunit-log.json" "/Applications/NetBeans/NetBeans 8.2.app/Contents/Resources/NetBeans/php/phpunit/NetBeansSuite.php" "--" "--run=/Users/robweaver/Sites/community-sso/classes/test"
PHPUnit 6.2.1 by Sebastian Bergmann and contributors.

This version of PHPUnit is supported on PHP 7.0 and PHP 7.1.
You are using PHP 5.6.30 (/usr/bin/php).
Done.

PHP 7.0 is installed in /usr/local/bin, which I have set in the NB preferences (see attached screenshot)

Running from command line gives an error about the switch "--log-json


robweaver:classes robweaver$ "/usr/local/bin/phpunit" "--colors" "--log-json" "/var/folders/pr/59hffzcn3xn3rl2tv8tr27t00000gn/T/nb-phpunit-log.json" "/Applications/NetBeans/NetBeans 8.2.app/Contents/Resources/NetBeans/php/phpunit/NetBeansSuite.php" "--" "--run=/Users/robweaver/Sites/community-sso/classes/test"
PHPUnit 6.2.1 by Sebastian Bergmann and contributors.

unrecognized option --log-json
Comment 1 rweaver 2017-06-06 19:44:46 UTC
Looks like --log-json was removed since 5.7

Removed the --log-json commandline option (deprecated in PHPUnit 5.7)

https://github.com/sebastianbergmann/phpunit/blob/master/ChangeLog-6.0.md#removed
Comment 2 rweaver 2017-06-06 19:55:54 UTC
Same problem if I set the tests to use phpunit directly:

"/usr/local/bin/phpunit" "--colors" "--log-json" "/var/folders/pr/59hffzcn3xn3rl2tv8tr27t00000gn/T/nb-phpunit-log.json"
PHPUnit 6.2.1 by Sebastian Bergmann and contributors.

This version of PHPUnit is supported on PHP 7.0 and PHP 7.1.
You are using PHP 5.6.30 (/usr/bin/php).
Done.
Comment 3 rweaver 2017-06-06 20:01:48 UTC
OK, was able to get it past that initial problem by manually editing the phpunit script to use the php in /usr/local/bin, so now the only problem is that phpunit is being called with an unrecognized option:

"/usr/local/bin/phpunit" "--colors" "--log-json" "/var/folders/pr/59hffzcn3xn3rl2tv8tr27t00000gn/T/nb-phpunit-log.json"
PHPUnit 6.2.1 by Sebastian Bergmann and contributors.

unrecognized option --log-json
Done.

running without the --log-json from the command line appears to work fine.\

robweaver:classes robweaver$ phpunit test/src
PHPUnit 6.2.1 by Sebastian Bergmann and contributors.

EEW...FFIIIIIIIWWWWWWWWWEEEEW                                     29 / 29 (100%)

Time: 226 ms, Memory: 8.00MB

There were 6 errors:

1) SSO\login\CommunityTest::testLogin
Missing argument 1 for SSO\login\Login::__construct(), called in /Users/robweaver/Sites/community-sso/classes/test/src/SSO/login/CommunityTest.php on line 22 and defined

/Users/robweaver/Sites/community-sso/classes/src/SSO/login/Login.php:32
/Users/robweaver/Sites/community-sso/classes/test/src/SSO/login/CommunityTest.php:22

2) SSO\login\CommunityTest::testHigherLogicLogin
Missing argument 1 for SSO\login\Login::__construct(), called in /Users/robweaver/Sites/community-sso/classes/test/src/SSO/login/CommunityTest.php on line 22 and defined

/Users/robweaver/Sites/community-sso/classes/src/SSO/login/Login.php:32
/Users/robweaver/Sites/community-sso/classes/test/src/SSO/login/CommunityTest.php:22

3) SSO\login\SignupTest::testGetError
Error: Class 'SSO\login\Signup' not found

/Users/robweaver/Sites/community-sso/classes/test/src/SSO/signup/SignupTest.php:22

4) SSO\login\SignupTest::testLogError
Error: Class 'SSO\login\Signup' not found

/Users/robweaver/Sites/community-sso/classes/test/src/SSO/signup/SignupTest.php:22

5) SSO\login\SignupTest::testAlertError
Error: Class 'SSO\login\Signup' not found

/Users/robweaver/Sites/community-sso/classes/test/src/SSO/signup/SignupTest.php:22

6) SSO\login\SignupTest::testCreateAccount
Error: Class 'SSO\login\Signup' not found

/Users/robweaver/Sites/community-sso/classes/test/src/SSO/signup/SignupTest.php:22

--

There were 11 warnings:

1) Warning
No tests found in class "SSO\login\HelpTest".

2) Warning
No tests found in class "SSO\login\TrainingTest".

3) Warning
No tests found in class "SSO\login\provider\HigherLogicTest".

4) Warning
No tests found in class "SSO\login\provider\HubTest".

5) Warning
No tests found in class "SSO\login\provider\LoginProviderTest".

6) Warning
No tests found in class "SSO\login\provider\OnDemandTest".

7) Warning
No tests found in class "SSO\login\provider\ProofHQTest".

8) Warning
No tests found in class "SSO\login\provider\ZenDeskTest".

9) Warning
No tests found in class "SSO\signup\CommunityTest".

10) Warning
No tests found in class "SSO\signup\HelpTest".

11) Warning
No tests found in class "SSO\signup\TrainingTest".

--

There were 2 failures:

1) SSO\login\LoginTest::testOnDemandLogin
ERROR: Ondemand login results are not valid but should be
Failed asserting that two objects are equal.
--- Expected
+++ Actual
@@ @@
 stdClass Object (
-    'data' => Array (...)
+    'error' => stdClass Object (...)
 )

/Users/robweaver/Sites/community-sso/classes/test/src/SSO/login/LoginTest.php:86

2) SSO\login\LoginTest::testOnDemandLoginBadUser
ERROR: Ondemand login results are should be invalid
Failed asserting that two objects are equal.
--- Expected
+++ Actual
@@ @@
 stdClass Object (
     'error' => stdClass Object (
         'class' => 'com.attask.biz.externallogin....eption'
-        'message' => 'That username password combination wasn't quite right.  Make sure your caps lock isn't on and try again.'
+        'message' => 'Curl call was not performed'
     )
 )

/Users/robweaver/Sites/community-sso/classes/test/src/SSO/login/LoginTest.php:102

ERRORS!
Tests: 29, Assertions: 5, Errors: 6, Failures: 2, Warnings: 11, Incomplete: 7.
robweaver:classes robweaver$
Comment 4 Tomas Mysik 2017-06-07 08:22:56 UTC
Yes, unfortunately you are right :/ However, this issue is already fixed in the dev version of NetBeans [1], we switched back to the XML report (and hope that this one will remain in PHPUnit longer ;)

Thanks for reporting.
Comment 5 rweaver 2017-06-08 03:10:09 UTC
What do you mean by "current version" I'm running the latest NB. Do you mean it's fixed in a newer build than 8.2 ?
Comment 6 junichi11 2017-06-08 03:25:32 UTC
(In reply to rweaver from comment #5)
> What do you mean by "current version" I'm running the latest NB. Do you mean
> it's fixed in a newer build than 8.2 ?

Yes, it means the dev build[1]. (Probably, Tomas just forgot to write the link.)


[1] http://bits.netbeans.org/download/trunk/nightly/latest/
Comment 7 Tomas Mysik 2017-06-08 05:00:15 UTC
Of course I forgot, sorry!
Comment 8 rweaver 2017-06-08 16:31:03 UTC
Thanks !!!