Hot answers tagged

7

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 --url http://d47.localhost --admin-pass mypass 2) from command line ensure you can run tests - that all is working properly karins-macbook-pro:civicrm sysadmin$ pwd /...


4

[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 to Tools » Options, then PHP tab, PHPUnit subtab. Set the path of your PHPUnit script. See screenshot: 2. Create a shell script with your environment ...


4

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, this is what I used in uk.co.vedaconsulting.mosaico: require_once __DIR__ . '/TestCase.php'; class CRM_Mosaico_MosaicoTemplateTest extends ...


3

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


2

Ok, so it turns out I was kinda doing something wrong... What I needed was a simple \ prefix: \Civi::log()->info('Hello, log!');


2

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/phpunit dir Use require to include the class Put the VolunteerTestAbstract class inside your CRM dir I usually use the second option for that and include/require ...


2

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::singleton() you just need to inject a mock object that has a magic __call() method with somthing like: $this->hookClass->setMock($this); The hook ...


1

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 that all the base-classes disappear if you run on a newer build of phpunit.


1

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/ . My tests are generated with civix generate:test. Remarks that this generator also creates the file tests/phpunit/bootstrap.php that takes care of the class ...


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