MediaWikiInstallerTest.php 1.7 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667
  1. <?php
  2. namespace Composer\Installers\Test;
  3. use Composer\Installers\MediaWikiInstaller;
  4. use Composer\Package\Package;
  5. use Composer\Composer;
  6. class MediaWikiInstallerTest extends \PHPUnit_Framework_TestCase
  7. {
  8. /**
  9. * @var MediaWikiInstaller
  10. */
  11. private $installer;
  12. public function setUp()
  13. {
  14. $this->installer = new MediaWikiInstaller(
  15. new Package('NyanCat', '4.2', '4.2'),
  16. new Composer()
  17. );
  18. }
  19. /**
  20. * @dataProvider packageNameInflectionProvider
  21. */
  22. public function testInflectPackageVars($type, $name, $expected)
  23. {
  24. $this->assertEquals(
  25. $this->installer->inflectPackageVars(array('name' => $name, 'type'=>$type)),
  26. array('name' => $expected, 'type'=>$type)
  27. );
  28. }
  29. public function packageNameInflectionProvider()
  30. {
  31. return array(
  32. array(
  33. 'mediawiki-extension',
  34. 'sub-page-list',
  35. 'SubPageList',
  36. ),
  37. array(
  38. 'mediawiki-extension',
  39. 'sub-page-list-extension',
  40. 'SubPageList',
  41. ),
  42. array(
  43. 'mediawiki-extension',
  44. 'semantic-mediawiki',
  45. 'SemanticMediawiki',
  46. ),
  47. // tests that exactly one '-skin' is cut off, and that skins do not get ucwords treatment like extensions
  48. array(
  49. 'mediawiki-skin',
  50. 'some-skin-skin',
  51. 'some-skin',
  52. ),
  53. // tests that names without '-skin' suffix stay valid
  54. array(
  55. 'mediawiki-skin',
  56. 'someotherskin',
  57. 'someotherskin',
  58. ),
  59. );
  60. }
  61. }