Hot answers tagged

8 votes
Accepted

How do I run PHP Unit Tests w/ XDEBUG from within PHPStorm [on Mac]?

Here are the steps/complete set of screenshots of a configuration that now works for me: 1) from command line ensure you can run buildkit -> civibuild $ civibuild create dmaster --type drupal-demo -...
user avatar
4 votes
Accepted

How do I run CiviCRM PHPUnit tests from within Netbeans?

[This all assumes you have civicrm-buildkit already working and that you can run CiviCRM phpunit tests successfully from the command line.] 1. Tell Netbeans which phpunit executable you're using. Go ...
user avatar
4 votes

Does class autoloading not work in standalone phpunit testing?

This is an issue with intermediate base-classes for tests (like VolunteerTestAbstract). The most reliable solution I've found is to put a require_once to load the intermediate base-class. For example, ...
user avatar
  • 5,589
3 votes
Accepted

Is there a copy of phpunit 4 documentation somewhere?

https://phpunit.de/manual/4.8/en/index.html still exists even though it's not shown as an option in the menu anymore.
user avatar
2 votes

class Civi not found

Ok, so it turns out I was kinda doing something wrong... What I needed was a simple \ prefix: \Civi::log()->info('Hello, log!');
user avatar
  • 1,561
2 votes
Accepted

Does class autoloading not work in standalone phpunit testing?

Civi's autoloader does not load classes outside the CRM directory. In order for that to work, you'll have a few options: Implement your own autoloader capable of loading classes inside the test/...
user avatar
2 votes
Accepted

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

So I figured this out. The specific hook engine for unit testing, very conveniently, comes with an injectable mock property. After grabbing the hook engine with $this->hookClass = \CRM_Utils_Hook::...
user avatar
  • 1,561
1 vote

Why are cv php:boot calls failing only when running unit tests and not through direct CLI calls?

I found the answer: I was using a backup: the CiviCRM unit test framework uses files and services not found without doing a git clone (or buildkit equivalent). The folders you need from a git clone ...
user avatar
  • 2,343
1 vote

PHPUnit_Framework_BaseTestListener class not found

This sounds like a mismatch in the phpunit versions: Currently, most of the Civi testing runs against the PHAR build of phpunit v4. phpunit v6 renames every class to use \ instead of _, which means ...
user avatar
  • 5,589
1 vote
Accepted

PHPUnit_Framework_BaseTestListener class not found

I run tests the following way I test in a CiviCRM instance that is generated with buildkit (the toolchain provided for CiviCRM developers see https://docs.civicrm.org/dev/en/latest/tools/buildkit/ . ...
user avatar

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