-
-
Notifications
You must be signed in to change notification settings - Fork 2.3k
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
CTestCase PHPUnit 3.7.10 autoload fails #1907
Comments
Which Yii version have you tried? |
@samdark 1.1.13 but does not matter now, i've discovered that it was my fault, not Yii, i forgot to install some packages, but anyway i found bug on pear installer with |
Actually this is not quite correct and should not be closed. |
@nezaboravi u can find PHP_Invoker package on phpunit.de site, not through pear, and install it manually, works for me. (pear.phpunit.de) |
I had the exact same problem but the solution ended up being pretty simple. Here's how I solved the problem for each file: PHP_Invoker.php I suspect this would have worked:
but instead I did this:
PHPUnit_Extensions_Database_TestCase.php
PHPUnit_Extensions_Story_TestCase.php
|
Just an additional note that: put the "Invoker" directory under C:\xampp\php\pear\PHP Also works for those on OSX using MAMP and do not want to go through the mess of getting pcntl running. Although the directory is different. Usually something along the lines of: $ pear config-get php_dir Then the subdirectory PHP of the output. |
It is a bug in YiiBase::autoload(). Incorrect implementation of autoloader if you want. |
Can you give a bit more details about what you are talking about? Code line and what is wrong exactly? :) |
Existence of the file should be checked before But it triggers a warning. An you should to use And what is it?: return class_exists($className,false) || interface_exists($className,false); If autoloader is asked it means, that class doesn't exist. For example:require_once __DIR__.'/../vendor/yiisoft/yii/framework/YiiBase.php';
class_exists('SomeMissingClass', true);
About problem with PHPUnit:
Look at :
Calling of |
Yes it is a bug, but fix can not be applied because of BC. You need to install all dep. packages to avoid this bug. |
See this PR #2324 |
What can I say. Yii... |
Use symfony, kohana, or even laravel, feel free to choose ;) |
My choise is Symfony 2. But now I work with existing project based on Yii. |
Yii 1.1 was created before there was PSR-0 and namespaces so autoloader was created to rely on include path. This works really nice when following the yii way but causes problems like this with external libraries. This case is special as PHPUnit tries to detect whether extension is loaded by trying to autoload the classes. A workaround for this could be to make a custom autoloader, tell him the classes loaded by PHPUnit that are not installed and return true for them without doing anything else. prepend that autoloader before yii autoloader with the function given above. Sounds a bit hacky but will help you in this special case. |
@cebe, PEAR recommendation has been. |
I solved it installing the following packages: pear install phpunit/PHPUnit
pear install phpunit/PHPUnit_Selenium
pear install phpunit/PHP_Invoker
pear install phpunit/PHPUnit_Story
pear install phpunit/DbUnit |
yes, that because phpunit uses them internally and when calling |
It is not phpunit bug. It is Yii bug. Yii brakes |
@Sharom please investigate phpunit code, and stop posting this bullshit, thanks. |
Calm down boys, yii autoloader is not perfect and PHPUnits usage of class_exists() is also not nice, but we can not change that right now. Workarounds have been described so please stop fighting here. |
lol, those symfony guys are so symfony) they can not have conversations in normal way, they always trying to say "Yii sucks, Kohana sucks, OtherPhpFw sucks" )) |
Nice method name "addDirectoryContainingClassToPHPUnitFilesList" :-D |
@cebe check this out https://gist.github.com/DavertMik/4309132 =D |
Hi Team, I am running acceptance test cases using phpunit-selenium, and codeception ... while executing my phpunit i am getting [RuntimeException] even i followed this : #1907 (comment) and also i re-installed invoker .. but still issue was not solve any suggestions to fix the problem
output :
please suggest me something to fix the problem .. |
Should be either your PHPUnit local issue or Codeception issue. These exact tests are runned constantly via Travis (that's PHPUnit w/o Codeception). |
Hi @samdark Thanks for your replay ... Any suggestions to fix [RuntimeException] [ErrorException] like adjusting yiibase.php or adding some packages anything ? |
@DavertMik please look here once |
are you sure you have installed PHP_Invoker? go to your pear folder and check if it there, if no you can download package manually and put it under that folder. |
@Sharom that's not relevant unless you're suggesting Yii2 :) |
I tried both ways..
but still its not working .. getting headache with this .. Anyone please suggest .. |
@aditya- can you try PhpUnit w/o Codeception? i.e. from |
@aditya- make sure yii autoloader is the last one in the autoloader chain. OR include PHP_Invoker.php explicitly in phpunit bootstrap file to work around it. |
Hi @samdark
|
Thanks for the idea ... i am just wondering still its throwing same error |
yeah !!! First of all Thanks @samdark .. For helping me to fix this issue .. i tried this before i posted here.. i got this from Google.. i think so but ... this is also not fixed the issue .. after that i tried manually replacing invoker files in pear folder |
@samdark, на сколько я знаю, ты из России. Так вот, на чистом русском: Yii - дерьмо. Часть 1 и часть 2. |
@Sharom ну ок :) |
@Sharom, не будь балаболом, приведи факты. |
В чем ОК? Вы делаете дерьмо. |
@yvgorshkov, станешь программистом, сам увидишь факты. |
@yvgorshkov, я трезв. Я не переношу дерьмовые продукты. Вроде Yii. |
For English-speaking people: sorry that we're using Russian. Don't spend time translating, it's just offtopic chat that doesn't have anything to do with the problem described in the ticket. @yvgorshkov не стоит переходить на личности и материться.
|
lol .. Thanks for understanding our problem ;-) but yii is great framework .. |
@samdark |
@aditya- so was your problem solved? If not, get to Yii IRC and ping me. That will be faster. |
No @samdark .. not yet fixed .. yes i will cum there .. Thank you .. |
@aditya- Please add this line
Somewhere in bootstrap file. If this not helps: install the PHP_Invoker from PEAR channel. @Sharom No one here is talking about new projects, right?
I understand your feelings. My choice is Rails and I suffered that hard when I had to use Symfony :) |
This problem with Yii could be fixed.
This is a well-founded fear. But, on the other hand, the current behavior of the code breaks behavior of the In my opinion it is a greater evil. |
Sorry for no replay .. i was on vacation till now ..
Really works great .. issue was fixed .. Thank you .. 👍 Thank you to all who helped me.. Specially to @samdark 👍 |
@pennyp Thanks for your solution. I was experiencing the same problem and followed your instructions, then it worked smoothly. |
I had tried to fix PHPUnit + Yii for a two days before found a "YiiBase::$enableIncludePath=false;" solution. I thought Yii is more better. It was my first disappointment about Yii (( |
Shouldn't we place this line somewhere in the default test code? See also: Codeception/Codeception#234 (comment) |
Does PHPUnit 4.6 fix this issue? https://github.com/sebastianbergmann/phpunit/blob/master/ChangeLog-4.6.md |
Unfortunately, no:
|
(this issue still exists in PHPUnit 6 when running tests from NetBeans) |
I know there are some issues about that (phpunit < 3.7.10) and looks like there were solved but, i got this problem, need to notice that problem occures when tests fails:
When i run unit tests, Yii::autoloader throws Exceptions on not found files, this files:
on
YiiBase::autoload() ...\php\pear\PHPUnit\Util\GlobalState.php:0
So i found that problem again in autoloader order, if i comment
spl_autoload_register(array('YiiBase','autoload')); // put yii's autoloader at the end
than no exceptions will be thrown by Yii::autoload() even if there is a fail test. But if i run WebTestCase tests Yii autoload throws errors again.So is it my problem or its a Yii bug or phpunit bug? Btw. spl autoloaders list is correct (Yii autoload is the last one). Could it be because of in YiiBase at the end of the file there is already
spl_autoload_register(array('YiiBase','autoload'));
?The text was updated successfully, but these errors were encountered: