Install Ibexa DXP (required dependency):
composer create-project ibexa/dxp-project my-project
cd my-project
Add the test package (if not auto-included in DXP):
composer require ibexa/test-core --dev
First Use Case: Basic Test Setup
Create a test class extending Ibexa\Core\Test\PHPUnit\TestCase:
use Ibexa\Core\Test\PHPUnit\TestCase;
class MyTest extends TestCase
{
public function testExample()
{
$this->assertTrue(true); // Basic test
}
}
Key Files to Explore:
vendor/ibexa/test-core/src/ (core test utilities)tests/Integration/ (DXP integration tests as reference)Database Testing
Use TestCase with built-in database transactions:
public function testContentCreation()
{
$content = $this->createContent('article');
$this->assertEquals('article', $content->getContentInfo()->contentTypeIdentifier);
}
Service Container Access
Inject services via getContainer():
$contentService = $this->getContainer()->get('ezpublish.api.service.content');
Test Data Factories Leverage Ibexa’s data factories for consistent test data:
$content = $this->createContent('article', [
'title' => 'Test Article',
'body' => 'Test content',
]);
API Client Testing
Use Ibexa\Core\Test\Client\Client for API interactions:
$client = $this->getClient();
$response = $client->get('/content');
createMock() for external dependencies.phpunit.xml:
<php>
<env name="APP_ENV" value="test"/>
<env name="DB_CONNECTION" value="testbench"/>
</php>
Experimental Status:
composer require ibexa/test-core:^1.0 --dev
Database Dependencies:
touch database/database.sqlite
Service Initialization:
ContentService) may need manual setup:
$this->getContainer()->get('ezpublish.api.service.content')->initialize();
$this->getContainer()->get('ezpublish.api.service.content')->setDebug(true);
Ibexa\Core\Base\Logger for test-specific logging.Custom Test Cases:
Extend TestCase to add reusable methods:
class CustomTestCase extends TestCase
{
protected function createUser(): User
{
return $this->createUser('test@example.com', ['admin']);
}
}
Test Data Builders:
Override createContent() in child classes for domain-specific data:
protected function createContent(string $type, array $data = []): Content
{
$data['custom_field'] = 'custom_value';
return parent::createContent($type, $data);
}
Performance Testing:
Use Ibexa\Core\Test\Performance\Benchmark for load testing:
$benchmark = new Benchmark();
$benchmark->run(function() {
$this->createContent('article');
});
How can I help you explore Laravel packages today?