Skip to content

Commit 5a66ed3

Browse files
committed
fix: remove kreuzberg-tesseract version constraint and add PHP test assertions
1 parent 6eb27c0 commit 5a66ed3

File tree

3 files changed

+29
-4
lines changed

3 files changed

+29
-4
lines changed

crates/kreuzberg/Cargo.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -173,7 +173,7 @@ rst_parser = { version = "0.4", optional = true }
173173
fb2 = { version = "0.4", optional = true }
174174
typst-syntax = { version = "0.14", optional = true }
175175

176-
kreuzberg-tesseract = { path = "../kreuzberg-tesseract", version = "4.0", optional = true }
176+
kreuzberg-tesseract = { path = "../kreuzberg-tesseract", optional = true }
177177
image = { workspace = true, default-features = false, features = [
178178
"png",
179179
"jpeg",

packages/php/tests/Integration/ImageExtractionTest.php

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -543,6 +543,11 @@ public function it_returns_empty_array_for_documents_without_images(): void
543543
$result = $kreuzberg->extractFile($filePath);
544544

545545
// Images should be null or empty array for documents without images
546+
$this->assertTrue(
547+
$result->images === null || is_array($result->images),
548+
'Images should be null or array',
549+
);
550+
546551
if ($result->images !== null) {
547552
$this->assertIsArray(
548553
$result->images,
@@ -578,6 +583,11 @@ public function it_skips_image_extraction_when_disabled(): void
578583
$result = $kreuzberg->extractFile($pdfFiles[0]);
579584

580585
// When disabled, images should be null or empty
586+
$this->assertTrue(
587+
$result->images === null || (is_array($result->images) && empty($result->images)),
588+
'Images should be null or empty array when extraction is disabled',
589+
);
590+
581591
if ($result->images !== null) {
582592
$this->assertEmpty(
583593
$result->images,

packages/php/tests/Integration/KeywordExtractionTest.php

Lines changed: 18 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -244,12 +244,27 @@ public function it_returns_readonly_keyword_objects(): void
244244
$kreuzberg = new Kreuzberg($config);
245245
$result = $kreuzberg->extractFile($filePath);
246246

247+
// Verify keywords array exists and is populated
248+
$this->assertNotNull($result->keywords, 'Keywords should not be null');
249+
$this->assertIsArray($result->keywords, 'Keywords should be an array');
250+
$this->assertNotEmpty($result->keywords, 'Should return at least one keyword');
251+
247252
if (!empty($result->keywords)) {
248253
$keyword = $result->keywords[0];
249254

250-
// Verify readonly by attempting to access and verify immutability
251-
$this->assertIsString($keyword->text ?? '');
252-
$this->assertIsFloat($keyword->score ?? 0.0);
255+
// Verify readonly by checking that objects have expected properties
256+
$this->assertTrue(
257+
property_exists($keyword, 'text'),
258+
'Keyword object should have text property',
259+
);
260+
$this->assertTrue(
261+
property_exists($keyword, 'score'),
262+
'Keyword object should have score property',
263+
);
264+
265+
// Verify property types
266+
$this->assertIsString($keyword->text, 'Keyword text should be a string');
267+
$this->assertIsFloat($keyword->score, 'Keyword score should be a float');
253268
}
254269
}
255270

0 commit comments

Comments
 (0)