mirror of
https://github.com/Part-DB/Part-DB-server.git
synced 2026-02-15 14:09:36 +00:00
Implement URLHandlerInfoProviderInterface in BuerklinProvider (#1235)
Some checks failed
Build assets artifact / Build assets artifact (push) Has been cancelled
Docker Image Build / docker (push) Has been cancelled
Docker Image Build (FrankenPHP) / docker (push) Has been cancelled
Static analysis / Static analysis (push) Has been cancelled
PHPUnit Tests / PHPUnit and coverage Test (PHP 8.2, mysql) (push) Has been cancelled
PHPUnit Tests / PHPUnit and coverage Test (PHP 8.3, mysql) (push) Has been cancelled
PHPUnit Tests / PHPUnit and coverage Test (PHP 8.4, mysql) (push) Has been cancelled
PHPUnit Tests / PHPUnit and coverage Test (PHP 8.5, mysql) (push) Has been cancelled
PHPUnit Tests / PHPUnit and coverage Test (PHP 8.2, postgres) (push) Has been cancelled
PHPUnit Tests / PHPUnit and coverage Test (PHP 8.3, postgres) (push) Has been cancelled
PHPUnit Tests / PHPUnit and coverage Test (PHP 8.4, postgres) (push) Has been cancelled
PHPUnit Tests / PHPUnit and coverage Test (PHP 8.5, postgres) (push) Has been cancelled
PHPUnit Tests / PHPUnit and coverage Test (PHP 8.2, sqlite) (push) Has been cancelled
PHPUnit Tests / PHPUnit and coverage Test (PHP 8.3, sqlite) (push) Has been cancelled
PHPUnit Tests / PHPUnit and coverage Test (PHP 8.4, sqlite) (push) Has been cancelled
PHPUnit Tests / PHPUnit and coverage Test (PHP 8.5, sqlite) (push) Has been cancelled
Some checks failed
Build assets artifact / Build assets artifact (push) Has been cancelled
Docker Image Build / docker (push) Has been cancelled
Docker Image Build (FrankenPHP) / docker (push) Has been cancelled
Static analysis / Static analysis (push) Has been cancelled
PHPUnit Tests / PHPUnit and coverage Test (PHP 8.2, mysql) (push) Has been cancelled
PHPUnit Tests / PHPUnit and coverage Test (PHP 8.3, mysql) (push) Has been cancelled
PHPUnit Tests / PHPUnit and coverage Test (PHP 8.4, mysql) (push) Has been cancelled
PHPUnit Tests / PHPUnit and coverage Test (PHP 8.5, mysql) (push) Has been cancelled
PHPUnit Tests / PHPUnit and coverage Test (PHP 8.2, postgres) (push) Has been cancelled
PHPUnit Tests / PHPUnit and coverage Test (PHP 8.3, postgres) (push) Has been cancelled
PHPUnit Tests / PHPUnit and coverage Test (PHP 8.4, postgres) (push) Has been cancelled
PHPUnit Tests / PHPUnit and coverage Test (PHP 8.5, postgres) (push) Has been cancelled
PHPUnit Tests / PHPUnit and coverage Test (PHP 8.2, sqlite) (push) Has been cancelled
PHPUnit Tests / PHPUnit and coverage Test (PHP 8.3, sqlite) (push) Has been cancelled
PHPUnit Tests / PHPUnit and coverage Test (PHP 8.4, sqlite) (push) Has been cancelled
PHPUnit Tests / PHPUnit and coverage Test (PHP 8.5, sqlite) (push) Has been cancelled
* Implement URLHandlerInfoProviderInterface in BuerklinProvider
Added URL handling capabilities to BuerklinProvider.
* Refactor ID extraction logic in BuerklinProvider
* Add tests for BuerklinProvider URLHandlerInfoProviderInterface
* Revert "Refactor ID extraction logic in BuerklinProvider"
This reverts commit 5f65176636.
* Exclude 'p' from valid ID return in BuerklinProvider
This commit is contained in:
parent
c2a51e57b7
commit
41252d8bb9
2 changed files with 108 additions and 1 deletions
|
|
@ -268,4 +268,80 @@ class BuerklinProviderTest extends TestCase
|
|||
$this->assertSame('PartX', $dto->name);
|
||||
$this->assertSame('https://img', $dto->preview_image_url);
|
||||
}
|
||||
public function testGetHandledDomains(): void
|
||||
{
|
||||
$this->assertSame(['buerklin.com'], $this->provider->getHandledDomains());
|
||||
}
|
||||
|
||||
/**
|
||||
* @dataProvider buerklinIdFromUrlProvider
|
||||
*/
|
||||
public function testGetIDFromURLExtractsId(string $url, ?string $expected): void
|
||||
{
|
||||
$this->assertSame($expected, $this->provider->getIDFromURL($url));
|
||||
}
|
||||
|
||||
public static function buerklinIdFromUrlProvider(): array
|
||||
{
|
||||
return [
|
||||
'de long path' => [
|
||||
'https://www.buerklin.com/de/p/bkl-electronic/niedervoltsteckverbinder/072341-l/40F1332/',
|
||||
'40F1332',
|
||||
],
|
||||
'de short path' => [
|
||||
'https://www.buerklin.com/de/p/40F1332/',
|
||||
'40F1332',
|
||||
],
|
||||
'en long path' => [
|
||||
'https://www.buerklin.com/en/p/bkl-electronic/dc-connectors/072341-l/40F1332/',
|
||||
'40F1332',
|
||||
],
|
||||
'en short path' => [
|
||||
'https://www.buerklin.com/en/p/40F1332/',
|
||||
'40F1332',
|
||||
],
|
||||
'fragment should be ignored' => [
|
||||
'https://www.buerklin.com/de/p/bkl-electronic/niedervoltsteckverbinder/072341-l/40F1332/#download',
|
||||
'40F1332',
|
||||
],
|
||||
'no trailing slash' => [
|
||||
'https://www.buerklin.com/en/p/40F1332',
|
||||
'40F1332',
|
||||
],
|
||||
'query should be ignored' => [
|
||||
'https://www.buerklin.com/en/p/40F1332/?foo=bar',
|
||||
'40F1332',
|
||||
],
|
||||
'query and fragment should be ignored' => [
|
||||
'https://www.buerklin.com/en/p/40F1332/?foo=bar#download',
|
||||
'40F1332',
|
||||
],
|
||||
|
||||
// Negative cases
|
||||
'not a product url (no /p/ segment)' => [
|
||||
'https://www.buerklin.com/de/impressum/',
|
||||
null,
|
||||
],
|
||||
'path contains "p" but not "/p/"' => [
|
||||
'https://www.buerklin.com/de/help/price/',
|
||||
null,
|
||||
],
|
||||
'ends with /p/ (no id)' => [
|
||||
'https://www.buerklin.com/de/p/',
|
||||
null,
|
||||
],
|
||||
'ends with /p (no trailing slash)' => [
|
||||
'https://www.buerklin.com/de/p',
|
||||
null,
|
||||
],
|
||||
'empty string' => [
|
||||
'',
|
||||
null,
|
||||
],
|
||||
'not a url string' => [
|
||||
'not a url',
|
||||
null,
|
||||
],
|
||||
];
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue