I'm using it.
In my src/addons/YourAddon/Tests I have a bootstrap.php file with these contents:
PHP:
<?php
$dir =
__DIR__ . DIRECTORY_SEPARATOR .
'..' . DIRECTORY_SEPARATOR .
'..' . DIRECTORY_SEPARATOR .
'..' . DIRECTORY_SEPARATOR .
'..';
require ($dir . '/src/XF.php');
XF::startAutoloader($dir);
Which basically just tells PHPUnit how to XenForo classes.
And also this file
XML:
<?xml version="1.0" encoding="utf-8" ?>
<phpunit bootstrap="./bootstrap.php" colors="true">
</phpunit>
I put all my tests in src/addons/YourAddon/Tests and have this header:
PHP:
namespace YourAddon\Tests;
use PHPUnit\Framework\TestCase;
class MyTest extends TestCase
{
use TestCaseTrait;
And I run it like this:
Code:
cd src/addons/YourAddon/Tests && phpunit .
PHPUnit always looks for the phpunit.xml in the current directory, so we have to go there to run our tests.
This is for XF2, let me know if you need help with XF1.
I am also using DbUnit, so if you need help with that, I can share more of my code.