Files
firecrawl/apps/php-sdk/tests/Unit/ProteinLookupTest.php
Karan LokchandaniandKris Oei 58d8c4bfab feat(sdks): add protein lookup to all SDKs (#5722)
* feat(sdks): add protein lookup to the Python and JS SDKs

* fix(sdks): restore the research_docs header, split the notice sentence, reuse RESEARCH_METHODS

The research_docs module docstring keeps main's wording and line breaks except for the added lookup_protein and five to six. The README notice line becomes two sentences. The sync and async client method checks now loop over RESEARCH_METHODS, so they cover lookup_protein.

* fix(sdks): keep the API's error message and code on research request failures

* feat(sdks): add protein lookup to the PHP, Ruby and Elixir SDKs

Add lookupProtein (PHP), lookup_protein (Ruby) and lookup_protein (Elixir), which call GET /v2/search/research/proteins with protein and an optional organism. The Elixir method sits in the hand-written region beside the paper methods, and generate.exs lists its route so a regenerate from the public spec emits no second definition.

* test(sdks): cover the protein lookup query in Ruby and PHP, document notice

Each test checks the path and that protein, origin and organism (only when set) reach the query string. The PHP, Ruby and Elixir doc comments now say the response's notice is the UniProt credit and license to show with the results.

* feat(sdks): add protein lookup to the Go, Rust, Java and .NET SDKs

* fix(sdks): rename GoTerm to ProteinGoTerm and cover origin and not_found

Rename the GO term type to ProteinGoTerm in the Go, Rust, Java and .NET
SDKs to match the other protein types and the JS SDK. Document that
notice carries UniProt's credit and CC BY 4.0 license. The protein tests
now assert that origin is sent, and the Rust test decodes a not_found
body.

---------

Co-authored-by: Kris Oei <oei.kris71@gmail.com>
2026-11-16 11:47:40 -08:00

30 lines
1.1 KiB
PHP

<?php
declare(strict_types=1);
use Firecrawl\Version;
use GuzzleHttp\Psr7\Response;
it('sends the protein, the organism when set and the origin as query parameters', function (): void {
$history = new ArrayObject();
$client = fakeFirecrawlClient([
new Response(200, [], json_encode(['success' => true, 'match' => 'found'])),
new Response(200, [], json_encode(['success' => true, 'match' => 'found'])),
], $history);
$client->lookupProtein('TP53', ['organism' => 'human']);
$client->lookupProtein('P04637');
$origin = 'php-sdk@' . Version::SDK_VERSION;
$withOrganism = $history[0]['request']->getUri();
expect($withOrganism->getPath())->toBe('/v2/search/research/proteins');
parse_str($withOrganism->getQuery(), $query);
expect($query)->toEqual(['protein' => 'TP53', 'organism' => 'human', 'origin' => $origin]);
$withoutOrganism = $history[1]['request']->getUri();
expect($withoutOrganism->getPath())->toBe('/v2/search/research/proteins');
parse_str($withoutOrganism->getQuery(), $query);
expect($query)->toEqual(['protein' => 'P04637', 'origin' => $origin]);
});