Weave Code
Code Weaver
Helps Laravel developers discover, compare, and choose open-source packages. See popularity, security, maintainers, and scores at a glance to make better decisions.
Feedback
Share your thoughts, report bugs, or suggest improvements.
Subject
Message

Test Core Laravel Package

ibexa/test-core

View on GitHub
Deep Wiki
Context7

Getting Started

Minimal Setup

  1. Install Ibexa DXP (required dependency):

    composer create-project ibexa/dxp-project my-project
    cd my-project
    

    Follow official Ibexa DXP installation docs.

  2. Add the test package (if not auto-included in DXP):

    composer require ibexa/test-core --dev
    
  3. 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
        }
    }
    
  4. Key Files to Explore:

    • vendor/ibexa/test-core/src/ (core test utilities)
    • tests/Integration/ (DXP integration tests as reference)

Implementation Patterns

Core Workflows

  1. Database Testing Use TestCase with built-in database transactions:

    public function testContentCreation()
    {
        $content = $this->createContent('article');
        $this->assertEquals('article', $content->getContentInfo()->contentTypeIdentifier);
    }
    
  2. Service Container Access Inject services via getContainer():

    $contentService = $this->getContainer()->get('ezpublish.api.service.content');
    
  3. Test Data Factories Leverage Ibexa’s data factories for consistent test data:

    $content = $this->createContent('article', [
        'title' => 'Test Article',
        'body' => 'Test content',
    ]);
    
  4. API Client Testing Use Ibexa\Core\Test\Client\Client for API interactions:

    $client = $this->getClient();
    $response = $client->get('/content');
    

Integration Tips

  • Mocking Services: Use createMock() for external dependencies.
  • Test Isolation: Each test runs in a fresh transaction (no manual cleanup needed).
  • Configuration: Override DXP config via phpunit.xml:
    <php>
        <env name="APP_ENV" value="test"/>
        <env name="DB_CONNECTION" value="testbench"/>
    </php>
    

Gotchas and Tips

Pitfalls

  1. Experimental Status:

    • API may change between DXP versions. Pin versions strictly:
      composer require ibexa/test-core:^1.0 --dev
      
  2. Database Dependencies:

    • Tests require a running database (e.g., SQLite for CI):
      touch database/database.sqlite
      
  3. Service Initialization:

    • Some services (e.g., ContentService) may need manual setup:
      $this->getContainer()->get('ezpublish.api.service.content')->initialize();
      

Debugging

  • Enable Debug Mode:
    $this->getContainer()->get('ezpublish.api.service.content')->setDebug(true);
    
  • Log Output: Use Ibexa\Core\Base\Logger for test-specific logging.

Extension Points

  1. Custom Test Cases: Extend TestCase to add reusable methods:

    class CustomTestCase extends TestCase
    {
        protected function createUser(): User
        {
            return $this->createUser('test@example.com', ['admin']);
        }
    }
    
  2. 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);
    }
    
  3. Performance Testing: Use Ibexa\Core\Test\Performance\Benchmark for load testing:

    $benchmark = new Benchmark();
    $benchmark->run(function() {
        $this->createContent('article');
    });
    
Weaver

How can I help you explore Laravel packages today?

Conversation history is not saved when not logged in.
Prompt
Add packages to context
No packages found.
jayeshmepani/jpl-moshier-ephemeris-php
elnasnato/laraliveui
labrodev/rest-sdk
sampaui/sampaui
babelqueue/php-sdk
facebook/capi-param-builder-php
babelqueue/symfony
hamzi/corewatch
minionfactory/raw-hydrator
hexters/coinpayment
rjcodes/rjcms
act-training/laravel-permissions-manager
alimarchal/laravel-chart-of-accounts
babenkoivan/elastic-scout-driver
mkwebdesign/filament-watchdog-v5
renatomarinho/laravel-page-speed
zedmagdy/filament-business-hours
renatovdemoura/blade-elements-ui
devgeek/beacon-admin
benjamin-rqt/data-watcher-bundle