215 lines
7.9 KiB
PHP
Generated
215 lines
7.9 KiB
PHP
Generated
<?php
|
|
// This file is auto-generated by alef — DO NOT EDIT.
|
|
// alef:hash:4e15143f4af1ae8bafbdb1506ef057da924484c66a19483966333558ad437e75
|
|
// To regenerate: alef generate
|
|
// To verify freshness: alef verify --exit-code
|
|
// Issues & docs: https://github.com/kreuzberg-dev/alef
|
|
|
|
|
|
declare(strict_types=1);
|
|
|
|
namespace Kreuzberg\E2e;
|
|
|
|
use PHPUnit\Framework\TestCase;
|
|
use Kreuzberg\Kreuzberg;
|
|
use Kreuzberg\ExtractionConfig;
|
|
|
|
/** E2e tests for category: plugin_api. */
|
|
final class PluginApiTest extends TestCase
|
|
{
|
|
|
|
/** register_document_extractor: trait bridge */
|
|
public function test_register_document_extractor_trait_bridge(): void
|
|
{
|
|
$stub = new class implements \Kreuzberg\DocumentExtractor {
|
|
public function name(): string { return 'test-extractor'; }
|
|
public function extract_bytes($content, $mime_type, $config): mixed { return '{}'; }
|
|
public function extract_file($path, $mime_type, $config): mixed { return '{}'; }
|
|
public function supported_mime_types(): mixed { return []; }
|
|
public function priority(): mixed { return 1; }
|
|
public function can_handle($_path, $_mime_type): mixed { return false; }
|
|
public function version(): mixed { return ''; }
|
|
public function initialize(): mixed { return null; }
|
|
public function shutdown(): mixed { return null; }
|
|
public function description(): mixed { return ''; }
|
|
public function author(): mixed { return ''; }
|
|
};
|
|
$this->expectNotToPerformAssertions();
|
|
$result = Kreuzberg::registerDocumentExtractor($stub);
|
|
|
|
|
|
Kreuzberg::unregisterDocumentExtractor("test-extractor");
|
|
|
|
}
|
|
|
|
|
|
/** register_embedding_backend: trait bridge */
|
|
public function test_register_embedding_backend_trait_bridge(): void
|
|
{
|
|
$stub = new class implements \Kreuzberg\EmbeddingBackend {
|
|
public function name(): string { return 'test-embedding-backend'; }
|
|
public function dimensions(): mixed { return 1; }
|
|
public function embed($texts): mixed { return []; }
|
|
public function version(): mixed { return ''; }
|
|
public function initialize(): mixed { return null; }
|
|
public function shutdown(): mixed { return null; }
|
|
public function description(): mixed { return ''; }
|
|
public function author(): mixed { return ''; }
|
|
};
|
|
$this->expectNotToPerformAssertions();
|
|
$result = Kreuzberg::registerEmbeddingBackend($stub);
|
|
|
|
|
|
Kreuzberg::unregisterEmbeddingBackend("test-embedding-backend");
|
|
|
|
}
|
|
|
|
|
|
/** register_ocr_backend: trait bridge */
|
|
public function test_register_ocr_backend_trait_bridge(): void
|
|
{
|
|
$stub = new class implements \Kreuzberg\OcrBackend {
|
|
public function name(): string { return 'test-backend'; }
|
|
public function process_image($image_bytes, $config): mixed { return '{}'; }
|
|
public function process_image_file($path, $config): mixed { return '{}'; }
|
|
public function supports_language($lang): mixed { return false; }
|
|
public function backend_type(): mixed { return '{}'; }
|
|
public function supported_languages(): mixed { return []; }
|
|
public function supports_table_detection(): mixed { return false; }
|
|
public function supports_document_processing(): mixed { return false; }
|
|
public function process_document($_path, $_config): mixed { return '{}'; }
|
|
public function version(): mixed { return ''; }
|
|
public function initialize(): mixed { return null; }
|
|
public function shutdown(): mixed { return null; }
|
|
public function description(): mixed { return ''; }
|
|
public function author(): mixed { return ''; }
|
|
};
|
|
$this->expectNotToPerformAssertions();
|
|
$result = Kreuzberg::registerOcrBackend($stub);
|
|
|
|
|
|
Kreuzberg::unregisterOcrBackend("test-backend");
|
|
|
|
}
|
|
|
|
|
|
/** register_post_processor: trait bridge */
|
|
public function test_register_post_processor_trait_bridge(): void
|
|
{
|
|
$stub = new class implements \Kreuzberg\PostProcessor {
|
|
public function name(): string { return 'test-processor'; }
|
|
public function process($result, $config): mixed { return null; }
|
|
public function processing_stage(): mixed { return '{}'; }
|
|
public function should_process($_result, $_config): mixed { return false; }
|
|
public function estimated_duration_ms($_result): mixed { return 1; }
|
|
public function priority(): mixed { return 1; }
|
|
public function version(): mixed { return ''; }
|
|
public function initialize(): mixed { return null; }
|
|
public function shutdown(): mixed { return null; }
|
|
public function description(): mixed { return ''; }
|
|
public function author(): mixed { return ''; }
|
|
};
|
|
$this->expectNotToPerformAssertions();
|
|
$result = Kreuzberg::registerPostProcessor($stub);
|
|
|
|
|
|
Kreuzberg::unregisterPostProcessor("test-processor");
|
|
|
|
}
|
|
|
|
|
|
/** register_renderer: trait bridge */
|
|
public function test_register_renderer_trait_bridge(): void
|
|
{
|
|
$stub = new class implements \Kreuzberg\Renderer {
|
|
public function name(): string { return 'test-renderer'; }
|
|
public function render($doc): mixed { return ''; }
|
|
public function version(): mixed { return ''; }
|
|
public function initialize(): mixed { return null; }
|
|
public function shutdown(): mixed { return null; }
|
|
public function description(): mixed { return ''; }
|
|
public function author(): mixed { return ''; }
|
|
};
|
|
$this->expectNotToPerformAssertions();
|
|
$result = Kreuzberg::registerRenderer($stub);
|
|
|
|
|
|
Kreuzberg::unregisterRenderer("test-renderer");
|
|
|
|
}
|
|
|
|
|
|
/** register_validator: trait bridge */
|
|
public function test_register_validator_trait_bridge(): void
|
|
{
|
|
$stub = new class implements \Kreuzberg\Validator {
|
|
public function name(): string { return 'test-validator'; }
|
|
public function validate($result, $config): mixed { return null; }
|
|
public function should_validate($_result, $_config): mixed { return false; }
|
|
public function priority(): mixed { return 1; }
|
|
public function version(): mixed { return ''; }
|
|
public function initialize(): mixed { return null; }
|
|
public function shutdown(): mixed { return null; }
|
|
public function description(): mixed { return ''; }
|
|
public function author(): mixed { return ''; }
|
|
};
|
|
$this->expectNotToPerformAssertions();
|
|
$result = Kreuzberg::registerValidator($stub);
|
|
|
|
|
|
Kreuzberg::unregisterValidator("test-validator");
|
|
|
|
}
|
|
|
|
|
|
/** unregister_document_extractor */
|
|
public function test_unregister_document_extractor_after_register(): void
|
|
{
|
|
$this->expectNotToPerformAssertions();
|
|
$result = Kreuzberg::unregisterDocumentExtractor("test-extractor");
|
|
|
|
|
|
}
|
|
|
|
|
|
/** unregister_embedding_backend */
|
|
public function test_unregister_embedding_backend_after_register(): void
|
|
{
|
|
$this->expectNotToPerformAssertions();
|
|
$result = Kreuzberg::unregisterEmbeddingBackend("test-embedding-backend");
|
|
|
|
|
|
}
|
|
|
|
|
|
/** unregister_post_processor */
|
|
public function test_unregister_post_processor_after_register(): void
|
|
{
|
|
$this->expectNotToPerformAssertions();
|
|
$result = Kreuzberg::unregisterPostProcessor("test-processor");
|
|
|
|
|
|
}
|
|
|
|
|
|
/** unregister_renderer */
|
|
public function test_unregister_renderer_after_register(): void
|
|
{
|
|
$this->expectNotToPerformAssertions();
|
|
$result = Kreuzberg::unregisterRenderer("test-renderer");
|
|
|
|
|
|
}
|
|
|
|
|
|
/** unregister_validator */
|
|
public function test_unregister_validator_after_register(): void
|
|
{
|
|
$this->expectNotToPerformAssertions();
|
|
$result = Kreuzberg::unregisterValidator("test-validator");
|
|
|
|
|
|
}
|
|
|
|
}
|