Files
fil/e2e/php/tests/MimeUtilitiesTest.php

63 lines
1.8 KiB
PHP
Raw Permalink Normal View History

2026-06-01 23:40:55 +02:00
<?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: mime_utilities. */
final class MimeUtilitiesTest extends TestCase
{
/** Detect MIME type from file bytes */
public function test_mime_detect_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::detectMimeTypeFromBytes($contentBytes);
$this->assertStringContainsString("pdf", $result);
}
/** Detect MIME type from PNG image bytes */
public function test_mime_detect_image(): void
{
$contentBytes = file_get_contents("images/test_hello_world.png");
if ($contentBytes === false) { $this->fail("failed to read fixture: images/test_hello_world.png"); }
$result = Kreuzberg::detectMimeTypeFromBytes($contentBytes);
$this->assertStringContainsString("png", $result);
}
/** Get file extensions for a MIME type */
public function test_mime_get_extensions(): void
{
$result = Kreuzberg::getExtensionsForMime("application/pdf");
$found = false;
foreach ($result as $item) {
$itemStr = is_object($item) ? json_encode($item) : (string)$item;
if (stripos($itemStr, "pdf") !== false) { $found = true; }
}
$this->assertTrue($found, 'expected array to contain string');
}
}