CiviCRM Community Forums (archive)

*

News:

Have a question about CiviCRM?
Get it answered quickly at the new
CiviCRM Stack Exchange Q+A site

This forum was archived on 25 November 2017. Learn more.
How to get involved.
What to do if you think you've found a bug.



  • CiviCRM Community Forums (archive) »
  • Old sections (read-only, deprecated) »
  • Developer Discussion »
  • Unit Testing (Moderator: Michał Mach) »
  • Segfaulting when using phpunit
Pages: [1]

Author Topic: Segfaulting when using phpunit  (Read 2516 times)

torenware

  • I post frequently
  • ***
  • Posts: 153
  • Karma: 4
Segfaulting when using phpunit
October 24, 2009, 01:33:09 am
I'm trying to get set up to use CiviTest, which uses phpunit.  I've been following the instructions at http://wiki.civicrm.org/confluence/display/CRM/Setting+up+your+personal+testing+sandbox+HOWTO?focusedCommentId=23724076&#comment-23724076.

From the sites/all/modules/civicrm/tools directory, I'm running something like this:
Code: [Select]
scripts/phpunit  -u civitester -pPASSWORD -h localhost api_v2_ContributionTest

The database exists; I can start up mysql and it works with these settings:
Code: [Select]
mysql -u civitester -pPASSWORD -h localhost civicrm_tests_dev
The copy of civicrm.settings.php that's in tests/phpunit/CiviTest exists and editing right AFAICT, and I've established that the file is in fact read when I start up phpunit.

But I die in tests/phpunit/CiviTest/CiviUnitTestCase.php around line 111,  in CiviUnitTestCase::setup():   

Code: [Select]
$config =& CRM_Core_Config::singleton();
I'm guessing that the database is not properly initialized when this gets called, but I can't figure out as to why.

Any idea as to why this happens, or how to fix this?

Michał Mach

  • Ask me questions
  • ****
  • Posts: 748
  • Karma: 59
    • CiviCRM site
  • CiviCRM version: latest
  • CMS version: Drupal and Joomla latest
  • MySQL version: numerous
  • PHP version: 5.3 and 5.2
Re: Segfaulting when using phpunit
October 26, 2009, 03:53:37 am
Hey Rob,

First thing that comes to my mind is that the database is empty when unit tests are trying to initialize CiviCRM. We had a few changes in the flow of tests recently and initialization was jumping in and out, so I forgot to update the documentation. Basically, the first time you are running any tests, you need to have the database populated either via setup.sh (if it's a clean checkout, it will also generate DAOs) or manually loading the schema (civicrm.mysql) and basic data (civicrm_data.mysql).

However, the segfault is kind of weird, it should be giving some more meaningful error. Can you check the above? If that's not it, we'll investigate further. I'm also assuming you have mysq 5.0? Some segfaulting problems with 5.1 were reported.

I need to solve the problem of first time initialization once and for all - I'll modify the test suite in next few days to do something about it (need to figure out the best solution first). In the meantime, I've added a note to documentation to init the database on the first run.

Thx,
m
Found this reply helpful? Contribute NOW and help us improve CiviCRM with the Make it Happen! initiative.

My absolute favourite: Wordpress Integration!.

Donate Now!

Pages: [1]
  • CiviCRM Community Forums (archive) »
  • Old sections (read-only, deprecated) »
  • Developer Discussion »
  • Unit Testing (Moderator: Michał Mach) »
  • Segfaulting when using phpunit

This forum was archived on 2017-11-26.