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 $this->assertSame( 79 "1 BIRT\n2 PLAC England", 80 $gedcom_edit_service->editLinesToGedcom( 81 'INDI', 82 ['1', '2', '2', '3'], 83 ['BIRT', 'PLAC', 'SOUR', 'PAGE'], 84 ['Y', 'England', '', '123'] 85 ) 86 ); 87 88 $this->assertSame( 89 "1 BIRT\n2 PLAC England\n1 DEAT\n2 PLAC Scotland", 90 $gedcom_edit_service->editLinesToGedcom( 91 'INDI', 92 ['1', '2', '2', '3', '1', '2', '2', '3'], 93 ['BIRT', 'PLAC', 'SOUR', 'PAGE', 'DEAT', 'PLAC', 'SOUR', 'PAGE'], 94 ['Y', 'England', '', '123', 'Y', 'Scotland', '', '123'] 95 ) 96 ); 97 98 $this->assertSame( 99 "0 NOTE @N1@\n1 CONC foo\n1 CONT bar\n1 RESN locked", 100 $gedcom_edit_service->editLinesToGedcom( 101 'NOTE', 102 ['0', '1', '1'], 103 ['NOTE', 'CONC', 'RESN'], 104 ['@N1@', "foo\nbar", 'locked'] 105 ) 106 ); 107 } 108} 109