Stack Exchange Network

Stack Exchange network consists of 175 Q&A communities including Stack Overflow, the largest, most trusted online community for developers to learn, share their knowledge, and build their careers.

Visit Stack Exchange

Questions tagged [unit-testing]

The tag has no usage guidance.

3
votes
1answer
38 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?
1
vote
0answers
107 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 ...
1
vote
1answer
27 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 ...
2
votes
1answer
80 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 ...
1
vote
0answers
59 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: ...
1
vote
1answer
30 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/...
0
votes
2answers
57 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?
3
votes
1answer
27 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 ...
1
vote
0answers
14 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 ...
5
votes
1answer
196 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).
3
votes
2answers
604 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-...