Skip to content

Commit

Permalink
hello phpunit-phar
Browse files Browse the repository at this point in the history
  • Loading branch information
igorw committed Nov 28, 2011
0 parents commit 36d0233
Show file tree
Hide file tree
Showing 5 changed files with 123 additions and 0 deletions.
6 changes: 6 additions & 0 deletions .gitignore
@@ -0,0 +1,6 @@
dbunit
php-*
phpunit
phpunit-*
symfony
phpunit.phar
19 changes: 19 additions & 0 deletions LICENSE
@@ -0,0 +1,19 @@
Copyright (c) 2011 Igor Wiedler

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is furnished
to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
THE SOFTWARE.
12 changes: 12 additions & 0 deletions README.md
@@ -0,0 +1,12 @@
# phpunit-phar

Packages PHPUnit into a phar archive.

## Usage

$ ./vendors.sh
$ php make-phar.php

## License

phpunit-phar is licensed under the MIT license.
70 changes: 70 additions & 0 deletions make-phar.php
@@ -0,0 +1,70 @@
<?php

/*
* This file is part of phpunit-phar.
*
* (c) Igor Wiedler <igor@wiedler.ch>
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/

require __DIR__.'/symfony/src/Symfony/Component/ClassLoader/UniversalClassLoader.php';
$loader = new Symfony\Component\ClassLoader\UniversalClassLoader;
$loader->registerNamespace('Symfony', __DIR__.'/symfony/src');
$loader->register();

$pharFile = 'phpunit.phar';

if (file_exists($pharFile)) {
unlink($pharFile);
}

$phar = new Phar($pharFile, 0, 'phpunit.phar');
$phar->setSignatureAlgorithm(Phar::SHA1);
$phar->startBuffering();

$finder = new Symfony\Component\Finder\Finder();
$finder->files()
->ignoreVCS(true)
->notName('make-phar.php')
->notName('phpunit.phar')
->notName('vendors.sh')
->exclude('symfony')
->exclude('Tests')
->in(__DIR__)
;

foreach ($finder as $file) {
$filename = substr((string)$file, strlen(__DIR__.'/'));
$phar->addFile($filename);
}

$phar->setStub(<<<EOF
<?php
set_include_path(
__DIR__.'/phpunit'.PATH_SEPARATOR.
__DIR__.'/dbunit'.PATH_SEPARATOR.
__DIR__.'/php-file-iterator'.PATH_SEPARATOR.
__DIR__.'/php-text-template'.PATH_SEPARATOR.
__DIR__.'/php-code-coverage'.PATH_SEPARATOR.
__DIR__.'/php-token-stream'.PATH_SEPARATOR.
__DIR__.'/php-timer'.PATH_SEPARATOR.
__DIR__.'/phpunit-mock-objects'.PATH_SEPARATOR.
__DIR__.'/phpunit-selenium'.PATH_SEPARATOR.
__DIR__.'/phpunit-story'.PATH_SEPARATOR.
__DIR__.'/php-invoker'.PATH_SEPARATOR.
get_include_path()
);
require 'PHPUnit/Autoload.php';
PHPUnit_TextUI_Command::main();
__HALT_COMPILER();
EOF
);

$phar->stopBuffering();
unset($phar);
16 changes: 16 additions & 0 deletions vendors.sh
@@ -0,0 +1,16 @@
#!/bin/sh

git clone git://github.com/sebastianbergmann/phpunit.git
git clone git://github.com/sebastianbergmann/dbunit.git
git clone git://github.com/sebastianbergmann/php-file-iterator.git
git clone git://github.com/sebastianbergmann/php-text-template.git
git clone git://github.com/sebastianbergmann/php-code-coverage.git
git clone git://github.com/sebastianbergmann/php-token-stream.git
git clone git://github.com/sebastianbergmann/php-timer.git
git clone git://github.com/sebastianbergmann/phpunit-mock-objects.git
git clone git://github.com/sebastianbergmann/phpunit-selenium.git
git clone git://github.com/sebastianbergmann/phpunit-story.git
git clone git://github.com/sebastianbergmann/php-invoker.git

git clone git://github.com/symfony/ClassLoader.git symfony/src/Symfony/Component/ClassLoader
git clone git://github.com/symfony/Finder.git symfony/src/Symfony/Component/Finder

0 comments on commit 36d0233

Please sign in to comment.