The Stack Overflow podcast is back! Listen to an interview with our new CEO.

Hot answers tagged

9

This is an excellent question. Before trying to answer, let me note a bit of the context: When defining a test plan, several organizational and technical factors can weigh-in (e.g. perhaps certain extensions or use-cases are more important or more within your expertise; perhaps there's a rotation of responsibilities). The question focused on how to examine ...


7

I will answer your questions #1 and #2. (I'm not sure what you mean by #3. If #3 is sufficiently unrelated to #1 and #2, I would suggest creating a separate question for it) Why an ER (Entity Relationship) diagram might not be helpful As a visual learner, I too looked for an ER diagram when first trying to understand the CiviCRM database schema. I was ...


6

At time of writing, all PRs tests and scheduled tests run under Ubuntu 12.04 (PHP 5.3.10). There is an effort underway to introduce a test node for Ubuntu 16.04 (PHP 7.0) (although details are still a bit in flux). When you inspect the results of a test run, you can get some details (such as the node name and console output). The node names follow a ...


5

ah-ha! In your test class edit the setUpHeadless() method which might look at first like this: public function setUpHeadless() { // Civi\Test has ...


4

2) You can use a tool like SchemaSpy to extract the structure of the database, have the foreign key displayed in a table or on a schema and navigate easily between related tables. You can see an example (and use) of SchemaSpy doc generated for CiviCRM 4.7 https://doc.symbiotic.coop/dev/civicrm/v47/schema/index.html EDIT: For those interested, there is a ...


4

Selenium testing can refer to a couple different situations: A. If you focus on implementing custom sites for clients, then you might create a custom Selenium test-suite which encompasses the configurations/customizations/addons. Basically everything in the tool-chain is at your discretion. Use Selenium (or something else!). Use Civi tarballs (or zipballs ...


4

Redirect to database puts them as mass mailings, or used to. You can read them in the UI the same as those.


4

I recently pushed b3db22c002a5d16ae3715b97b58f3f64a1526a3a -- which adds the --user (-U) option and seems to work in WP/D7 (but hasn't been exhaustively tested). Try downloading the latest build of cv.


4

If wp-cli is an option, it takes a --user option, similarly to drush. If that's not an option, looking at the wp-cli source code (here) suggests that wp_set_current_user() will do the trick.


2

Generally, you need to get a reference to the API kernel. (For testing, I usually build up a custom instance, but you can use Civi::service("civi_api_kernel")). Then call registerApiProvider(...) and pass along a new provider. I usually define mock APIs using new AdhocProvider(...). There are examples of mocking an API in api_v3_UtilsTest and ...


2

Allan - I have tended to try to refactor the AJAX functions such that they call a more testable function & test that - this generally improves the code.... There are a few examples that test the calls directly - see classes like CRM_Contact_Page_AjaxTest CRM_Custom_Page_AJAXTest CRM_Financial_Page_AjaxTest CRM_Group_Page_AjaxTest


2

I'm a bit out of date on the current status of the civi test framework, but if WebTests are still available I would do this as a WebTest. https://wiki.civicrm.org/confluence/display/CRM/Setting+yourself+up+to+work+with+Selenium+tests Include a line that waits for some element you are expecting to appear, then test its value using the webtest api.


2

So one possibility is to use Selenium2TestCase as your base class for you test... I've been using Selenium Standalone Server 3.3 (looks like 3.4 just released) http://www.seleniumhq.org/download/ So its a little different that SeleniumTestCase, because Selenium 2 uses the WebDriver, and support for firefox may require you install the third party gecko ...


2

I'm not an expert of testing but i'm pretty sure that SimpleTest creates a new instance of Drupal with a new database each time the testing process is ran. CiviCRM is not a standard Drupal module and cannot just be enabled. In your SetUp function, You need to install CiviCRM to create the corresponding tables in the database. It could be a rather complex ...


2

I strongly prefer the approach of having a $1 membership type set up, and testing it with real cards and real money. For $2-3 I get full piece of mind that things are working. I generally only need to know it is working on one Contribution page to give me confidence that it will be working on all pages using the same Payment Processor.


2

The error message says sh: 1: cv not found, so the symptom here is that the proc_open() call is unable to find the executable cv. It looked like the place to check this should be cv() function in tests/phpunit/CiviTest/bootstrap.php ... but I wasn't able to get that to work. Having investigated, I suspect that this may be an issue in \Civi\API\...


2

Thanks to the helpful comments, I conclude: Yes it can, with a bit of help. TL;DR you need to define CIVICRM_CMSDIR in your code you need set CIVICRM_SETTINGS as an environment var Longer version As far as I can work out, cv sources civicrm.settings.php before it sources wp-config.php. So if, like me, you have config set in civicrm.settings.php that ...


2

Please refer to Moving an Existing Installation to a New Server or Location for this.


2

We strongly discourage interacting directly with tables and fields in the database. Instead it is much safer to access data via the API, which has a convenient explorer. For those doing core work, and sometimes for extension developers who wish to extend functionality, an ERD is a useful idea. I don't think we have created a set recently due to the ...


2

I recommend you install and use buildkit: https://github.com/civicrm/civicrm-buildkit It comes with lots of tools - including those you need to run tests. I use it on MAMP but from what I understand this will work on Windows as well. Alternatively - if you like you can also: https://github.com/civicrm/civicrm-buildkit-vagrant


1

An example is in tests/phpunit/CRM/Contribute/Form/Task/PDFLetterCommonTest.php, testing that hook_civicrm_tokenValues works correctly on PDF letters. You write a function using the hook, but you can name it whatever you want. Then you call $this->hookClass->setHook, specifying the function name.


1

I am unaware of a way to turn on test data as you put it but here are some work arounds. To find test the records, in searches (advanced search, membership search etc) there is a field "Membership is a Test" by default this is set to No but if you want to find test record such as the one specified above you can switched this to Yes. Another option, if the ...


1

It's also worth noting that if you're using civicrm-buildkit to create your test sites (highly recommended) you can also rebuild a site with civibuild reinstall.


1

Your error doesn't indicate a problem with your database - and it does sound like you've copied them correctly. This error indicates that you have a missing file in your file system. Is the webform module missing on your test site? Or perhaps the test site's webform module isn't the same version? You should also clear your Drupal cache on the test site.


1

Just adding some steps to check if basic things are met correctly. Make sure you are in civicrm folder when you run the test. $ cd <site_name>/sites/all/modules/civicrm $ export CIVICRM_UF=UnitTests $ phpunit4 tests/phpunit/api/v3/ContactTest.php Is your civicrm.settings.php file searchable? Add the below line to your ~/.bash_profile file. export ...


Only top voted, non community-wiki answers of a minimum length are eligible