PearPackageExtractorTest.php 2.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081
  1. <?php
  2. /*
  3. * This file is part of Composer.
  4. *
  5. * (c) Nils Adermann <naderman@naderman.de>
  6. * Jordi Boggiano <j.boggiano@seld.be>
  7. *
  8. * For the full copyright and license information, please view the LICENSE
  9. * file that was distributed with this source code.
  10. */
  11. namespace Composer\Test\Downloader;
  12. use Composer\Downloader\PearPackageExtractor;
  13. class PearPackageExtractorTest extends \PHPUnit_Framework_TestCase
  14. {
  15. public function testShouldExtractPackage_1_0()
  16. {
  17. $extractor = $this->getMockForAbstractClass('Composer\Downloader\PearPackageExtractor', array(), '', false);
  18. $method = new \ReflectionMethod($extractor, 'buildCopyActions');
  19. $method->setAccessible(true);
  20. $fileActions = $method->invoke($extractor, __DIR__ . '/Fixtures/Package_v1.0', 'php');
  21. $expectedFileActions = array(
  22. 0 => Array(
  23. 'from' => 'PEAR_Frontend_Gtk-0.4.0/Gtk.php',
  24. 'to' => 'PEAR/Frontend/Gtk.php',
  25. ),
  26. 1 => Array(
  27. 'from' => 'PEAR_Frontend_Gtk-0.4.0/Gtk/Config.php',
  28. 'to' => 'PEAR/Frontend/Gtk/Config.php',
  29. ),
  30. 2 => Array(
  31. 'from' => 'PEAR_Frontend_Gtk-0.4.0/Gtk/xpm/black_close_icon.xpm',
  32. 'to' => 'PEAR/Frontend/Gtk/xpm/black_close_icon.xpm',
  33. )
  34. );
  35. $this->assertSame($expectedFileActions, $fileActions);
  36. }
  37. public function testShouldExtractPackage_2_0()
  38. {
  39. $extractor = $this->getMockForAbstractClass('Composer\Downloader\PearPackageExtractor', array(), '', false);
  40. $method = new \ReflectionMethod($extractor, 'buildCopyActions');
  41. $method->setAccessible(true);
  42. $fileActions = $method->invoke($extractor, __DIR__ . '/Fixtures/Package_v2.0', 'php');
  43. $expectedFileActions = array(
  44. 0 => Array(
  45. 'from' => 'Net_URL-1.0.15/URL.php',
  46. 'to' => 'Net/URL.php',
  47. )
  48. );
  49. $this->assertSame($expectedFileActions, $fileActions);
  50. }
  51. public function testShouldExtractPackage_2_1()
  52. {
  53. $extractor = $this->getMockForAbstractClass('Composer\Downloader\PearPackageExtractor', array(), '', false);
  54. $method = new \ReflectionMethod($extractor, 'buildCopyActions');
  55. $method->setAccessible(true);
  56. $fileActions = $method->invoke($extractor, __DIR__ . '/Fixtures/Package_v2.1', 'php');
  57. $expectedFileActions = array(
  58. 0 => Array(
  59. 'from' => 'Zend_Authentication-2.0.0beta4/php/Zend/Authentication/Storage/StorageInterface.php',
  60. 'to' => '/php/Zend/Authentication/Storage/StorageInterface.php',
  61. ),
  62. 1 => Array(
  63. 'from' => 'Zend_Authentication-2.0.0beta4/php/Zend/Authentication/Result.php',
  64. 'to' => '/php/Zend/Authentication/Result.php',
  65. )
  66. );
  67. $this->assertSame($expectedFileActions, $fileActions);
  68. }
  69. }