batchProcessor = $this->getContainer()->get(BatchProcessor::class); } public function test_processes_multiple_operations_in_batch(): void { // Create batch request with multiple operations $operations = [ BatchOperation::fromArray([ 'componentId' => 'counter:test1', 'method' => 'increment', 'params' => ['amount' => 1], ]), BatchOperation::fromArray([ 'componentId' => 'counter:test2', 'method' => 'increment', 'params' => ['amount' => 2], ]), ]; $batchRequest = new BatchRequest(...$operations); $response = $this->batchProcessor->process($batchRequest); $this->assertEquals(2, $response->totalOperations); $this->assertEquals(2, $response->successCount); $this->assertEquals(0, $response->failureCount); $this->assertTrue($response->isFullSuccess()); } public function test_handles_partial_failures_gracefully(): void { // Create batch with one valid and one invalid operation $operations = [ BatchOperation::fromArray([ 'componentId' => 'counter:test1', 'method' => 'increment', 'params' => ['amount' => 1], ]), BatchOperation::fromArray([ 'componentId' => 'nonexistent:test', 'method' => 'increment', 'params' => [], ]), ]; $batchRequest = new BatchRequest(...$operations); $response = $this->batchProcessor->process($batchRequest); $this->assertEquals(2, $response->totalOperations); $this->assertEquals(1, $response->successCount); $this->assertEquals(1, $response->failureCount); $this->assertTrue($response->hasPartialFailure()); } public function test_supports_fragments_in_batch_operations(): void { $operations = [ BatchOperation::fromArray([ 'componentId' => 'counter:test1', 'method' => 'increment', 'params' => ['amount' => 5], 'fragments' => ['counter-display'], ]), ]; $batchRequest = new BatchRequest(...$operations); $response = $this->batchProcessor->process($batchRequest); $this->assertEquals(1, $response->successCount); $result = $response->getSuccessfulResults()[0]; $this->assertTrue($result->hasFragments()); $this->assertArrayHasKey('counter-display', $result->fragments); } }