ComposerInstallersTestGravInstallerTest

The Simple Calendar Composer Installers Test GravInstallerTest class.

Defined (1)

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

/vendor/composer/installers/tests/Composer/Installers/Test/GravInstallerTest.php  
  1. class GravInstallerTest extends TestCase 
  2. /** @var \Composer\Composer */ 
  3. protected $composer; 
  4.  
  5. public function setUp() 
  6. $this->composer = new Composer(); 
  7.  
  8. public function testInflectPackageVars() 
  9. $package = $this->getPackage('vendor/name', '0.0.0'); 
  10. $installer = new GravInstaller($package, $this->composer); 
  11. $packageVars = $this->getPackageVars($package); 
  12.  
  13. $result = $installer->inflectPackageVars(array_merge($packageVars, array('name' => 'test'))); 
  14. $this->assertEquals('test', $result['name']); 
  15.  
  16. foreach ($installer->getLocations() as $name => $location) { 
  17. $result = $installer->inflectPackageVars(array_merge($packageVars, array('name' => "$name-test"))); 
  18. $this->assertEquals('test', $result['name']); 
  19. $result = $installer->inflectPackageVars(array_merge($packageVars, array('name' => "test-$name"))); 
  20. $this->assertEquals('test', $result['name']); 
  21. $result = $installer->inflectPackageVars(array_merge($packageVars, array('name' => "$name-test-test"))); 
  22. $this->assertEquals('test-test', $result['name']); 
  23. $result = $installer->inflectPackageVars(array_merge($packageVars, array('name' => "test-test-$name"))); 
  24. $this->assertEquals('test-test', $result['name']); 
  25. $result = $installer->inflectPackageVars(array_merge($packageVars, array('name' => "grav-$name-test"))); 
  26. $this->assertEquals('test', $result['name']); 
  27. $result = $installer->inflectPackageVars(array_merge($packageVars, array('name' => "grav-test-$name"))); 
  28. $this->assertEquals('test', $result['name']); 
  29. $result = $installer->inflectPackageVars(array_merge($packageVars, array('name' => "grav-$name-test-test"))); 
  30. $this->assertEquals('test-test', $result['name']); 
  31. $result = $installer->inflectPackageVars(array_merge($packageVars, array('name' => "grav-test-test-$name"))); 
  32. $this->assertEquals('test-test', $result['name']); 
  33.  
  34. /** 
  35. * @param $package \Composer\Package\PackageInterface 
  36. */ 
  37. public function getPackageVars($package) 
  38. $type = $package->getType(); 
  39.  
  40. $prettyName = $package->getPrettyName(); 
  41. if (strpos($prettyName, '/') !== false) { 
  42. list($vendor, $name) = explode('/', $prettyName); 
  43. } else { 
  44. $vendor = ''; 
  45. $name = $prettyName; 
  46.  
  47. return compact('name', 'vendor', 'type');