MockedServiceOnSetUpInterface. This aligns well with Laravel’s testing ecosystem (PHPUnit, Mockery) but requires Symfony-specific adaptations.AppKernel.php and config_test.yml) makes direct Laravel integration non-trivial. Laravel uses autoloading and service containers differently (e.g., no AppKernel, YAML configs are replaced by PHP arrays or annotations).HttpClient, SnappyPDF equivalents).DatabaseSeeder/Factories), but requires manual mapping of DoctrineFixturesBundle to Laravel’s Migrations/Seeders.bind()/singleton(); Symfony uses XML/YAML/annotations. The bundle’s MockedServiceOnSetUpInterface would need a Laravel-compatible adapter (e.g., a TestingServiceProvider).config_test.yml → Laravel’s config/testing.php or environment-specific bindings.LiipFunctionalTestBundle is irrelevant to Laravel; focus on Laravel’s HttpTests/FeatureTests.getMockedServices()) is directly applicable.ContainerAware or event system (e.g., kernel.request events).ServiceProvider lifecycle.phpunit.xml lacks Symfony’s LiipFunctionalTestBundle; functional tests would require manual setup (e.g., createApplication() in Laravel’s TestCase).DatabaseSeeder or Factory classes (e.g., create() in DatabaseSeeder).laravel-shift/laravel-test-helpers, spatie/laravel-mock-factories) first.KnpSnappy, Guzzle)? Can Laravel’s native Mockery or Http::fake() suffice?LiipFunctionalTestBundle is irrelevant)?mockery/dms, orchestra/testbench) that avoid Symfony bloat?AppKernel.php with a custom ServiceProvider to register the bundle’s logic. Example:
namespace App\Providers;
use Chaplean\Bundle\UnitBundle\MockedServiceOnSetUpInterface;
use Illuminate\Support\ServiceProvider;
class ChapleanUnitServiceProvider extends ServiceProvider {
public function register() {
$this->app->singleton(MockedServiceOnSetUpInterface::class, function () {
return new App\Tests\MockService(); // User-provided mock class
});
}
}
config_test.yml to Laravel’s config/testing.php:
// config/testing.php
'chaplean_unit' => [
'mocked_service' => App\Tests\MockService::class,
],
TestCase with Mockery (already supported). The bundle’s getMockedServices() can be called in setUp():
public function setUp(): void {
parent::setUp();
$mocks = (new App\Tests\MockService())->getMockedServices();
foreach ($mocks as $id => $mock) {
$this->app->instance($id, $mock);
}
}
DoctrineFixturesBundle with Laravel’s DatabaseSeeder or Factory classes. Example:
// database/seeds/DatabaseSeeder.php
public function run() {
\App\Models\User::factory()->create(); // Laravel Factory
}
Phase 1: Mock Service Injection
ServiceProvider to register the MockedServiceOnSetUpInterface.config_test.yml with Laravel’s config/testing.php.phpunit.xml to extend Laravel’s TestCase and call getMockedServices() in setUp().Phase 2: Fixture Integration (Optional)
DoctrineFixturesBundle logic to Laravel’s Factory classes or DatabaseSeeder.// Database/factories/UserFactory.php
return [
'name' => 'Test User',
'email' => '[email protected]',
];
Phase 3: Testing Adaptation
LiipFunctionalTestBundle with Laravel’s HttpTests/FeatureTests.public function testExample() {
$response = $this->get('/endpoint');
$response->assertStatus(200);
}
app->bind()).LiipFunctionalTestBundle, DoctrineFixturesBundle are irrelevant and must be replaced.kernel.request events → Laravel’s Events::dispatch() or middleware.getMockedServices()) is the primary goal (proceed) or if Laravel’s built-in tools suffice.ServiceProvider to handle MockedServiceOnSetUpInterface.phpunit.xml to extend Laravel’s TestCase.LiipFunctionalTestBundle (use Laravel’s HttpTests).DoctrineFixturesBundle with Factories/Seeders.FeatureTests.AppKernel → ServiceProvider).ServiceProvider logic ties the team to the bundle’s design, making future migrations harder.How can I help you explore Laravel packages today?