|
| 1 | +<?php |
| 2 | + |
| 3 | +namespace Composer\Installers\Test; |
| 4 | + |
| 5 | +use Composer\Installers\ForkCMSInstaller; |
| 6 | +use Composer\Package\Package; |
| 7 | + |
| 8 | +class ForkCMSInstallerTest extends TestCase |
| 9 | +{ |
| 10 | + /** |
| 11 | + * @var ForkCMSInstaller |
| 12 | + */ |
| 13 | + private $installer; |
| 14 | + |
| 15 | + public function setUp(): void |
| 16 | + { |
| 17 | + $this->installer = new ForkCMSInstaller( |
| 18 | + new Package('Knife', '4.2', '4.2'), |
| 19 | + $this->getComposer(), |
| 20 | + $this->getMockIO() |
| 21 | + ); |
| 22 | + } |
| 23 | + |
| 24 | + /** |
| 25 | + * @dataProvider packageNameInflectionProvider |
| 26 | + */ |
| 27 | + public function testInflectPackageVars(string $type, string $vendor, string $name, string $expectedVendor, string $expectedName): void |
| 28 | + { |
| 29 | + $this->assertEquals( |
| 30 | + $this->installer->inflectPackageVars([ |
| 31 | + 'vendor' => $vendor, |
| 32 | + 'name' => $name, |
| 33 | + 'type' => $type |
| 34 | + ]), |
| 35 | + ['vendor' => $expectedVendor, 'name' => $expectedName, 'type' => $type] |
| 36 | + ); |
| 37 | + } |
| 38 | + |
| 39 | + public function packageNameInflectionProvider(): array |
| 40 | + { |
| 41 | + return [ |
| 42 | + // module with lowercase name |
| 43 | + [ |
| 44 | + 'fork-cms-module', |
| 45 | + 'pageon', |
| 46 | + 'knife', |
| 47 | + 'pageon', |
| 48 | + 'Knife', |
| 49 | + ], |
| 50 | + // theme with lowercase name |
| 51 | + [ |
| 52 | + 'fork-cms-theme', |
| 53 | + 'pageon', |
| 54 | + 'knife', |
| 55 | + 'pageon', |
| 56 | + 'Knife', |
| 57 | + ], |
| 58 | + // module with lowercase name and module affix |
| 59 | + [ |
| 60 | + 'fork-cms-module', |
| 61 | + 'pageon', |
| 62 | + 'knife-module', |
| 63 | + 'pageon', |
| 64 | + 'Knife', |
| 65 | + ], |
| 66 | + // theme with lowercase name and theme affix |
| 67 | + [ |
| 68 | + 'fork-cms-theme', |
| 69 | + 'pageon', |
| 70 | + 'knife-theme', |
| 71 | + 'pageon', |
| 72 | + 'Knife', |
| 73 | + ], |
| 74 | + // module with lowercase name and module affix and fork-cms prefix |
| 75 | + [ |
| 76 | + 'fork-cms-module', |
| 77 | + 'pageon', |
| 78 | + 'fork-cms-knife-module', |
| 79 | + 'pageon', |
| 80 | + 'Knife', |
| 81 | + ], |
| 82 | + // theme with lowercase name and theme affix and fork-cms prefix |
| 83 | + [ |
| 84 | + 'fork-cms-theme', |
| 85 | + 'pageon', |
| 86 | + 'fork-cms-knife-theme', |
| 87 | + 'pageon', |
| 88 | + 'Knife', |
| 89 | + ], |
| 90 | + // module with lowercase name and fork-cms prefix |
| 91 | + [ |
| 92 | + 'fork-cms-module', |
| 93 | + 'pageon', |
| 94 | + 'fork-cms-knife', |
| 95 | + 'pageon', |
| 96 | + 'Knife', |
| 97 | + ], |
| 98 | + // theme with lowercase name and fork-cms prefix |
| 99 | + [ |
| 100 | + 'fork-cms-theme', |
| 101 | + 'pageon', |
| 102 | + 'fork-cms-knife', |
| 103 | + 'pageon', |
| 104 | + 'Knife', |
| 105 | + ], |
| 106 | + // module with hyphenated name |
| 107 | + [ |
| 108 | + 'fork-cms-module', |
| 109 | + 'pageon', |
| 110 | + 'knife-and-spoon', |
| 111 | + 'pageon', |
| 112 | + 'KnifeAndSpoon', |
| 113 | + ], |
| 114 | + // theme with hyphenated name |
| 115 | + [ |
| 116 | + 'fork-cms-theme', |
| 117 | + 'pageon', |
| 118 | + 'knife-and-spoon', |
| 119 | + 'pageon', |
| 120 | + 'KnifeAndSpoon', |
| 121 | + ], |
| 122 | + // module with hyphenated name and module affix |
| 123 | + [ |
| 124 | + 'fork-cms-module', |
| 125 | + 'pageon', |
| 126 | + 'knife-and-spoon-module', |
| 127 | + 'pageon', |
| 128 | + 'KnifeAndSpoon', |
| 129 | + ], |
| 130 | + // theme with hyphenated name and theme affix |
| 131 | + [ |
| 132 | + 'fork-cms-theme', |
| 133 | + 'pageon', |
| 134 | + 'knife-and-spoon-theme', |
| 135 | + 'pageon', |
| 136 | + 'KnifeAndSpoon', |
| 137 | + ], |
| 138 | + // module with hyphenated name and module affix and fork-cms prefix |
| 139 | + [ |
| 140 | + 'fork-cms-module', |
| 141 | + 'pageon', |
| 142 | + 'fork-cms-knife-and-spoon-module', |
| 143 | + 'pageon', |
| 144 | + 'KnifeAndSpoon', |
| 145 | + ], |
| 146 | + // theme with hyphenated name and theme affix and fork-cms prefix |
| 147 | + [ |
| 148 | + 'fork-cms-theme', |
| 149 | + 'pageon', |
| 150 | + 'fork-cms-knife-and-spoon-theme', |
| 151 | + 'pageon', |
| 152 | + 'KnifeAndSpoon', |
| 153 | + ], |
| 154 | + // module with hyphenated name and fork-cms prefix |
| 155 | + [ |
| 156 | + 'fork-cms-module', |
| 157 | + 'pageon', |
| 158 | + 'fork-cms-knife-and-spoon', |
| 159 | + 'pageon', |
| 160 | + 'KnifeAndSpoon', |
| 161 | + ], |
| 162 | + // theme with hyphenated name and fork-cms prefix |
| 163 | + [ |
| 164 | + 'fork-cms-theme', |
| 165 | + 'pageon', |
| 166 | + 'fork-cms-knife-and-spoon', |
| 167 | + 'pageon', |
| 168 | + 'KnifeAndSpoon', |
| 169 | + ], |
| 170 | + // module with underscored name |
| 171 | + [ |
| 172 | + 'fork-cms-module', |
| 173 | + 'pageon', |
| 174 | + 'knife_and_spoon', |
| 175 | + 'pageon', |
| 176 | + 'KnifeAndSpoon', |
| 177 | + ], |
| 178 | + // theme with underscored name |
| 179 | + [ |
| 180 | + 'fork-cms-theme', |
| 181 | + 'pageon', |
| 182 | + 'knife_and_spoon', |
| 183 | + 'pageon', |
| 184 | + 'KnifeAndSpoon', |
| 185 | + ], |
| 186 | + // module with underscored name and module affix |
| 187 | + [ |
| 188 | + 'fork-cms-module', |
| 189 | + 'pageon', |
| 190 | + 'knife_and_spoon-module', |
| 191 | + 'pageon', |
| 192 | + 'KnifeAndSpoon', |
| 193 | + ], |
| 194 | + // theme with underscored name and theme affix |
| 195 | + [ |
| 196 | + 'fork-cms-theme', |
| 197 | + 'pageon', |
| 198 | + 'knife_and_spoon-theme', |
| 199 | + 'pageon', |
| 200 | + 'KnifeAndSpoon', |
| 201 | + ], |
| 202 | + // module with underscored name and module affix and fork-cms prefix |
| 203 | + [ |
| 204 | + 'fork-cms-module', |
| 205 | + 'pageon', |
| 206 | + 'fork-cms-knife_and_spoon-module', |
| 207 | + 'pageon', |
| 208 | + 'KnifeAndSpoon', |
| 209 | + ], |
| 210 | + // theme with underscored name and theme affix and fork-cms prefix |
| 211 | + [ |
| 212 | + 'fork-cms-theme', |
| 213 | + 'pageon', |
| 214 | + 'fork-cms-knife_and_spoon-theme', |
| 215 | + 'pageon', |
| 216 | + 'KnifeAndSpoon', |
| 217 | + ], |
| 218 | + // module with underscored name and fork-cms prefix |
| 219 | + [ |
| 220 | + 'fork-cms-module', |
| 221 | + 'pageon', |
| 222 | + 'fork-cms-knife_and_spoon', |
| 223 | + 'pageon', |
| 224 | + 'KnifeAndSpoon', |
| 225 | + ], |
| 226 | + // theme with underscored name and fork-cms prefix |
| 227 | + [ |
| 228 | + 'fork-cms-theme', |
| 229 | + 'pageon', |
| 230 | + 'fork-cms-knife_and_spoon', |
| 231 | + 'pageon', |
| 232 | + 'KnifeAndSpoon', |
| 233 | + ], |
| 234 | + // module with camelcased name |
| 235 | + [ |
| 236 | + 'fork-cms-module', |
| 237 | + 'pageon', |
| 238 | + 'knifeAndSpoon', |
| 239 | + 'pageon', |
| 240 | + 'KnifeAndSpoon', |
| 241 | + ], |
| 242 | + // theme with camelcased name |
| 243 | + [ |
| 244 | + 'fork-cms-theme', |
| 245 | + 'pageon', |
| 246 | + 'knifeAndSpoon', |
| 247 | + 'pageon', |
| 248 | + 'KnifeAndSpoon', |
| 249 | + ], |
| 250 | + // module with camelcased name and module affix |
| 251 | + [ |
| 252 | + 'fork-cms-module', |
| 253 | + 'pageon', |
| 254 | + 'knifeAndSpoonModule', |
| 255 | + 'pageon', |
| 256 | + 'KnifeAndSpoon', |
| 257 | + ], |
| 258 | + // theme with camelcased name and theme affix |
| 259 | + [ |
| 260 | + 'fork-cms-theme', |
| 261 | + 'pageon', |
| 262 | + 'knifeAndSpoonTheme', |
| 263 | + 'pageon', |
| 264 | + 'KnifeAndSpoon', |
| 265 | + ], |
| 266 | + // module with camelcased name and module affix and fork-cms prefix |
| 267 | + [ |
| 268 | + 'fork-cms-module', |
| 269 | + 'pageon', |
| 270 | + 'ForkCmsKnifeAndSpoonModule', |
| 271 | + 'pageon', |
| 272 | + 'KnifeAndSpoon', |
| 273 | + ], |
| 274 | + // theme with camelcased name and theme affix and fork-cms prefix |
| 275 | + [ |
| 276 | + 'fork-cms-theme', |
| 277 | + 'pageon', |
| 278 | + 'ForkCmsKnifeAndSpoonTheme', |
| 279 | + 'pageon', |
| 280 | + 'KnifeAndSpoon', |
| 281 | + ], |
| 282 | + // module with camelcased name and fork-cms prefix |
| 283 | + [ |
| 284 | + 'fork-cms-module', |
| 285 | + 'pageon', |
| 286 | + 'ForkCmsKnifeAndSpoon', |
| 287 | + 'pageon', |
| 288 | + 'KnifeAndSpoon', |
| 289 | + ], |
| 290 | + // theme with camelcased name and fork-cms prefix |
| 291 | + [ |
| 292 | + 'fork-cms-theme', |
| 293 | + 'pageon', |
| 294 | + 'ForkCmsKnifeAndSpoon', |
| 295 | + 'pageon', |
| 296 | + 'KnifeAndSpoon', |
| 297 | + ], |
| 298 | + ]; |
| 299 | + } |
| 300 | +} |
0 commit comments