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