mirror of
https://github.com/Part-DB/Part-DB-server.git
synced 2025-06-28 04:30:08 +02:00
Started to work on an import possibility for Partkeepr databases
This commit is contained in:
parent
0550c045c7
commit
fce32e70b9
7 changed files with 9365 additions and 1 deletions
54
tests/Services/Misc/MySQLDumpXMLConverterTest.php
Normal file
54
tests/Services/Misc/MySQLDumpXMLConverterTest.php
Normal file
|
@ -0,0 +1,54 @@
|
|||
<?php
|
||||
/*
|
||||
* This file is part of Part-DB (https://github.com/Part-DB/Part-DB-symfony).
|
||||
*
|
||||
* Copyright (C) 2019 - 2023 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\Misc;
|
||||
|
||||
use App\Services\Misc\MySQLDumpXMLConverter;
|
||||
use PHPUnit\Framework\TestCase;
|
||||
|
||||
class MySQLDumpXMLConverterTest extends TestCase
|
||||
{
|
||||
|
||||
public function testConvertMySQLDumpXMLDataToArrayStructure()
|
||||
{
|
||||
$service = new MySQLDumpXMLConverter();
|
||||
|
||||
//Load the test XML file
|
||||
$xml_string = file_get_contents(__DIR__.'/../../assets/partkeepr_import_test.xml');
|
||||
|
||||
$result = $service->convertMySQLDumpXMLDataToArrayStructure($xml_string);
|
||||
|
||||
//Check that the result is an array
|
||||
$this->assertIsArray($result);
|
||||
|
||||
//Must contain 36 tables
|
||||
$this->assertCount(50, $result);
|
||||
|
||||
//Must have a table called "footprints"
|
||||
$this->assertArrayHasKey('footprint', $result);
|
||||
|
||||
//Must have 36 entry in the "footprints" table
|
||||
$this->assertCount(36, $result['footprint']);
|
||||
|
||||
$this->assertSame('1', $result['footprint'][0]['id']);
|
||||
$this->assertSame('CBGA-32', $result['footprint'][0]['name']);
|
||||
|
||||
}
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue