1cb62cb3cSGreg Roach<?php 2cb62cb3cSGreg Roach 3cb62cb3cSGreg Roach/** 4cb62cb3cSGreg Roach * webtrees: online genealogy 55bfc6897SGreg Roach * Copyright (C) 2022 webtrees development team 6cb62cb3cSGreg Roach * This program is free software: you can redistribute it and/or modify 7cb62cb3cSGreg Roach * it under the terms of the GNU General Public License as published by 8cb62cb3cSGreg Roach * the Free Software Foundation, either version 3 of the License, or 9cb62cb3cSGreg Roach * (at your option) any later version. 10cb62cb3cSGreg Roach * This program is distributed in the hope that it will be useful, 11cb62cb3cSGreg Roach * but WITHOUT ANY WARRANTY; without even the implied warranty of 12cb62cb3cSGreg Roach * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 13cb62cb3cSGreg Roach * GNU General Public License for more details. 14cb62cb3cSGreg Roach * You should have received a copy of the GNU General Public License 15cb62cb3cSGreg Roach * along with this program. If not, see <https://www.gnu.org/licenses/>. 16cb62cb3cSGreg Roach */ 17cb62cb3cSGreg Roach 18cb62cb3cSGreg Roachdeclare(strict_types=1); 19cb62cb3cSGreg Roach 20cb62cb3cSGreg Roachnamespace Fisharebest\Webtrees\Services; 21cb62cb3cSGreg Roach 22cb62cb3cSGreg Roachuse Fisharebest\Webtrees\TestCase; 23cb62cb3cSGreg Roach 24cb62cb3cSGreg Roach/** 25cb62cb3cSGreg Roach * Test harness for the class GedcomEditService 26cb62cb3cSGreg Roach * 27cb62cb3cSGreg Roach * @covers \Fisharebest\Webtrees\Services\GedcomEditService 28cb62cb3cSGreg Roach */ 29cb62cb3cSGreg Roachclass GedcomEditServiceTest extends TestCase 30cb62cb3cSGreg Roach{ 31cb62cb3cSGreg Roach /** 32cb62cb3cSGreg Roach * @covers \Fisharebest\Webtrees\Services\GedcomEditService::editLinesToGedcom 33cb62cb3cSGreg Roach */ 34cb62cb3cSGreg Roach public function testEditLinesToGedcom(): void 35cb62cb3cSGreg Roach { 36cb62cb3cSGreg Roach $gedcom_edit_service = new GedcomEditService(); 37cb62cb3cSGreg Roach 38f01ab4acSGreg Roach static::assertSame( 39*6e60786aSGreg Roach '1 BIRT Y', 40cb62cb3cSGreg Roach $gedcom_edit_service->editLinesToGedcom( 41cb62cb3cSGreg Roach 'INDI', 42cb62cb3cSGreg Roach ['1'], 43cb62cb3cSGreg Roach ['BIRT'], 44cb62cb3cSGreg Roach ['Y'] 45cb62cb3cSGreg Roach ) 46cb62cb3cSGreg Roach ); 47cb62cb3cSGreg Roach 48f01ab4acSGreg Roach static::assertSame( 49cb62cb3cSGreg Roach "1 BIRT Y\n2 ADDR England", 50cb62cb3cSGreg Roach $gedcom_edit_service->editLinesToGedcom( 51cb62cb3cSGreg Roach 'INDI', 52cb62cb3cSGreg Roach ['1', '2'], 53cb62cb3cSGreg Roach ['BIRT', 'ADDR'], 54cb62cb3cSGreg Roach ['Y', 'England'] 55cb62cb3cSGreg Roach ) 56cb62cb3cSGreg Roach ); 57cb62cb3cSGreg Roach 58f01ab4acSGreg Roach static::assertSame( 59cb62cb3cSGreg Roach "1 BIRT\n2 PLAC England", 60cb62cb3cSGreg Roach $gedcom_edit_service->editLinesToGedcom( 61cb62cb3cSGreg Roach 'INDI', 62cb62cb3cSGreg Roach ['1', '2'], 63cb62cb3cSGreg Roach ['BIRT', 'PLAC'], 64cb62cb3cSGreg Roach ['Y', 'England'] 65cb62cb3cSGreg Roach ) 66cb62cb3cSGreg Roach ); 67cb62cb3cSGreg Roach 68f01ab4acSGreg Roach static::assertSame( 69cb62cb3cSGreg Roach "1 BIRT\n2 PLAC England\n2 SOUR @S1@\n3 PAGE 123", 70cb62cb3cSGreg Roach $gedcom_edit_service->editLinesToGedcom( 71cb62cb3cSGreg Roach 'INDI', 72cb62cb3cSGreg Roach ['1', '2', '2', '3'], 73cb62cb3cSGreg Roach ['BIRT', 'PLAC', 'SOUR', 'PAGE'], 74cb62cb3cSGreg Roach ['Y', 'England', '@S1@', '123'] 75cb62cb3cSGreg Roach ) 76cb62cb3cSGreg Roach ); 77cb62cb3cSGreg Roach 78cefd719cSGreg Roach // Missing SOUR, so ignore PAGE 79f01ab4acSGreg Roach static::assertSame( 80cefd719cSGreg Roach "1 BIRT\n2 PLAC England", 81cefd719cSGreg Roach $gedcom_edit_service->editLinesToGedcom( 82cefd719cSGreg Roach 'INDI', 83cefd719cSGreg Roach ['1', '2', '2', '3'], 84cefd719cSGreg Roach ['BIRT', 'PLAC', 'SOUR', 'PAGE'], 85cefd719cSGreg Roach ['Y', 'England', '', '123'] 86cefd719cSGreg Roach ) 87cefd719cSGreg Roach ); 88cefd719cSGreg Roach 89f01ab4acSGreg Roach static::assertSame( 90cb62cb3cSGreg Roach "1 BIRT\n2 PLAC England", 91cb62cb3cSGreg Roach $gedcom_edit_service->editLinesToGedcom( 92cb62cb3cSGreg Roach 'INDI', 93cb62cb3cSGreg Roach ['1', '2', '2', '3'], 94cb62cb3cSGreg Roach ['BIRT', 'PLAC', 'SOUR', 'PAGE'], 95cb62cb3cSGreg Roach ['Y', 'England', '', '123'] 96cb62cb3cSGreg Roach ) 97cb62cb3cSGreg Roach ); 98cb62cb3cSGreg Roach 99f01ab4acSGreg Roach static::assertSame( 100cb62cb3cSGreg Roach "1 BIRT\n2 PLAC England\n1 DEAT\n2 PLAC Scotland", 101cb62cb3cSGreg Roach $gedcom_edit_service->editLinesToGedcom( 102cb62cb3cSGreg Roach 'INDI', 103cb62cb3cSGreg Roach ['1', '2', '2', '3', '1', '2', '2', '3'], 104cb62cb3cSGreg Roach ['BIRT', 'PLAC', 'SOUR', 'PAGE', 'DEAT', 'PLAC', 'SOUR', 'PAGE'], 105cb62cb3cSGreg Roach ['Y', 'England', '', '123', 'Y', 'Scotland', '', '123'] 106cb62cb3cSGreg Roach ) 107cb62cb3cSGreg Roach ); 108cb62cb3cSGreg Roach 109f01ab4acSGreg Roach static::assertSame( 110cb62cb3cSGreg Roach "0 NOTE @N1@\n1 CONC foo\n1 CONT bar\n1 RESN locked", 111cb62cb3cSGreg Roach $gedcom_edit_service->editLinesToGedcom( 112cb62cb3cSGreg Roach 'NOTE', 113cb62cb3cSGreg Roach ['0', '1', '1'], 114cb62cb3cSGreg Roach ['NOTE', 'CONC', 'RESN'], 115cb62cb3cSGreg Roach ['@N1@', "foo\nbar", 'locked'] 116cb62cb3cSGreg Roach ) 117cb62cb3cSGreg Roach ); 118cb62cb3cSGreg Roach } 119cb62cb3cSGreg Roach} 120