Jump to content

Bootstrapping Processwire in PHPUnit


FrancisChung
 Share

Recommended Posts

Hi there,

I'm having trouble getting Processwire to boostrap into PHPUnit.

It used to work but it's stopped working for some inexplicable reason.

I'm getting the following error message.

Error: Exception: SQLSTATE[HY000] [2002] No such file or directory (in /Users/FrancisChung/Sites/Develop/wire/core/ProcessWire.php line 186)

I have included one of the tests that uses Processwire boostrapping.ImageTest.php

My other tests are working fine, just the ones that need Processwire bootstrapping is broken.

FYI, I've tried bootstrapping externally using --boostrap option using phpunit in CLI, but it did not work.

Link to comment
Share on other sites

I've turned on debugging on PW, and this was the stack trace returned.
 

---------
 
 
/Applications/MAMP/bin/php/php5.5.26/bin/php /private/var/folders/m4/x0zynvp96jx6tndn0f5k2jc40000gn/T/ide-phpunit.php --configuration /Users/FrancisChung/Sites/Develop/site/templates/php/tests/phpunit.xml Test\ImageTest /Users/FrancisChung/Sites/Develop/site/templates/php/tests/ImageTest.php
Testing started at 19:39 ...
 
Fatal error: Exception: SQLSTATE[HY000] [2002] No such file or directory (in /Users/FrancisChung/Sites/Develop/wire/core/ProcessWire.php line 186)
 
#0 /Users/FrancisChung/Sites/Develop/wire/core/ProcessWire.php(76): ProcessWire->load(Object(Config))
#1 /Users/FrancisChung/Sites/Develop/index.php(238): ProcessWire->__construct(Object(Config))
#2 /Users/FrancisChung/Sites/Develop/site/templates/php/tests/ImageTest.php(3): include_once('/Users/FrancisC...')
#3 /Users/FrancisChung/Sites/Develop/site/templates/composer/vendor/phpunit/phpunit/src/Util/Fileloader.php(56): include_once('/Users/FrancisC...')
#4 /Users/FrancisChung/Sites/Develop/site/templates/composer/vendor/phpunit/phpunit/src/Util/Fileloader.php(38): PHPUnit_Util_Fileloader::load('/Users/FrancisC...')
#5 /Users/FrancisChung/Sites/Develop/site/templates/composer/vendor/phpunit/phpunit/src/Runner/StandardTestSuiteLoader.php(39): PHPUnit_Util_Fileloader::checkAndLoad('/Users/FrancisC...')
#6 /Users/FrancisChung/Sites/Develop/site/templates/composer/vendor/phpunit/p in /Users/FrancisChung/Sites/Develop/index.php on line 253
 
Call Stack:
    0.0022     360216   1. {main}() /private/var/folders/m4/x0zynvp96jx6tndn0f5k2jc40000gn/T/ide-phpunit.php:0
    0.0196    1189816   2. IDE_Base_PHPUnit_TextUI_Command::main() /private/var/folders/m4/x0zynvp96jx6tndn0f5k2jc40000gn/T/ide-phpunit.php:552
    0.0196    1196856   3. PHPUnit_TextUI_Command->run() /private/var/folders/m4/x0zynvp96jx6tndn0f5k2jc40000gn/T/ide-phpunit.php:294
    0.0356    1882640   4. PHPUnit_Runner_BaseTestRunner->getTest() /Users/FrancisChung/Sites/Develop/site/templates/composer/vendor/phpunit/phpunit/src/TextUI/Command.php:123
    0.0356    1882688   5. PHPUnit_Runner_BaseTestRunner->loadSuiteClass() /Users/FrancisChung/Sites/Develop/site/templates/composer/vendor/phpunit/phpunit/src/Runner/BaseTestRunner.php:67
    0.0365    1906040   6. PHPUnit_Runner_StandardTestSuiteLoader->load() /Users/FrancisChung/Sites/Develop/site/templates/composer/vendor/phpunit/phpunit/src/Runner/BaseTestRunner.php:123
    0.0370    1947752   7. PHPUnit_Util_Fileloader::checkAndLoad() /Users/FrancisChung/Sites/Develop/site/templates/composer/vendor/phpunit/phpunit/src/Runner/StandardTestSuiteLoader.php:39
    0.0370    1947952   8. PHPUnit_Util_Fileloader::load() /Users/FrancisChung/Sites/Develop/site/templates/composer/vendor/phpunit/phpunit/src/Util/Fileloader.php:38
    0.0376    1987008   9. include_once('/Users/FrancisChung/Sites/Develop/site/templates/php/tests/ImageTest.php') /Users/FrancisChung/Sites/Develop/site/templates/composer/vendor/phpunit/phpunit/src/Util/Fileloader.php:56
    0.0384    2035400  10. include_once('/Users/FrancisChung/Sites/Develop/index.php') /Users/FrancisChung/Sites/Develop/site/templates/php/tests/ImageTest.php:3
    0.0768    3906672  11. trigger_error() /Users/FrancisChung/Sites/Develop/index.php:253
 
 
 
Error: Exception: SQLSTATE[HY000] [2002] No such file or directory (in /Users/FrancisChung/Sites/Develop/wire/core/ProcessWire.php line 186)
 
#0 /Users/FrancisChung/Sites/Develop/wire/core/ProcessWire.php(76): ProcessWire->load(Object(Config))
#1 /Users/FrancisChung/Sites/Develop/index.php(238): ProcessWire->__construct(Object(Config))
#2 /Users/FrancisChung/Sites/Develop/site/templates/php/tests/ImageTest.php(3): include_once('/Users/FrancisC...')
#3 /Users/FrancisChung/Sites/Develop/site/templates/composer/vendor/phpunit/phpunit/src/Util/Fileloader.php(56): include_once('/Users/FrancisC...')
#4 /Users/FrancisChung/Sites/Develop/site/templates/composer/vendor/phpunit/phpunit/src/Util/Fileloader.php(38): PHPUnit_Util_Fileloader::load('/Users/FrancisC...')
#5 /Users/FrancisChung/Sites/Develop/site/templates/composer/vendor/phpunit/phpunit/src/Runner/StandardTestSuiteLoader.php(39): PHPUnit_Util_Fileloader::checkAndLoad('/Users/FrancisC...')
#6 /Users/FrancisChung/Sites/Develop/site/templates/composer/vendor/phpunit/p
 
This error message was shown because site is in debug mode ($config->debug = true; in /site/config.php). Error has been logged. 
 
 
Process finished with exit code 255
 
Link to comment
Share on other sites

Ah, you're using MAMP (Pro?). Try the following:

* Main window › MySQL, tick checkbox "Allow network access" (I got the German version of MAMP, don't know the proper translation), restart.
* In ProcessWire's /site/config.php, replace localhost with 127.0.0.1

This is also an issue I found while working on wireshell with that particular MAMP set up.

  • Like 4
Link to comment
Share on other sites

Actually, I had to reinstall MAMP Pro as I realised it was causing other issues.

Unfortunately, I saw your post after I figured it out Marcus. (Could have saved me hours of pain).

But thanks for the post.

Definitely will come in handy for other users stumbling here,.

  • Like 2
Link to comment
Share on other sites

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 account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...