CraftInstallerTest.php 2.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384
  1. <?php
  2. namespace Composer\Installers\Test;
  3. use Composer\Installers\CraftInstaller;
  4. /**
  5. * Tests for the CraftInstaller Class
  6. *
  7. * @coversDefaultClass Composer\Installers\CraftInstaller
  8. */
  9. class CraftInstallerTest extends TestCase
  10. {
  11. /** @var CraftInstaller */
  12. private $installer;
  13. /**
  14. * Sets up the fixture, for example, instantiate the class-under-test.
  15. *
  16. * This method is called before a test is executed.
  17. */
  18. final public function setup()
  19. {
  20. $this->installer = new CraftInstaller();
  21. }
  22. /**
  23. * @param string $packageName
  24. * @param string $expectedName
  25. *
  26. * @covers ::inflectPackageVars
  27. *
  28. * @dataProvider provideExpectedInflectionResults
  29. */
  30. final public function testInflectPackageVars($packageName, $expectedName)
  31. {
  32. $installer = $this->installer;
  33. $vars = array('name' => $packageName);
  34. $expected = array('name' => $expectedName);
  35. $actual = $installer->inflectPackageVars($vars);
  36. $this->assertEquals($actual, $expected);
  37. }
  38. /**
  39. * Provides various names for packages and the expected result after inflection
  40. *
  41. * @return array
  42. */
  43. final public function provideExpectedInflectionResults()
  44. {
  45. return array(
  46. // lowercase
  47. array('foo', 'foo'),
  48. array('craftfoo', 'craftfoo'),
  49. array('fooplugin', 'fooplugin'),
  50. array('craftfooplugin', 'craftfooplugin'),
  51. // lowercase - dash
  52. array('craft-foo', 'foo'),
  53. array('foo-plugin', 'foo'),
  54. array('craft-foo-plugin', 'foo'),
  55. // lowercase - underscore
  56. array('craft_foo', 'craft_foo'),
  57. array('foo_plugin', 'foo_plugin'),
  58. array('craft_foo_plugin', 'craft_foo_plugin'),
  59. // CamelCase
  60. array('Foo', 'Foo'),
  61. array('CraftFoo', 'CraftFoo'),
  62. array('FooPlugin', 'FooPlugin'),
  63. array('CraftFooPlugin', 'CraftFooPlugin'),
  64. // CamelCase - Dash
  65. array('Craft-Foo', 'Foo'),
  66. array('Foo-Plugin', 'Foo'),
  67. array('Craft-Foo-Plugin', 'Foo'),
  68. // CamelCase - underscore
  69. array('Craft_Foo', 'Craft_Foo'),
  70. array('Foo_Plugin', 'Foo_Plugin'),
  71. array('Craft_Foo_Plugin', 'Craft_Foo_Plugin'),
  72. );
  73. }
  74. }