chrizz Posted April 17, 2019 Share Posted April 17, 2019 Hey guys, I am recently migrated my whole setup to a newer environment, using Vagrant, webpack and the latest version of PHPUnit. Everything works fine except the tests are driving me crazy. It worked long time ago already but nowadays I have some trouble with the test output and I hope that someone has an idea. If I run a single test via my Eclipse IDE it works perfectly and the output as shown as expected. I see all tests in a nice overview including all passed and failed tests. But as soon as I include the index.php from the root directory to utilize the PW API the output is killed completely. Something must cause interferences between PHPUnit and including the PW API. I am using PW 3.0.62 and tried with PHPUnit 6.5.14, 7.5.8, 8.1.2 and PHP 7.1.28, 7.2.16. Regardless which configuration - it all ends when PW is included ? Any ideas where I might dig into are really appreciated. Link to comment Share on other sites More sharing options...
chrizz Posted May 2, 2019 Author Share Posted May 2, 2019 Sorry for pushing this but I still hope that someone has an idea. Maybe you are using a different IDE? Or you are not testing as all? Link to comment Share on other sites More sharing options...
WinnieB Posted August 23, 2019 Share Posted August 23, 2019 Have you seen this thread? https://processwire.com/talk/topic/12723-bootstrapping-processwire-in-phpunit/ I'm getting into test-driven development with the Nette Tester module, and am learning how to bootstrap PW. If the PW instance you're bootstrapping has Tracy Debugger installed, "Tracy Logs" give meaningful realtime feedback (after page reload) on bootstrap (and other) errors. This helped me "trace" ? a tricky bug that didn't appear in Tracy "Processwire Logs", or Windows, mysql, or Apache logs. My error was caused by the fact that: While I was logged as Superuser into the admin of the PW instance I was bootstrapping AND the PHP script I bootstrapped from was in a subdirectory of that site by default PW runs bootstrapped scripts as "guest" user, and couldn't access what I wanted - a custom per-user field from the Admin "Profile" section. PW forum searching revealed that Ryan Cramer chose this sane default for security. Ryan's code in this thread solved my problem: <?php $users = wire('users'); $superuser = $users->get("YOUR_PW_USERNAME"); $users->setCurrentUser($superuser); Also be aware, as this page states: Quote You can access all of the same API variables that you can from a template, except that there is no default $page variable accessible from the API since ProcessWire is not handling the web request. Of course, you are welcome to retrieve any page you want from the $pages API variable. Likewise you can modify, save, and delete pages as usual. 1 Link to comment Share on other sites More sharing options...
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now