Part-DB.Part-DB-server/tests/Services/Misc/MySQLDumpXMLConverterTest.php
2023-03-25 00:25:18 +01:00

54 lines
1.8 KiB
PHP

<?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\ImportExportSystem\PartKeeprImporter\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']);
}
}