Ejemplo n.º 1
0
    {
        $show = (bool) (error_reporting() & $errno);
        if (!$show) {
            return;
        }
        throw new ErrorException($errstr, 0, $errno, $errfile, $errline);
    }
    public static function get_tests()
    {
        $tests = array();
        foreach (glob(Gorilla::$path . '/lib/tests/*.php') as $file) {
            $name = str_replace(Gorilla::$path . '/lib/tests/', '', $file);
            $name = str_replace('.php', '', $name);
            $tests[] = $name;
        }
        return $tests;
    }
    public static function load_phpunit()
    {
        if (!class_exists('PHPUnit_TestCase')) {
            include 'PHPUnit/Autoload.php';
            if (!function_exists('phpunit_autoload')) {
                throw new Exception('PHPUnit could not be loaded');
            }
        }
    }
}
Gorilla::$path = dirname(dirname(dirname(__FILE__)));
spl_autoload_register(array('Gorilla', 'autoload'));
Gorilla::load_phpunit();
set_exception_handler(array('Gorilla', 'exception'));
Ejemplo n.º 2
0
 protected function usage($opts, $error = null)
 {
     $command = empty($opts['using_batch']) ? 'gorilla' : 'gorilla.bat';
     if ($error !== null) {
         printf("%s: %s\n", $command, $error);
     }
     printf("usage: %s [OPTION]... TEST\n\n", $command);
     echo "  -u, --uri, --url\n";
     echo "    AtomPub API URI (required)\n";
     echo "  --user\n";
     echo "    Authentication username\n";
     echo "  --pass\n";
     echo "    Authentication password\n";
     echo "  --auth-type\n";
     echo "    Authentication type (defaults to none, or HTTP Basic if\n      username is specified)\n";
     echo "\nAvailable tests:";
     foreach (Gorilla::get_tests() as $test) {
         echo "\n  " . $test;
     }
     die;
 }
Ejemplo n.º 3
0
<?php

if (in_array('PHPUnit_TextUI_Command', get_declared_classes())) {
    require_once dirname(dirname(__FILE__)) . '/classes/Gorilla.php';
    Gorilla::$runner = new Gorilla_Runner_Server($argv);
}
/**
 * Post document tests
 *
 * @package Gorilla
 * @subpackage API Tests
 */
class EntryPostsTest extends PHPUnit_Framework_TestCase
{
    /**
     * Constructor
     *
     * Set up the 
     */
    public function __construct($name = NULL, array $data = array(), $dataName = '')
    {
        $this->uri = Gorilla::$runner->get_option('uri');
        $this->auth = Gorilla::$runner->get_option('auth');
        $this->document = Requests::get($this->uri . '/service', array(), array(), $this->requestsOptions());
        if ($this->document->status_code !== 200) {
            throw new Exception('Could not GET service document, run ServiceDocumentTest');
        }
        parent::__construct($name, $data, $dataName);
    }
    protected function requestsOptions()
    {