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\Census; 21 22use Fisharebest\Webtrees\TestCase; 23 24/** 25 * Test harness for the class Census 26 */ 27class CensusTest extends TestCase 28{ 29 /** 30 * @covers \Fisharebest\Webtrees\Census\Census 31 * 32 * @return void 33 */ 34 public function testCensusPlacesCzech(): void 35 { 36 $censuses = Census::censusPlaces('cs'); 37 38 self::assertCount(10, $censuses); 39 self::assertInstanceOf(CensusOfCzechRepublic::class, $censuses[0]); 40 self::assertInstanceOf(CensusOfSlovakia::class, $censuses[1]); 41 self::assertInstanceOf(CensusOfDenmark::class, $censuses[2]); 42 self::assertInstanceOf(CensusOfDeutschland::class, $censuses[3]); 43 self::assertInstanceOf(CensusOfEngland::class, $censuses[4]); 44 self::assertInstanceOf(CensusOfFrance::class, $censuses[5]); 45 self::assertInstanceOf(CensusOfScotland::class, $censuses[6]); 46 self::assertInstanceOf(CensusOfUnitedStates::class, $censuses[7]); 47 self::assertInstanceOf(CensusOfWales::class, $censuses[8]); 48 self::assertInstanceOf(CensusOfCanada::class, $censuses[9]); 49 } 50 51 /** 52 * @covers \Fisharebest\Webtrees\Census\Census 53 * 54 * @return void 55 */ 56 public function testCensusPlacesDanish(): void 57 { 58 $censuses = Census::censusPlaces('da'); 59 60 self::assertCount(10, $censuses); 61 self::assertInstanceOf(CensusOfDenmark::class, $censuses[0]); 62 self::assertInstanceOf(CensusOfDeutschland::class, $censuses[1]); 63 self::assertInstanceOf(CensusOfCzechRepublic::class, $censuses[2]); 64 self::assertInstanceOf(CensusOfEngland::class, $censuses[3]); 65 self::assertInstanceOf(CensusOfFrance::class, $censuses[4]); 66 self::assertInstanceOf(CensusOfScotland::class, $censuses[5]); 67 self::assertInstanceOf(CensusOfSlovakia::class, $censuses[6]); 68 self::assertInstanceOf(CensusOfUnitedStates::class, $censuses[7]); 69 self::assertInstanceOf(CensusOfWales::class, $censuses[8]); 70 self::assertInstanceOf(CensusOfCanada::class, $censuses[9]); 71 } 72 73 /** 74 * @covers \Fisharebest\Webtrees\Census\Census 75 * 76 * @return void 77 */ 78 public function testCensusPlacesGerman(): void 79 { 80 $censuses = Census::censusPlaces('de'); 81 82 self::assertInstanceOf(CensusOfDeutschland::class, $censuses[0]); 83 self::assertInstanceOf(CensusOfCzechRepublic::class, $censuses[1]); 84 self::assertInstanceOf(CensusOfDenmark::class, $censuses[2]); 85 self::assertInstanceOf(CensusOfEngland::class, $censuses[3]); 86 self::assertInstanceOf(CensusOfFrance::class, $censuses[4]); 87 self::assertInstanceOf(CensusOfScotland::class, $censuses[5]); 88 self::assertInstanceOf(CensusOfSlovakia::class, $censuses[6]); 89 self::assertInstanceOf(CensusOfUnitedStates::class, $censuses[7]); 90 self::assertInstanceOf(CensusOfWales::class, $censuses[8]); 91 self::assertInstanceOf(CensusOfCanada::class, $censuses[9]); 92 } 93 94 /** 95 * @covers \Fisharebest\Webtrees\Census\Census 96 * 97 * @return void 98 */ 99 public function testCensusPlacesAustralianEnglish(): void 100 { 101 $censuses = Census::censusPlaces('en-AU'); 102 103 self::assertCount(10, $censuses); 104 self::assertInstanceOf(CensusOfEngland::class, $censuses[0]); 105 self::assertInstanceOf(CensusOfScotland::class, $censuses[1]); 106 self::assertInstanceOf(CensusOfWales::class, $censuses[2]); 107 self::assertInstanceOf(CensusOfCanada::class, $censuses[3]); 108 self::assertInstanceOf(CensusOfUnitedStates::class, $censuses[4]); 109 self::assertInstanceOf(CensusOfCzechRepublic::class, $censuses[5]); 110 self::assertInstanceOf(CensusOfDenmark::class, $censuses[6]); 111 self::assertInstanceOf(CensusOfDeutschland::class, $censuses[7]); 112 self::assertInstanceOf(CensusOfFrance::class, $censuses[8]); 113 self::assertInstanceOf(CensusOfSlovakia::class, $censuses[9]); 114 } 115 116 /** 117 * @covers \Fisharebest\Webtrees\Census\Census 118 * 119 * @return void 120 */ 121 public function testCensusPlacesBritishEnglish(): void 122 { 123 $censuses = Census::censusPlaces('en-GB'); 124 125 self::assertCount(10, $censuses); 126 self::assertInstanceOf(CensusOfEngland::class, $censuses[0]); 127 self::assertInstanceOf(CensusOfScotland::class, $censuses[1]); 128 self::assertInstanceOf(CensusOfWales::class, $censuses[2]); 129 self::assertInstanceOf(CensusOfCanada::class, $censuses[3]); 130 self::assertInstanceOf(CensusOfUnitedStates::class, $censuses[4]); 131 self::assertInstanceOf(CensusOfCzechRepublic::class, $censuses[5]); 132 self::assertInstanceOf(CensusOfDenmark::class, $censuses[6]); 133 self::assertInstanceOf(CensusOfDeutschland::class, $censuses[7]); 134 self::assertInstanceOf(CensusOfFrance::class, $censuses[8]); 135 self::assertInstanceOf(CensusOfSlovakia::class, $censuses[9]); 136 } 137 138 /** 139 * @covers \Fisharebest\Webtrees\Census\Census 140 * 141 * @return void 142 */ 143 public function testCensusPlacesUSEnglish(): void 144 { 145 $censuses = Census::censusPlaces('en-US'); 146 147 self::assertCount(10, $censuses); 148 self::assertInstanceOf(CensusOfUnitedStates::class, $censuses[0]); 149 self::assertInstanceOf(CensusOfCanada::class, $censuses[1]); 150 self::assertInstanceOf(CensusOfCzechRepublic::class, $censuses[2]); 151 self::assertInstanceOf(CensusOfDenmark::class, $censuses[3]); 152 self::assertInstanceOf(CensusOfDeutschland::class, $censuses[4]); 153 self::assertInstanceOf(CensusOfEngland::class, $censuses[5]); 154 self::assertInstanceOf(CensusOfFrance::class, $censuses[6]); 155 self::assertInstanceOf(CensusOfScotland::class, $censuses[7]); 156 self::assertInstanceOf(CensusOfSlovakia::class, $censuses[8]); 157 self::assertInstanceOf(CensusOfWales::class, $censuses[9]); 158 } 159 160 /** 161 * @covers \Fisharebest\Webtrees\Census\Census 162 * 163 * @return void 164 */ 165 public function testCensusPlacesFrench(): void 166 { 167 $censuses = Census::censusPlaces('fr'); 168 169 self::assertCount(10, $censuses); 170 self::assertInstanceOf(CensusOfFrance::class, $censuses[0]); 171 self::assertInstanceOf(CensusOfCanada::class, $censuses[1]); 172 self::assertInstanceOf(CensusOfCzechRepublic::class, $censuses[2]); 173 self::assertInstanceOf(CensusOfDenmark::class, $censuses[3]); 174 self::assertInstanceOf(CensusOfDeutschland::class, $censuses[4]); 175 self::assertInstanceOf(CensusOfEngland::class, $censuses[5]); 176 self::assertInstanceOf(CensusOfScotland::class, $censuses[6]); 177 self::assertInstanceOf(CensusOfSlovakia::class, $censuses[7]); 178 self::assertInstanceOf(CensusOfUnitedStates::class, $censuses[8]); 179 self::assertInstanceOf(CensusOfWales::class, $censuses[9]); 180 } 181 182 /** 183 * @covers \Fisharebest\Webtrees\Census\Census 184 * 185 * @return void 186 */ 187 public function testCensusPlacesCanadianFrench(): void 188 { 189 $censuses = Census::censusPlaces('fr-CA'); 190 191 self::assertCount(10, $censuses); 192 self::assertInstanceOf(CensusOfCanada::class, $censuses[0]); 193 self::assertInstanceOf(CensusOfFrance::class, $censuses[1]); 194 self::assertInstanceOf(CensusOfCzechRepublic::class, $censuses[2]); 195 self::assertInstanceOf(CensusOfDenmark::class, $censuses[3]); 196 self::assertInstanceOf(CensusOfDeutschland::class, $censuses[4]); 197 self::assertInstanceOf(CensusOfEngland::class, $censuses[5]); 198 self::assertInstanceOf(CensusOfScotland::class, $censuses[6]); 199 self::assertInstanceOf(CensusOfSlovakia::class, $censuses[7]); 200 self::assertInstanceOf(CensusOfUnitedStates::class, $censuses[8]); 201 self::assertInstanceOf(CensusOfWales::class, $censuses[9]); 202 } 203 204 /** 205 * @covers \Fisharebest\Webtrees\Census\Census 206 * 207 * @return void 208 */ 209 public function testCensusPlacesSlovak(): void 210 { 211 $censuses = Census::censusPlaces('sk'); 212 213 self::assertCount(10, $censuses); 214 self::assertInstanceOf(CensusOfSlovakia::class, $censuses[0]); 215 self::assertInstanceOf(CensusOfCzechRepublic::class, $censuses[1]); 216 self::assertInstanceOf(CensusOfDenmark::class, $censuses[2]); 217 self::assertInstanceOf(CensusOfDeutschland::class, $censuses[3]); 218 self::assertInstanceOf(CensusOfEngland::class, $censuses[4]); 219 self::assertInstanceOf(CensusOfFrance::class, $censuses[5]); 220 self::assertInstanceOf(CensusOfScotland::class, $censuses[6]); 221 self::assertInstanceOf(CensusOfUnitedStates::class, $censuses[7]); 222 self::assertInstanceOf(CensusOfWales::class, $censuses[8]); 223 self::assertInstanceOf(CensusOfCanada::class, $censuses[9]); 224 } 225 226 /** 227 * @covers \Fisharebest\Webtrees\Census\Census 228 * 229 * @return void 230 */ 231 public function testCensusPlacesDefault(): void 232 { 233 $censuses = Census::censusPlaces('XX'); 234 235 self::assertCount(10, $censuses); 236 self::assertInstanceOf(CensusOfUnitedStates::class, $censuses[0]); 237 self::assertInstanceOf(CensusOfEngland::class, $censuses[1]); 238 self::assertInstanceOf(CensusOfScotland::class, $censuses[2]); 239 self::assertInstanceOf(CensusOfWales::class, $censuses[3]); 240 self::assertInstanceOf(CensusOfDeutschland::class, $censuses[4]); 241 self::assertInstanceOf(CensusOfFrance::class, $censuses[5]); 242 self::assertInstanceOf(CensusOfCzechRepublic::class, $censuses[6]); 243 self::assertInstanceOf(CensusOfSlovakia::class, $censuses[7]); 244 self::assertInstanceOf(CensusOfDenmark::class, $censuses[8]); 245 self::assertInstanceOf(CensusOfCanada::class, $censuses[9]); 246 } 247} 248