Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

phpunit don't work (fatal error) on PHP 7.0.0 #373

Closed
takekoshinet opened this issue Jan 18, 2017 · 7 comments
Closed

phpunit don't work (fatal error) on PHP 7.0.0 #373

takekoshinet opened this issue Jan 18, 2017 · 7 comments

Comments

@takekoshinet
Copy link
Contributor

Due to recent changes, phpunit don't work (fatal error) on PHP 7.0.0.
On 7.0.14, it works.

I can't find differences between both of them, but root cause is that test-code eats application namespace.
/tests/_support/Services.php's namespace is \CodeIgniter\Services. This namespace is too rich for test-code.

It is avoidable by using PHP latest version, but probably it will appear on latest version someday.
I will use 7.0.14 for a while. Now I want to make queue.
FYI.

$ phpenv local 7.0.14

$ phpunit

==== Redirecting to composer installed version in vendor/phpunit ====

PHPUnit 5.3.5 by Sebastian Bergmann and contributors.

.............................................................   61 / 1213 (  5%)
.............................................................  122 / 1213 ( 10%)
.............................................................  183 / 1213 ( 15%)
.............................................................  244 / 1213 ( 20%)
.............................................................  305 / 1213 ( 25%)
.............................................................  366 / 1213 ( 30%)
.............................................................  427 / 1213 ( 35%)
.............................................................  488 / 1213 ( 40%)
.............................................................  549 / 1213 ( 45%)
.............................................................  610 / 1213 ( 50%)
.............................................................  671 / 1213 ( 55%)
.............................................................  732 / 1213 ( 60%)
.............................................................  793 / 1213 ( 65%)
.............................................................  854 / 1213 ( 70%)
.............................................................  915 / 1213 ( 75%)
.............................................................  976 / 1213 ( 80%)
............................................................. 1037 / 1213 ( 85%)
............................................................. 1098 / 1213 ( 90%)
............................................................. 1159 / 1213 ( 95%)
......................................................        1213 / 1213 (100%)

Time: 1.26 minutes, Memory: 44.00MB

OK (1213 tests, 1925 assertions)

Generating code coverage report in Clover XML format ... done
$ phpenv local 7.0.0

$ phpunit

==== Redirecting to composer installed version in vendor/phpunit ====


$ tail -n12 /var/log/php_errors.7.0.0.log 
PHP Fatal error:  Cannot use Config\Services as Services because the name is already in use in /path/to/project/system/CodeIgniter.php on line 4
PHP Stack trace:
PHP   1. {main}() /usr/bin/phpunit:0
PHP   2. PHPUnit_TextUI_Command::main() /usr/bin/phpunit:49
PHP   3. PHPUnit_TextUI_Command->run() /path/to/project/vendor/phpunit/phpunit/src/TextUI/Command.php:110
PHP   4. PHPUnit_TextUI_Command->handleArguments() /path/to/project/vendor/phpunit/phpunit/src/TextUI/Command.php:121
PHP   5. PHPUnit_TextUI_Command->handleBootstrap() /path/to/project/vendor/phpunit/phpunit/src/TextUI/Command.php:683
PHP   6. PHPUnit_Util_Fileloader::checkAndLoad() /path/to/project/vendor/phpunit/phpunit/src/TextUI/Command.php:854
PHP   7. PHPUnit_Util_Fileloader::load() /path/to/project/vendor/phpunit/phpunit/src/Util/Fileloader.php:38
PHP   8. include_once() /path/to/project/vendor/phpunit/phpunit/src/Util/Fileloader.php:56
PHP   9. spl_autoload_call() /path/to/project/tests/_support/_bootstrap.php:95
PHP  10. CodeIgniter\Autoloader\Autoloader->CodeIgniter\Autoloader\{closure}() /path/to/project/tests/_support/_bootstrap.php:95
@takekoshinet
Copy link
Contributor Author

@Llbe
Copy link

Llbe commented Jan 18, 2017

Those bugs were fixed in 7.0.13.

@takekoshinet
Copy link
Contributor Author

so there are 2 point of view.

  • CI4 requires "7.0 or newer". Maybe it should be changed to "7.1 or newer".
  • Should \CodeIgniter\Services or like namespace be used for test-case code?

@lonnieezell
Copy link
Member

Definitely not shooting for 7.1 minimum. I think it will be too long before enough hosting providers start supporting 7.1 to use that for now.

I'm pretty sure this was working quite a bit prior to 7.0.13, though. It's entirely possible I messed something up a little bit during some refactoring of the bootstrap process last week.

@kenjis
Copy link
Member

kenjis commented Jan 19, 2017

@lonnieezell

Is this the same problem?

$ php ci.php
PHP Fatal error:  Cannot use Config\Services as Services because the name is already in use in /.../CodeIgniter4/system/CodeIgniter.php on line 4

PHP 7.0.5

@lonnieezell
Copy link
Member

@kenjis Yes, that's the one.

@takekoshinet
Copy link
Contributor Author

Definitely not shooting for 7.1 minimum. I think it will be too long before enough hosting providers start supporting 7.1 to use that for now.

I understand. That's right.

It's a bit difficult to fix root problem... There is a little different between phpunit and php ci.php.

$ vi system/CodeIgniter.php

<?php namespace CodeIgniter;
var_dump((new \ReflectionClass(new Services))->getFileName());die;
use Config\Cache;
//use Config\Services;

This code print the filepath declares Services class.

$ php -v
PHP 7.0.12 (cli) (built: Jan 18 2017 23:56:04) ( NTS )
Copyright (c) 1997-2016 The PHP Group
Zend Engine v3.0.0, Copyright (c) 1998-2016 Zend Technologies
    with Zend OPcache v7.0.12, Copyright (c) 1999-2016, by Zend Technologies
    with Xdebug v2.5.0, Copyright (c) 2002-2016, by Derick Rethans

$ phpunit

==== Redirecting to composer installed version in vendor/phpunit ====

/path/to/project/system/CodeIgniter.php:2:
string(78) "/path/to/project/tests/_support/Services.php"

$ php ci.php 
/path/to/project/system/CodeIgniter.php:2:
string(82) "/path/to/project/application/Config/Services.php"

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants