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