-
Notifications
You must be signed in to change notification settings - Fork 1.9k
New Feature/HTTP Testing capabilities #1047
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
Conversation
Ugh. Have an issue with Code Coverage and the debug toolbar.... will have to get that working later. |
Oh my - a couple of changes :) |
The tests themselves are passing but when it runs the code coverage it has issues with the toolbar loader. Seems like we had this issue in the past but I don’t remember how to fix it. Will try to get it working tonight. |
@jim-parry merged. Let me know if you have any questions. |
Not sure if I am doing something wrong, or if there is some config bit that differs between us, but I barely get a peep out of phpunit...
|
Since you got some other commits on your PR does that mean you got it working? |
No. A straight pull of "develop" leads to the fatal error above when I try to run phpunit locally. |
Hmm - I have the same problem if I do a straight download of the repo & try to run phpunit. In tests/_support/CIUnitTestCase, starting with "use CodeIgniter\Test; class CIUnitTestCase extends Test\CIUnitTestCase ..." gives the class not found error, while starting with "use CodeIgniter\Test\CIUnitTestCase; class CIUnitTestCase extends CIUnitTestCase ... " gives "Cannot declare class CIUnitTestCase because the name is already in use..." At the moment, I suspect a namespace issue with CIUnitTestCase; not sure if it is somehow version related. |
@lonnieezell I am leaning towards a breaking change in tests/_support/_bootstrap.php ... it no longer adds namespaces or loads the CI config or framework instance. |
The changes in bootstrap are intentional. It was refactored so that a new instance of CodeIgniter was built for every test run, allowing us to do tests that were impossible previously. I was running into similar things previously. That should be changed to a require_once I believe, though not sure exactly where it’s trying to do that. Confused how it worked for both me and for Travis though. |
The only thing "required" in _bootstrap is CIUnitTestCase. There is no mention of CodeIgniter or App config. Is this the way it is supposed to be? It feels incomplete. |
It only feels incomplete because that functionality was moved. I won't have time to look at it until maybe tonight. |
@jim-parry I'm not sure what to tell you. I just pulled down a new copy into a vagrant instance I have running with Ubuntu and tests run just fine. I can't replicate the issue you're describing here. |
I have setup centos6, centos7 & ubuntu instances, with php7.0, 7.1 & 7.2 (as appropriate), and phpunit 6 and 7. I have not found a combination that does not give the same problem. |
That's crazy. I'm sorry it's doing that to you. My vagrant box is PHP 7.1.3, phpUnit 7.1.5, under Ubuntu 16.04.2 if that helps anything. Looks like on that box XDebug is not installed - which would not have ran code coverage, so is probably skipping over whatever is causing that issue. Dang. On my mac I'm running PHP 7.1.14, with phpUnit 7.1.5 with XDebug enabled. Have you tried just running any single test file to see if there's one particular file that's causing the issue? I know I had some painful times locating some of the things last week where I had to go one directory at a time running the tests. Once I even had to modify phpunit.xml's testsuite to start specifically including directories to see if there was some combination of folders causing errors I was seeing. It wasn't overly fun but eventually got me there. It sounds like the autoloader isn't being loaded somewhere. So I'd start stepping through testsuite's bootstrap to see where things died, too. |
Echoing the different paths shows BASEPATH as .../system instead of .../CodeIgniter4/system! |
@jim-parry Where is your phpunit command running from? Mine is running from the vendor/bin/phpunit folder. Do you have a symlink or phar loaded in the main file? If so, I wonder if that's messing with the URLs... |
phpunit 7.1.5 |
vendor/bin/phpunit is a symlink, to vendor/phpunit/phpunit/phpunit (a 1.2KB script) |
Problem resolved, at least on my system. |
Does the site still run from the frontend? Those paths have always been set relative to the public folder since that's where the index.php file is that runs everything. If you managed to make it work for both testing and front-end, then cool. Otherwise, it's just the way CodeIgniter has always been... |
Includes refactoring of a few core portions of the framework (like CodeIgniter.php and IncomingRequest) to allow more flexible testing.
Docs still need to be written, but since @jim-parry is working on a lot of tests I want to get these changes in place so he can work with them.
The biggest things to know when working on tests:
setUp()
methods within tests must now callparent::setUp()
.tests/_support
must have their namespace changed toTests\Support\...
Biggest new feature is the FeatureTesting portion.