Questions tagged [unit-testing]

The tag has no usage guidance.

Filter by
Sorted by
Tagged with
1 vote
1 answer
67 views

Why does phpunit say "DB Error: connect failed" for new 'drupal-clean' site?

I have a new 'drupal-clean' civibuild site which works fine in the browser, yet when I try to run civicrm phpunit tests, I get a mysql connection error, "DB Error: connect failed". How can I ...
TwoMice's user avatar
  • 1,794
3 votes
1 answer
77 views

How do I run CiviCRM PHPUnit tests from within Netbeans?

I want to run PHPUnit tests from within my IDE - and I know Karin G. has created excellent directions for PHPStorm, but I use Netbeans 8.2. What can I do?
Jon G - Megaphone Tech's user avatar
1 vote
0 answers
147 views

How to write php unit test

I am having the below PHP class file. How do I create a TestCase or TestClass for this <?php class CRM_History_Page_HistoryPage extends CRM_Core_Page { public function run() { // Get User ...
ManiMuthuPandi's user avatar
1 vote
1 answer
35 views

Working e2e UnitTests?

When I run e2e unit tests, it doesn't seem to recognise that I'm telling it to only use group e2e. This is possibly due to the default include/exclude filters in the phunit.xml file. When I add the ...
JohnFF's user avatar
  • 2,343
2 votes
1 answer
101 views

How do I write unit tests that verify a hook is being fired?

I found this example but it doesn't look like it would generalise to all hooks. The use case is for API4 - basically whenever any action is called I think we should be able to verify that particular ...
ErichBSchulz's user avatar
  • 1,571
1 vote
0 answers
89 views

How to spoof users to unit test ACL logic

Starting to think about unit testing access control permission logic in API calls. Is there an established pattern for this? Within CiviUnitTestCase and ACLPermissionTest there are these snips: ...
ErichBSchulz's user avatar
  • 1,571
1 vote
1 answer
145 views

class Civi not found

I'm trying to use the Civi class to debug an extension with build kit, but after I add this line: `Civi::log()->info('Hello, log!');` to my class I get: ampuser@58e3a823b9ee:/opt/buildkit/...
ErichBSchulz's user avatar
  • 1,571
0 votes
2 answers
142 views

How do I write unit tests for time based actions?

If I have an delayed action in my code then how on Earth can I unit test this? For example a membership transition?
ErichBSchulz's user avatar
  • 1,571
3 votes
1 answer
34 views

private or protected class properties

I'm looking at a class in CRM_Utils_Cache here specificly and it looks exactly like what I need to write some unit tests against my extension. The issue is that the $cache array is private rather ...
ErichBSchulz's user avatar
  • 1,571
1 vote
0 answers
29 views

Ideal dependency injection pattern

Noting Tim Otten's answer here which pointed to his blog post, I'd like to know the best pattern to allow injection of CiviCRM services into extension classes and other things (ie to support unit ...
ErichBSchulz's user avatar
  • 1,571
5 votes
1 answer
235 views

How can I use Xdebug with CiviCRM unit tests?

Ideally in conjunction with an IDE (I use Netbeans, but will fire up pretty much anything that gets this to work).
Jon G - Megaphone Tech's user avatar
3 votes
2 answers
2k views

Does class autoloading not work in standalone phpunit testing?

I'm following civix's upgrade instructions to enable unit tests to be executed with standalone phpunit. I've got my code in a work-in-progress git branch. The first commit captures the civix-...
universalhandle's user avatar