ComposerInstallersTestCakePHPInstallerTest

The WooCommerce Multilingual Composer Installers Test CakePHPInstallerTest class.

Defined (1)

The class is defined in the following location(s).

/vendor/composer/installers/tests/Composer/Installers/Test/CakePHPInstallerTest.php  
  1. class CakePHPInstallerTest extends TestCase 
  2. private $composer; 
  3. private $io; 
  4.  
  5. /** 
  6. * setUp 
  7. * @return void 
  8. */ 
  9. public function setUp() 
  10. $this->package = new Package('CamelCased', '1.0', '1.0'); 
  11. $this->io = $this->getMock('Composer\IO\PackageInterface'); 
  12. $this->composer = new Composer(); 
  13. $this->composer->setConfig(new Config(false)); 
  14.  
  15. /** 
  16. * testInflectPackageVars 
  17. * @return void 
  18. */ 
  19. public function testInflectPackageVars() 
  20. $installer = new CakePHPInstaller($this->package, $this->composer); 
  21. $result = $installer->inflectPackageVars(array('name' => 'CamelCased')); 
  22. $this->assertEquals($result, array('name' => 'CamelCased')); 
  23.  
  24. $installer = new CakePHPInstaller($this->package, $this->composer); 
  25. $result = $installer->inflectPackageVars(array('name' => 'with-dash')); 
  26. $this->assertEquals($result, array('name' => 'WithDash')); 
  27.  
  28. $installer = new CakePHPInstaller($this->package, $this->composer); 
  29. $result = $installer->inflectPackageVars(array('name' => 'with_underscore')); 
  30. $this->assertEquals($result, array('name' => 'WithUnderscore')); 
  31.  
  32. $installer = new CakePHPInstaller($this->package, $this->composer); 
  33. $result = $installer->inflectPackageVars(array('name' => 'cake/acl')); 
  34. $this->assertEquals($result, array('name' => 'Cake/Acl')); 
  35.  
  36. $installer = new CakePHPInstaller($this->package, $this->composer); 
  37. $result = $installer->inflectPackageVars(array('name' => 'cake/debug-kit')); 
  38. $this->assertEquals($result, array('name' => 'Cake/DebugKit')); 
  39.  
  40. /** 
  41. * Test getLocations returning appropriate values based on CakePHP version 
  42. */ 
  43. public function testGetLocations() { 
  44. $package = new RootPackage('CamelCased', '1.0', '1.0'); 
  45. $composer = $this->composer; 
  46. $rm = new RepositoryManager( 
  47. $this->getMock('Composer\IO\IOInterface'),  
  48. $this->getMock('Composer\Config') 
  49. ); 
  50. $composer->setRepositoryManager($rm); 
  51. $installer = new CakePHPInstaller($package, $composer); 
  52.  
  53. // 2.0 < cakephp < 3.0 
  54. $this->setCakephpVersion($rm, '2.0.0'); 
  55. $result = $installer->getLocations(); 
  56. $this->assertContains('Plugin/', $result['plugin']); 
  57.  
  58. $this->setCakephpVersion($rm, '2.5.9'); 
  59. $result = $installer->getLocations(); 
  60. $this->assertContains('Plugin/', $result['plugin']); 
  61.  
  62. $this->setCakephpVersion($rm, '~2.5'); 
  63. $result = $installer->getLocations(); 
  64. $this->assertContains('Plugin/', $result['plugin']); 
  65.  
  66. // special handling for 2.x versions when 3.x is still in development 
  67. $this->setCakephpVersion($rm, 'dev-master'); 
  68. $result = $installer->getLocations(); 
  69. $this->assertContains('Plugin/', $result['plugin']); 
  70.  
  71. $this->setCakephpVersion($rm, '>=2.5'); 
  72. $result = $installer->getLocations(); 
  73. $this->assertContains('Plugin/', $result['plugin']); 
  74.  
  75. // cakephp >= 3.0 
  76. $this->setCakephpVersion($rm, '3.0.*-dev'); 
  77. $result = $installer->getLocations(); 
  78. $this->assertContains('vendor/{$vendor}/{$name}/', $result['plugin']); 
  79.  
  80. $this->setCakephpVersion($rm, '~8.8'); 
  81. $result = $installer->getLocations(); 
  82. $this->assertContains('vendor/{$vendor}/{$name}/', $result['plugin']); 
  83.  
  84. protected function setCakephpVersion($rm, $version) { 
  85. $parser = new VersionParser(); 
  86. list(, $version) = explode(' ', $parser->parseConstraints($version)); 
  87. $installed = new InstalledArrayRepository(); 
  88. $package = new Package('cakephp/cakephp', $version, $version); 
  89. $installed->addPackage($package); 
  90. $rm->setLocalRepository($installed); 
  91.