mirror of
https://github.com/Part-DB/Part-DB-server.git
synced 2025-12-07 11:39:30 +00:00
Some checks are pending
Build assets artifact / Build assets artifact (push) Waiting to run
Docker Image Build / docker (push) Waiting to run
Docker Image Build (FrankenPHP) / docker (push) Waiting to run
Static analysis / Static analysis (push) Waiting to run
PHPUnit Tests / PHPUnit and coverage Test (PHP 8.2, mysql) (push) Waiting to run
PHPUnit Tests / PHPUnit and coverage Test (PHP 8.3, mysql) (push) Waiting to run
PHPUnit Tests / PHPUnit and coverage Test (PHP 8.4, mysql) (push) Waiting to run
PHPUnit Tests / PHPUnit and coverage Test (PHP 8.5, mysql) (push) Waiting to run
PHPUnit Tests / PHPUnit and coverage Test (PHP 8.2, postgres) (push) Waiting to run
PHPUnit Tests / PHPUnit and coverage Test (PHP 8.3, postgres) (push) Waiting to run
PHPUnit Tests / PHPUnit and coverage Test (PHP 8.4, postgres) (push) Waiting to run
PHPUnit Tests / PHPUnit and coverage Test (PHP 8.5, postgres) (push) Waiting to run
PHPUnit Tests / PHPUnit and coverage Test (PHP 8.2, sqlite) (push) Waiting to run
PHPUnit Tests / PHPUnit and coverage Test (PHP 8.3, sqlite) (push) Waiting to run
PHPUnit Tests / PHPUnit and coverage Test (PHP 8.4, sqlite) (push) Waiting to run
PHPUnit Tests / PHPUnit and coverage Test (PHP 8.5, sqlite) (push) Waiting to run
This makes PR #1110 obsolete
72 lines
2.9 KiB
PHP
72 lines
2.9 KiB
PHP
<?php
|
|
/*
|
|
* This file is part of Part-DB (https://github.com/Part-DB/Part-DB-symfony).
|
|
*
|
|
* Copyright (C) 2019 - 2025 Jan Böhmer (https://github.com/jbtronics)
|
|
*
|
|
* This program is free software: you can redistribute it and/or modify
|
|
* it under the terms of the GNU Affero General Public License as published
|
|
* by the Free Software Foundation, either version 3 of the License, or
|
|
* (at your option) any later version.
|
|
*
|
|
* This program is distributed in the hope that it will be useful,
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
* GNU Affero General Public License for more details.
|
|
*
|
|
* You should have received a copy of the GNU Affero General Public License
|
|
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
|
*/
|
|
|
|
namespace App\Tests\Services\InfoProviderSystem\DTOs;
|
|
|
|
use App\Services\InfoProviderSystem\DTOs\BulkSearchFieldMappingDTO;
|
|
use PHPUnit\Framework\TestCase;
|
|
|
|
class BulkSearchFieldMappingDTOTest extends TestCase
|
|
{
|
|
|
|
public function testProviderInstanceNormalization(): void
|
|
{
|
|
$mockProvider = $this->createMock(\App\Services\InfoProviderSystem\Providers\InfoProviderInterface::class);
|
|
$mockProvider->method('getProviderKey')->willReturn('mock_provider');
|
|
|
|
$fieldMapping = new BulkSearchFieldMappingDTO(field: 'mpn', providers: ['provider1', $mockProvider], priority: 5);
|
|
$this->assertSame(['provider1', 'mock_provider'], $fieldMapping->providers);
|
|
}
|
|
|
|
public function testIsSupplierPartNumberField(): void
|
|
{
|
|
$fieldMapping = new BulkSearchFieldMappingDTO(field: 'reichelt_spn', providers: ['provider1'], priority: 1);
|
|
$this->assertTrue($fieldMapping->isSupplierPartNumberField());
|
|
|
|
$fieldMapping = new BulkSearchFieldMappingDTO(field: 'partNumber', providers: ['provider1'], priority: 1);
|
|
$this->assertFalse($fieldMapping->isSupplierPartNumberField());
|
|
}
|
|
|
|
public function testToSerializableArray(): void
|
|
{
|
|
$fieldMapping = new BulkSearchFieldMappingDTO(field: 'test', providers: ['provider1', 'provider2'], priority: 3);
|
|
$array = $fieldMapping->toSerializableArray();
|
|
$this->assertIsArray($array);
|
|
$this->assertSame([
|
|
'field' => 'test',
|
|
'providers' => ['provider1', 'provider2'],
|
|
'priority' => 3,
|
|
], $array);
|
|
}
|
|
|
|
public function testFromSerializableArray(): void
|
|
{
|
|
$data = [
|
|
'field' => 'test',
|
|
'providers' => ['provider1', 'provider2'],
|
|
'priority' => 3,
|
|
];
|
|
$fieldMapping = BulkSearchFieldMappingDTO::fromSerializableArray($data);
|
|
$this->assertInstanceOf(BulkSearchFieldMappingDTO::class, $fieldMapping);
|
|
$this->assertSame('test', $fieldMapping->field);
|
|
$this->assertSame(['provider1', 'provider2'], $fieldMapping->providers);
|
|
$this->assertSame(3, $fieldMapping->priority);
|
|
}
|
|
}
|