mirror of
https://github.com/composer/composer
synced 2025-05-10 09:02:59 +00:00
Update PEAR Package Extractor to use 'task:replace', 'phprelease' commands and install role='script' files
Add PearInstaller Change PEAR packages type from 'library' to 'pear-library' and dist type from 'pear' to 'file' Remove PearDownloader Refactor Channel Installer
This commit is contained in:
parent
0117108efb
commit
ac3cebc633
16 changed files with 305 additions and 150 deletions
|
@ -22,20 +22,26 @@ class PearPackageExtractorTest extends \PHPUnit_Framework_TestCase
|
|||
$method = new \ReflectionMethod($extractor, 'buildCopyActions');
|
||||
$method->setAccessible(true);
|
||||
|
||||
$fileActions = $method->invoke($extractor, __DIR__ . '/Fixtures/Package_v1.0', 'php');
|
||||
$fileActions = $method->invoke($extractor, __DIR__ . '/Fixtures/Package_v1.0', array('php' => '/'), array());
|
||||
|
||||
$expectedFileActions = array(
|
||||
0 => Array(
|
||||
'Gtk.php' => Array(
|
||||
'from' => 'PEAR_Frontend_Gtk-0.4.0/Gtk.php',
|
||||
'to' => 'PEAR/Frontend/Gtk.php',
|
||||
'role' => 'php',
|
||||
'tasks' => array(),
|
||||
),
|
||||
1 => Array(
|
||||
'Gtk/Config.php' => Array(
|
||||
'from' => 'PEAR_Frontend_Gtk-0.4.0/Gtk/Config.php',
|
||||
'to' => 'PEAR/Frontend/Gtk/Config.php',
|
||||
'role' => 'php',
|
||||
'tasks' => array(),
|
||||
),
|
||||
2 => Array(
|
||||
'Gtk/xpm/black_close_icon.xpm' => Array(
|
||||
'from' => 'PEAR_Frontend_Gtk-0.4.0/Gtk/xpm/black_close_icon.xpm',
|
||||
'to' => 'PEAR/Frontend/Gtk/xpm/black_close_icon.xpm',
|
||||
'role' => 'php',
|
||||
'tasks' => array(),
|
||||
)
|
||||
);
|
||||
$this->assertSame($expectedFileActions, $fileActions);
|
||||
|
@ -47,12 +53,14 @@ class PearPackageExtractorTest extends \PHPUnit_Framework_TestCase
|
|||
$method = new \ReflectionMethod($extractor, 'buildCopyActions');
|
||||
$method->setAccessible(true);
|
||||
|
||||
$fileActions = $method->invoke($extractor, __DIR__ . '/Fixtures/Package_v2.0', 'php');
|
||||
$fileActions = $method->invoke($extractor, __DIR__ . '/Fixtures/Package_v2.0', array('php' => '/'), array());
|
||||
|
||||
$expectedFileActions = array(
|
||||
0 => Array(
|
||||
'URL.php' => Array(
|
||||
'from' => 'Net_URL-1.0.15/URL.php',
|
||||
'to' => 'Net/URL.php',
|
||||
'role' => 'php',
|
||||
'tasks' => array(),
|
||||
)
|
||||
);
|
||||
$this->assertSame($expectedFileActions, $fileActions);
|
||||
|
@ -64,18 +72,62 @@ class PearPackageExtractorTest extends \PHPUnit_Framework_TestCase
|
|||
$method = new \ReflectionMethod($extractor, 'buildCopyActions');
|
||||
$method->setAccessible(true);
|
||||
|
||||
$fileActions = $method->invoke($extractor, __DIR__ . '/Fixtures/Package_v2.1', 'php');
|
||||
$fileActions = $method->invoke($extractor, __DIR__ . '/Fixtures/Package_v2.1', array('php' => '/', 'script' => '/bin'), array());
|
||||
|
||||
$expectedFileActions = array(
|
||||
0 => Array(
|
||||
'php/Zend/Authentication/Storage/StorageInterface.php' => Array(
|
||||
'from' => 'Zend_Authentication-2.0.0beta4/php/Zend/Authentication/Storage/StorageInterface.php',
|
||||
'to' => '/php/Zend/Authentication/Storage/StorageInterface.php',
|
||||
'role' => 'php',
|
||||
'tasks' => array(),
|
||||
),
|
||||
1 => Array(
|
||||
'php/Zend/Authentication/Result.php' => Array(
|
||||
'from' => 'Zend_Authentication-2.0.0beta4/php/Zend/Authentication/Result.php',
|
||||
'to' => '/php/Zend/Authentication/Result.php',
|
||||
)
|
||||
'role' => 'php',
|
||||
'tasks' => array(),
|
||||
),
|
||||
'php/Test.php' => array (
|
||||
'from' => 'Zend_Authentication-2.0.0beta4/php/Test.php',
|
||||
'to' => '/php/Test.php',
|
||||
'role' => 'script',
|
||||
'tasks' => array (
|
||||
array (
|
||||
'from' => '@version@',
|
||||
'to' => 'version',
|
||||
)
|
||||
)
|
||||
),
|
||||
'renamedFile.php' => Array(
|
||||
'from' => 'Zend_Authentication-2.0.0beta4/renamedFile.php',
|
||||
'to' => 'correctFile.php',
|
||||
'role' => 'php',
|
||||
'tasks' => array(),
|
||||
),
|
||||
);
|
||||
$this->assertSame($expectedFileActions, $fileActions);
|
||||
}
|
||||
|
||||
public function testShouldPerformReplacements()
|
||||
{
|
||||
$from = tempnam(sys_get_temp_dir(), 'pear-extract');
|
||||
$to = $from.'-to';
|
||||
|
||||
$original = 'replaced: @placeholder@; not replaced: @another@; replaced again: @placeholder@';
|
||||
$expected = 'replaced: value; not replaced: @another@; replaced again: value';
|
||||
|
||||
file_put_contents($from, $original);
|
||||
|
||||
$extractor = new PearPackageExtractor($from);
|
||||
$method = new \ReflectionMethod($extractor, 'copyFile');
|
||||
$method->setAccessible(true);
|
||||
|
||||
$method->invoke($extractor, $from, $to, array(array('from' => '@placeholder@', 'to' => 'variable')), array('variable' => 'value'));
|
||||
$result = file_get_contents($to);
|
||||
|
||||
unlink($to);
|
||||
unlink($from);
|
||||
|
||||
$this->assertEquals($expected, $result);
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue