Spaces:
Sleeping
Sleeping
Download apps/php-sdk/tests/Unit/ParseTest.php from s-eto-hub/firecrawl-api: direct link, hf CLI and curl.
- Browser
- Download file 1.65 kB
-
https://huggingface.co/spaces/s-eto-hub/firecrawl-api/resolve/main/apps/php-sdk/tests/Unit/ParseTest.php
- Command line
-
hf download hf://spaces/s-eto-hub/firecrawl-api/apps/php-sdk/tests/Unit/ParseTest.php
-
curl -L -o ParseTest.php https://huggingface.co/spaces/s-eto-hub/firecrawl-api/resolve/main/apps/php-sdk/tests/Unit/ParseTest.php
1.65 kB
| declare(strict_types=1); | |
| use Firecrawl\Exceptions\FirecrawlException; | |
| use Firecrawl\Models\JsonFormat; | |
| use Firecrawl\Models\ParseFile; | |
| use Firecrawl\Models\ParseOptions; | |
| it('builds a ParseFile from bytes', function (): void { | |
| $file = ParseFile::fromBytes('doc.pdf', 'hello'); | |
| expect($file->getFilename())->toBe('doc.pdf'); | |
| expect($file->getContent())->toBe('hello'); | |
| }); | |
| it('rejects empty filename', function (): void { | |
| ParseFile::fromBytes(' ', 'hello'); | |
| })->throws(FirecrawlException::class); | |
| it('rejects empty content', function (): void { | |
| ParseFile::fromBytes('doc.pdf', ''); | |
| })->throws(FirecrawlException::class); | |
| it('serializes ParseOptions with JSON format', function (): void { | |
| $options = ParseOptions::with( | |
| formats: ['markdown', JsonFormat::with(prompt: 'Extract')], | |
| onlyMainContent: true, | |
| ); | |
| $array = $options->toArray(); | |
| expect($array['formats'][0])->toBe('markdown'); | |
| expect($array['formats'][1])->toMatchArray(['type' => 'json', 'prompt' => 'Extract']); | |
| expect($array['onlyMainContent'])->toBeTrue(); | |
| }); | |
| it('rejects unsupported parse formats', function (): void { | |
| ParseOptions::with(formats: ['screenshot']); | |
| })->throws(FirecrawlException::class); | |
| it('rejects video parse format', function (): void { | |
| ParseOptions::with(formats: ['video']); | |
| })->throws(FirecrawlException::class); | |
| it('rejects invalid proxy values', function (): void { | |
| ParseOptions::with(proxy: 'stealth'); | |
| })->throws(FirecrawlException::class); | |
| it('rejects non-positive timeout', function (): void { | |
| ParseOptions::with(timeout: 0); | |
| })->throws(FirecrawlException::class); | |