. */ declare(strict_types=1); namespace Fisharebest\Webtrees\Services; use Fisharebest\Webtrees\TestCase; /** * Test harness for the class GedcomEditService * * @covers \Fisharebest\Webtrees\Services\GedcomEditService */ class GedcomEditServiceTest extends TestCase { protected static bool $uses_database = true; /** * @covers \Fisharebest\Webtrees\Services\GedcomEditService::editLinesToGedcom */ public function testEditLinesToGedcom(): void { $gedcom_edit_service = new GedcomEditService(); static::assertSame( '1 BIRT Y', $gedcom_edit_service->editLinesToGedcom( 'INDI', ['1'], ['BIRT'], ['Y'], false ) ); static::assertSame( "\n1 BIRT Y\n2 ADDR England", $gedcom_edit_service->editLinesToGedcom( 'INDI', ['1', '2'], ['BIRT', 'ADDR'], ['Y', 'England'] ) ); static::assertSame( "\n1 BIRT\n2 PLAC England", $gedcom_edit_service->editLinesToGedcom( 'INDI', ['1', '2'], ['BIRT', 'PLAC'], ['Y', 'England'] ) ); static::assertSame( "\n1 BIRT\n2 PLAC England\n2 SOUR @S1@\n3 PAGE 123", $gedcom_edit_service->editLinesToGedcom( 'INDI', ['1', '2', '2', '3'], ['BIRT', 'PLAC', 'SOUR', 'PAGE'], ['Y', 'England', '@S1@', '123'] ) ); // Missing SOUR, so ignore PAGE static::assertSame( "\n1 BIRT\n2 PLAC England", $gedcom_edit_service->editLinesToGedcom( 'INDI', ['1', '2', '2', '3'], ['BIRT', 'PLAC', 'SOUR', 'PAGE'], ['Y', 'England', '', '123'] ) ); static::assertSame( "\n1 BIRT\n2 PLAC England", $gedcom_edit_service->editLinesToGedcom( 'INDI', ['1', '2', '2', '3'], ['BIRT', 'PLAC', 'SOUR', 'PAGE'], ['Y', 'England', '', '123'] ) ); static::assertSame( "\n1 BIRT\n2 PLAC England\n1 DEAT\n2 PLAC Scotland", $gedcom_edit_service->editLinesToGedcom( 'INDI', ['1', '2', '2', '3', '1', '2', '2', '3'], ['BIRT', 'PLAC', 'SOUR', 'PAGE', 'DEAT', 'PLAC', 'SOUR', 'PAGE'], ['Y', 'England', '', '123', 'Y', 'Scotland', '', '123'] ) ); } }