59 lines
1.3 KiB
Ruby
59 lines
1.3 KiB
Ruby
class Composer < Formula
|
|
desc "Dependency Manager for PHP"
|
|
homepage "https://getcomposer.org/"
|
|
url "https://getcomposer.org/download/1.6.4/composer.phar"
|
|
sha256 "8d0d9246f68532cc8fd6a47a58d195f0c849d26430f93c397a3176fc2d971ded"
|
|
|
|
bottle :unneeded
|
|
|
|
def install
|
|
bin.install "composer.phar" => "composer"
|
|
end
|
|
|
|
test do
|
|
(testpath/"composer.json").write <<~EOS
|
|
{
|
|
"name": "homebrew/test",
|
|
"authors": [
|
|
{
|
|
"name": "Homebrew"
|
|
}
|
|
],
|
|
"require": {
|
|
"php": ">=5.3.4"
|
|
},
|
|
"autoload": {
|
|
"psr-0": {
|
|
"HelloWorld": "src/"
|
|
}
|
|
}
|
|
}
|
|
EOS
|
|
|
|
(testpath/"src/HelloWorld/greetings.php").write <<~EOS
|
|
<?php
|
|
|
|
namespace HelloWorld;
|
|
|
|
class Greetings {
|
|
public static function sayHelloWorld() {
|
|
return 'HelloHomebrew';
|
|
}
|
|
}
|
|
EOS
|
|
|
|
(testpath/"tests/test.php").write <<~EOS
|
|
<?php
|
|
|
|
// Autoload files using the Composer autoloader.
|
|
require_once __DIR__ . '/../vendor/autoload.php';
|
|
|
|
use HelloWorld\\Greetings;
|
|
|
|
echo Greetings::sayHelloWorld();
|
|
EOS
|
|
|
|
system "#{bin}/composer", "install"
|
|
assert_match /^HelloHomebrew$/, shell_output("php tests/test.php")
|
|
end
|
|
end
|