<?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: async. */
final class AsyncTest extends TestCase
{

    /** Async extract_bytes call on PDF document */
    public function test_async_extract_bytes(): void
    {
        $contentBytes = file_get_contents("pdf/fake_memo.pdf");
        if ($contentBytes === false) { $this->fail("failed to read fixture: pdf/fake_memo.pdf"); }
        $result = Kreuzberg::extractBytes($contentBytes, "application/pdf", \Kreuzberg\ExtractionConfig::from_json('{}'));

            $this->assertEquals("application/pdf", trim($result->mimeType));
            $this->assertGreaterThanOrEqual(50, strlen($result->getContent()));


    }


    /** extract_bytes empty MIME async */
    public function test_async_extract_bytes_empty_mime(): void
    {
        $this->expectException(\Exception::class);        $contentBytes = file_get_contents("text/plain.txt");
        if ($contentBytes === false) { $this->fail("failed to read fixture: text/plain.txt"); }
        $config = \Kreuzberg\ExtractionConfig::from_json('{}');
        Kreuzberg::extractBytes($contentBytes, "", $config);
    }


    /** extract_bytes unsupported MIME async */
    public function test_async_extract_bytes_invalid_mime(): void
    {
        $this->expectException(\Exception::class);        $contentBytes = file_get_contents("text/plain.txt");
        if ($contentBytes === false) { $this->fail("failed to read fixture: text/plain.txt"); }
        $config = \Kreuzberg\ExtractionConfig::from_json('{}');
        Kreuzberg::extractBytes($contentBytes, "application/x-nonexistent", $config);
    }

}
