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) »
  • Making it easy to test
Pages: [1]

Author Topic: Making it easy to test  (Read 2588 times)

Eileen

  • Forum Godess / God
  • I’m (like) Lobo ;)
  • *****
  • Posts: 4195
  • Karma: 218
    • Fuzion
Making it easy to test
April 25, 2011, 04:30:28 pm
I have just switched across to branch 3.4 & trying to run my first test (to make sure a problem I have fixed is tested) and I find it fatals on not being able to find civicrm.settings.php. So, I remove the .txt extension & run again

I couldn't at first think of a good reason since you would almost always just rename it. But I guess there might be circumstances when people would want to change the db name so it might make more sense to ship it with the php extension but have something like

if (file_exists('settings.local.php'){
include 'settings.local.php';
}
Make today the day you step up to support CiviCRM and all the amazing organisations that are using it to improve our world - http://civicrm.org/contribute

xavier

  • Forum Godess / God
  • I’m (like) Lobo ;)
  • *****
  • Posts: 4453
  • Karma: 161
    • Tech To The People
  • CiviCRM version: yes probably
  • CMS version: drupal
Re: Making it easy to test
April 26, 2011, 03:29:57 am
I thought the name of the db was hardcoded ? (and in that case, what's the purpose of needing the setting file indeed)

What I never quite understood was why the name of the db is hardcoded, but login/pwd/host have to be put as a parameter when you run the test suite. Me would be happy if it takes the default (eg. test/test or what's in the suggested settings.local.php) when not in the url.


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: Making it easy to test
April 26, 2011, 10:00:12 am
Eileen: To be sincere, as we move forward with improving the suite, there is less and less reason for separate civicrm.settings.php just for tests. As the suite developed, we started setting things on runtime and not in settings file. So I would say it's a legacy things right now. On the other hand, setting up test suite is not a daily task and it's mentioned in documentation as one of the first steps... :-) (http://wiki.civicrm.org/confluence/display/CRM/Setting+up+your+personal+testing+sandbox+HOWTO).

When we get to improving the suite infrastructure, I think I would like to spend time on upgrading PHPunit to newer version and/or making our tests run off pristine PHPunit (now we used slightly hacked version) - and that would be a good moment to get rid of this thingy.

Xavier: Hardcoded db name is a feature created especially for you, so you don't have to write: "What I never quite understood was why my sandbox database is being overwritten with blank db, removing all my profiles and other stuff". :-)

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: Making it easy to test
April 26, 2011, 12:51:18 pm
Quote from: Michał Mach on April 26, 2011, 10:00:12 am

Xavier: Hardcoded db name is a feature created especially for you, so you don't have to write: "What I never quite understood was why my sandbox database is being overwritten with blank db, removing all my profiles and other stuff". :-)


Yeap, me like it hard and coded too. was suggesting to do the same with the login & password.
-Hackathon and data journalism about the European parliament 24-26 jan. Watch out the result

Eileen

  • Forum Godess / God
  • I’m (like) Lobo ;)
  • *****
  • Posts: 4195
  • Karma: 218
    • Fuzion
Re: Making it easy to test
April 26, 2011, 01:24:13 pm
Code: [Select]
On the other hand, setting up test suite is not a daily task
No, but I spent the time I was going to spend on writing an extra test on getting my test suite re-jigged.

NB, I did realise there are 2 things in the civicrm.settings.php file:

1) the temp path/ smarty template path - I assume there is a way to get the system variable for this that works across machines

2)    define( 'DOCUMENT_ME' ,1); which causes the examples to be generated.
I think I should reverse this so you can turn it off since otherwise there is the danger that no-one except me ever does it & you all hate my windows line breaks (and of course if it isn't useful enough to go beyond just me it should be ditched). I'm referring to the examples in

http://svn.civicrm.org/civicrm/trunk/api/v3/examples
Make today the day you step up to support CiviCRM and all the amazing organisations that are using it to improve our world - http://civicrm.org/contribute

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: Making it easy to test
April 26, 2011, 03:43:08 pm
Quote from: Eileen on April 26, 2011, 01:24:13 pm
NB, I did realise there are 2 things in the civicrm.settings.php file:

1) the temp path/ smarty template path - I assume there is a way to get the system variable for this that works across machines

2)    define( 'DOCUMENT_ME' ,1); which causes the examples to be generated.
I think I should reverse this so you can turn it off since otherwise there is the danger that no-one except me ever does it & you all hate my windows line breaks (and of course if it isn't useful enough to go beyond just me it should be ditched). I'm referring to the examples in

http://svn.civicrm.org/civicrm/trunk/api/v3/examples

Not sure I follow here. You want that to be added to testing settings?

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: Making it easy to test
April 26, 2011, 03:44:08 pm
Quote from: xavier on April 26, 2011, 12:51:18 pm
Quote from: Michał Mach on April 26, 2011, 10:00:12 am

Xavier: Hardcoded db name is a feature created especially for you, so you don't have to write: "What I never quite understood was why my sandbox database is being overwritten with blank db, removing all my profiles and other stuff". :-)


Yeap, me like it hard and coded too. was suggesting to do the same with the login & password.

Cool, send me the patch. ;-)

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!

Eileen

  • Forum Godess / God
  • I’m (like) Lobo ;)
  • *****
  • Posts: 4195
  • Karma: 218
    • Fuzion
Re: Making it easy to test
April 26, 2011, 03:59:02 pm
I think it would be good if the smarty path defaulted to the system temp path

re document_me - I can reverse it in class CiviUnitTestCase

function documentMe($params,$result,$function,$filename){

from

 
Code: [Select]
      if(DOCUMENT_ME ==1){

       
       if ( file_exists('../tests/templates/documentFunction.tpl')) {
          $f = fopen("../api/v3/examples/$entity$entityAction.php", "w");
          fwrite($f,$smarty->fetch('../tests/templates/documentFunction.tpl'));
          fclose($f);
        }
        }


 
Code: [Select]
      if(!DOCUMENT_ME ==1){

       
       if ( file_exists('../tests/templates/documentFunction.tpl')) {
          $f = fopen("../api/v3/examples/$entity$entityAction.php", "w");
          fwrite($f,$smarty->fetch('../tests/templates/documentFunction.tpl'));
          fclose($f);
        }
        }
Make today the day you step up to support CiviCRM and all the amazing organisations that are using it to improve our world - http://civicrm.org/contribute

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: Making it easy to test
April 27, 2011, 03:43:55 am
Eileen,

Let's catch up on IRC. :-)

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) »
  • Making it easy to test

This forum was archived on 2017-11-26.