Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?

Shell Script

Using curl:

curl -sS https://gist.github.com/jehoshua02/5580345/raw/a011696ce1005d30fbf8ce8ce77faf274f3fb319/install_phpunit_3.5.sh | sudo sh

Using wget:

wget -O - https://gist.github.com/jehoshua02/5580345/raw/a011696ce1005d30fbf8ce8ce77faf274f3fb319/install_phpunit_3.5.sh | sudo sh

PHP Script

Using curl:

curl -sS https://gist.github.com/jehoshua02/5580345/raw/1bc8fd9e9c8157bfeb2f3c0a7ca2789fa4f42d68/install_phpunit_3.5.php | sudo php

Using wget:

wget -O - https://gist.github.com/jehoshua02/5580345/raw/1bc8fd9e9c8157bfeb2f3c0a7ca2789fa4f42d68/install_phpunit_3.5.php | sudo php
<?php
$getInstalledPackages = function () {
exec('pear list -c phpunit', $output);
echo implode("\n", $output), "\n";
$packages = array();
$pattern = '/^(\w+)\s+([\d\.]+)\s+\w+$/';
foreach ($output as $line) {
if (preg_match($pattern, $line, $matches)) {
list(, $name, $version) = $matches;
$packages[] = sprintf('phpunit/%s-%s', $name, $version);
}
}
return $packages;
};
// uninstall phpunit packages
$packages = $getInstalledPackages();
$status = 0;
if (count($packages) > 0) {
system(sprintf('pear uninstall -n %s', implode(" ", $packages)), $status);
}
unset($packages);
// return if uninstall unsuccessful
if ($status != 0) {
return $status;
}
// packages to install
$packages = array(
// 'pear.symfony-project.com/YAML-1.0.2',
'phpunit/PHPUnit_Selenium-1.0.1',
// 'phpunit/PHPUnit_MockObject-1.0.3',
// 'phpunit/PHP_Timer-1.0.0',
'phpunit/File_Iterator-1.2.3',
'phpunit/PHP_TokenStream-1.0.1',
'phpunit/PHP_CodeCoverage-1.0.2',
// 'phpunit/Text_Template-1.0.0',
'phpunit/DbUnit-1.0.0',
'phpunit/PHPUnit-3.5.15',
);
// execute
system(sprintf('pear install -f %s', implode(' ', $packages)));
// verify
$installedPackages = $getInstalledPackages();
foreach ($packages as $package) {
if (!in_array($package, $installedPackages)) {
echo "Failed: {$package}\n";
}
}
unset($packages, $status, $getInstalledPackages);
#!/bin/sh
# uninstall junk
pear uninstall phpunit/PHPUnit
pear uninstall phpunit/DbUnit
pear uninstall phpunit/PHP_CodeCoverage
pear uninstall phpunit/File_Iterator
pear uninstall phpunit/Text_Template
pear uninstall phpunit/PHP_Timer
pear uninstall phpunit/PHPUnit_MockObject
pear uninstall phpunit/PHPUnit_Selenium
pear uninstall pear.symfony-project.com/YAML
# install junk
pear install pear.symfony-project.com/YAML-1.0.2
pear install phpunit/PHPUnit_Selenium-1.0.1
pear install phpunit/PHPUnit_MockObject-1.0.3
pear install phpunit/PHP_Timer-1.0.0
pear install phpunit/File_Iterator-1.2.3
pear install phpunit/PHP_TokenStream-1.0.1
pear install phpunit/PHP_CodeCoverage-1.0.2
pear install phpunit/Text_Template-1.0.0
pear install phpunit/DbUnit-1.0.0
pear install phpunit/PHPUnit-3.5.15
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.