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) »
  • How to disable the reset of the database at each test ?
Pages: [1]

Author Topic: How to disable the reset of the database at each test ?  (Read 3579 times)

xavier

  • Forum Godess / God
  • I’m (like) Lobo ;)
  • *****
  • Posts: 4453
  • Karma: 161
    • Tech To The People
  • CiviCRM version: yes probably
  • CMS version: drupal
How to disable the reset of the database at each test ?
January 13, 2011, 05:08:51 am
Hi,

I know, it's bad, that's going to cause me problems and you don't recommend it,  but please, what's the magic configuration option to be able to run a unit test without resetting the database ?


X+

-Hackathon and data journalism about the European parliament 24-26 jan. Watch out the result

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: How to disable the reset of the database at each test ?
January 13, 2011, 05:17:15 am
You'll be eternally damned if you pick this fruit. :-)

tests/phpunit/CiviTest/CiviUnitTestCase.php

protected $noreset = false;  <- set to true

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!

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: How to disable the reset of the database at each test ?
January 13, 2011, 05:21:52 am
Umph, sorry:

public static $populateOnce = false; <- set to true

$noreset seems like some kind of obsolete line of code - I'll take a look at it and fix on trunk.

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!

xavier

  • Forum Godess / God
  • I’m (like) Lobo ;)
  • *****
  • Posts: 4453
  • Karma: 161
    • Tech To The People
  • CiviCRM version: yes probably
  • CMS version: drupal
Re: How to disable the reset of the database at each test ?
January 13, 2011, 05:36:12 am
Quote from: Michał Mach on January 13, 2011, 05:17:15 am
You'll be eternally damned if you pick this fruit. :-)

How appropriate the choice of your picture in this forum... and thanks to think I wasn't damned already, something I'd doubt of ;)
-Hackathon and data journalism about the European parliament 24-26 jan. Watch out the result

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: How to disable the reset of the database at each test ?
January 13, 2011, 07:36:58 am
:-D
Found this reply helpful? Contribute NOW and help us improve CiviCRM with the Make it Happen! initiative.

My absolute favourite: Wordpress Integration!.

Donate Now!

xavier

  • Forum Godess / God
  • I’m (like) Lobo ;)
  • *****
  • Posts: 4453
  • Karma: 161
    • Tech To The People
  • CiviCRM version: yes probably
  • CMS version: drupal
Re: How to disable the reset of the database at each test ?
February 14, 2011, 01:00:15 pm
Hi,

For some reasons, my test environment started to mostly behave again and do something slightly more useful that dying on "Bool(true)".

When I run the test normally, works fine beside spending half an eternity on the db init.

When I populateOnce = true it seems to forget somewhere the database connection

Code: [Select]
Installing civicrm_tests_dev database
EEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEE

Time: 1 second

There were 41 errors:

1) api_v3_ActivityTest::testActivityCreateEmpty
PHPUnit_Extensions_Database_Operation_Exception: TRUNCATE operation failed on query:
                TRUNCATE `civicrm_option_group`
             using args: Array
(
)
 [SQLSTATE[3D000]: Invalid catalog name: 1046 No database selected]
...


Was trying testActivity. Could you test on your side and confirm it works ok ?


X+
-Hackathon and data journalism about the European parliament 24-26 jan. Watch out the result

Pages: [1]
  • CiviCRM Community Forums (archive) »
  • Old sections (read-only, deprecated) »
  • Developer Discussion »
  • Unit Testing (Moderator: Michał Mach) »
  • How to disable the reset of the database at each test ?

This forum was archived on 2017-11-26.