text:
<?php
/**
 * Zend Framework
 *
 * LICENSE
 *
 * This source file is subject to the new BSD license that is bundled
 * with this package in the file LICENSE.txt.
 * It is also available through the world-wide-web at this URL:
 * http://framework.zend.com/license/new-bsd
 * If you did not receive a copy of the license and are unable to
 * obtain it through the world-wide-web, please send an email
 * to license@zend.com so we can send you a copy immediately.
 *
 * @category   Zend
 * @package    Zend_Pdf
 * @copyright  Copyright (c) 2005-2011 Zend Technologies USA Inc. (http://www.zend.com)
 * @license    http://framework.zend.com/license/new-bsd     New BSD License
 * @version    $Id: Html.php 23775 2011-03-01 17:25:24Z ralph $
 */

/** Zend_Pdf_Color */
require_once 'Zend/Pdf/Color.php';

/**
 * HTML color implementation
 *
 * Factory class which vends Zend_Pdf_Color objects from typical HTML
 * representations.
 *
 * @category   Zend
 * @package    Zend_Pdf
 * @copyright  Copyright (c) 2005-2011 Zend Technologies USA Inc. (http://www.zend.com)
 * @license    http://framework.zend.com/license/new-bsd     New BSD License
 */
class Zend_Pdf_Color_Html extends Zend_Pdf_Color
{

    /**
     * Color
     *
     * @var Zend_Pdf_Color
     */
    private $_color;

    /**
     * Class constructor.
     *
     * @param mixed $color
     * @throws Zend_Pdf_Exception
     */
    public function __construct($color)
    {
        $this->_color = self::color($color);
    }

    /**
     * Instructions, which can be directly inserted into content stream
     * to switch color.
     * Color set instructions differ for stroking and nonstroking operations.
     *
     * @param boolean $stroking
     * @return string
     */
    public function instructions($stroking)
    {
        return $this->_color->instructions($stroking);
    }

    /**
     * Get color components (color space dependent)
     *
     * @return array
     */
    public function getComponents()
    {
        return $this->_color->getComponents();
    }

    /**
     * Creates a Zend_Pdf_Color object from the HTML representation.
     *
     * @param string $color May either be a hexidecimal number of the form
     *    #rrggbb or one of the 140 well-known names (black, white, blue, etc.)
     * @return Zend_Pdf_Color
     */
    public static function color($color)
    {
        $pattern = '/^#([A-Fa-f0-9]{2})([A-Fa-f0-9]{2})([A-Fa-f0-9]{2})$/';
        if (preg_match($pattern, $color, $matches)) {
            $r = round((hexdec($matches[1]) / 255), 3);
            $g = round((hexdec($matches[2]) / 255), 3);
            $b = round((hexdec($matches[3]) / 255), 3);
            if (($r == $g) && ($g == $b)) {
                require_once 'Zend/Pdf/Color/GrayScale.php';
                return new Zend_Pdf_Color_GrayScale($r);
            } else {
                require_once 'Zend/Pdf/Color/Rgb.php';
                return new Zend_Pdf_Color_Rgb($r, $g, $b);
            }
        } else {
            return Zend_Pdf_Color_Html::namedColor($color);
        }
    }

    /**
     * Creates a Zend_Pdf_Color object from the named color.
     *
     * @param string $color One of the 140 well-known color names (black, white,
     *    blue, etc.)
     * @return Zend_Pdf_Color
     */
    public static function namedColor($color)
    {
        switch (strtolower($color)) {
            case 'aqua':
                $r = 0.0;   $g = 1.0;   $b = 1.0;   break;
            case 'black':
                $r = 0.0;   $g = 0.0;   $b = 0.0;   break;
            case 'blue':
                $r = 0.0;   $g = 0.0;   $b = 1.0;   break;
            case 'fuchsia':
                $r = 1.0;   $g = 0.0;   $b = 1.0;   break;
            case 'gray':
                $r = 0.502; $g = 0.502; $b = 0.502; break;
            case 'green':
                $r = 0.0;   $g = 0.502; $b = 0.0;   break;
            case 'lime':
                $r = 0.0;   $g = 1.0;   $b = 0.0;   break;
            case 'maroon':
                $r = 0.502; $g = 0.0;   $b = 0.0;   break;
            case 'navy':
                $r = 0.0;   $g = 0.0;   $b = 0.502; break;
            case 'olive':
                $r = 0.502; $g = 0.502; $b = 0.0;   break;
            case 'purple':
                $r = 0.502; $g = 0.0;   $b = 0.502; break;
            case 'red':
                $r = 1.0;   $g = 0.0;   $b = 0.0;   break;
            case 'silver':
                $r = 0.753; $g = 0.753; $b = 0.753; break;
            case 'teal':
                $r = 0.0;   $g = 0.502; $b = 0.502; break;
            case 'white':
                $r = 1.0;   $g = 1.0;   $b = 1.0;   break;
            case 'yellow':
                $r = 1.0;   $g = 1.0;   $b = 0.0;   break;

            case 'aliceblue':
                $r = 0.941; $g = 0.973; $b = 1.0;   break;
            case 'antiquewhite':
                $r = 0.980; $g = 0.922; $b = 0.843; break;
            case 'aquamarine':
                $r = 0.498; $g = 1.0;   $b = 0.831; break;
            case 'azure':
                $r = 0.941; $g = 1.0;   $b = 1.0;   break;
            case 'beige':
                $r = 0.961; $g = 0.961; $b = 0.863; break;
            case 'bisque':
                $r = 1.0;   $g = 0.894; $b = 0.769; break;
            case 'blanchedalmond':
                $r = 1.0;   $g = 1.0;   $b = 0.804; break;
            case 'blueviolet':
                $r = 0.541; $g = 0.169; $b = 0.886; break;
            case 'brown':
                $r = 0.647; $g = 0.165; $b = 0.165; break;
            case 'burlywood':
                $r = 0.871; $g = 0.722; $b = 0.529; break;
            case 'cadetblue':
                $r = 0.373; $g = 0.620; $b = 0.627; break;
            case 'chartreuse':
                $r = 0.498; $g = 1.0;   $b = 0.0;   break;
            case 'chocolate':
                $r = 0.824; $g = 0.412; $b = 0.118; break;
            case 'coral':
                $r = 1.0;   $g = 0.498; $b = 0.314; break;
            case 'cornflowerblue':
                $r = 0.392; $g = 0.584; $b = 0.929; break;
            case 'cornsilk':
                $r = 1.0;   $g = 0.973; $b = 0.863; break;
            case 'crimson':
                $r = 0.863; $g = 0.078; $b = 0.235; break;
            case 'cyan':
                $r = 0.0;   $g = 1.0;   $b = 1.0;   break;
            case 'darkblue':
                $r = 0.0;   $g = 0.0;   $b = 0.545; break;
            case 'darkcyan':
                $r = 0.0;   $g = 0.545; $b = 0.545; break;
            case 'darkgoldenrod':
                $r = 0.722; $g = 0.525; $b = 0.043; break;
            case 'darkgray':
                $r = 0.663; $g = 0.663; $b = 0.663; break;
            case 'darkgreen':
                $r = 0.0;   $g = 0.392; $b = 0.0;   break;
            case 'darkkhaki':
                $r = 0.741; $g = 0.718; $b = 0.420; break;
            case 'darkmagenta':
                $r = 0.545; $g = 0.0;   $b = 0.545; break;
            case 'darkolivegreen':
                $r = 0.333; $g = 0.420; $b = 0.184; break;
            case 'darkorange':
                $r = 1.0;   $g = 0.549; $b = 0.0;   break;
            case 'darkorchid':
                $r = 0.6;   $g = 0.196; $b = 0.8;   break;
            case 'darkred':
                $r = 0.545; $g = 0.0;   $b = 0.0;   break;
            case 'darksalmon':
                $r = 0.914; $g = 0.588; $b = 0.478; break;
            case 'darkseagreen':
                $r = 0.561; $g = 0.737; $b = 0.561; break;
            case 'darkslateblue':
                $r = 0.282; $g = 0.239; $b = 0.545; break;
            case 'darkslategray':
                $r = 0.184; $g = 0.310; $b = 0.310; break;
            case 'darkturquoise':
                $r = 0.0;   $g = 0.808; $b = 0.820; break;
            case 'darkviolet':
                $r = 0.580; $g = 0.0;   $b = 0.827; break;
            case 'deeppink':
                $r = 1.0;   $g = 0.078; $b = 0.576; break;
            case 'deepskyblue':
                $r = 0.0;   $g = 0.749; $b = 1.0;   break;
            case 'dimgray':
                $r = 0.412; $g = 0.412; $b = 0.412; break;
            case 'dodgerblue':
                $r = 0.118; $g = 0.565; $b = 1.0;   break;
            case 'firebrick':
                $r = 0.698; $g = 0.133; $b = 0.133; break;
            case 'floralwhite':
                $r = 1.0;   $g = 0.980; $b = 0.941; break;
            case 'forestgreen':
                $r = 0.133; $g = 0.545; $b = 0.133; break;
            case 'gainsboro':
                $r = 0.863; $g = 0.863; $b = 0.863; break;
            case 'ghostwhite':
                $r = 0.973; $g = 0.973; $b = 1.0;   break;
            case 'gold':
                $r = 1.0;   $g = 0.843; $b = 0.0;   break;
            case 'goldenrod':
                $r = 0.855; $g = 0.647; $b = 0.125; break;
            case 'greenyellow':
                $r = 0.678; $g = 1.0;   $b = 0.184; break;
            case 'honeydew':
                $r = 0.941; $g = 1.0;   $b = 0.941; break;
            case 'hotpink':
                $r = 1.0;   $g = 0.412; $b = 0.706; break;
            case 'indianred':
                $r = 0.804; $g = 0.361; $b = 0.361; break;
            case 'indigo':
                $r = 0.294; $g = 0.0;   $b = 0.510; break;
            case 'ivory':
                $r = 1.0;   $g = 0.941; $b = 0.941; break;
            case 'khaki':
                $r = 0.941; $g = 0.902; $b = 0.549; break;
            case 'lavender':
                $r = 0.902; $g = 0.902; $b = 0.980; break;
            case 'lavenderblush':
                $r = 1.0;   $g = 0.941; $b = 0.961; break;
            case 'lawngreen':
                $r = 0.486; $g = 0.988; $b = 0.0;   break;
            case 'lemonchiffon':
                $r = 1.0;   $g = 0.980; $b = 0.804; break;
            case 'lightblue':
                $r = 0.678; $g = 0.847; $b = 0.902; break;
            case 'lightcoral':
                $r = 0.941; $g = 0.502; $b = 0.502; break;
            case 'lightcyan':
                $r = 0.878; $g = 1.0;   $b = 1.0;   break;
            case 'lightgoldenrodyellow':
                $r = 0.980; $g = 0.980; $b = 0.824; break;
            case 'lightgreen':
                $r = 0.565; $g = 0.933; $b = 0.565; break;
            case 'lightgrey':
                $r = 0.827; $g = 0.827; $b = 0.827; break;
            case 'lightpink':
                $r = 1.0;   $g = 0.714; $b = 0.757; break;
            case 'lightsalmon':
                $r = 1.0;   $g = 0.627; $b = 0.478; break;
            case 'lightseagreen':
                $r = 0.125; $g = 0.698; $b = 0.667; break;
            case 'lightskyblue':
                $r = 0.529; $g = 0.808; $b = 0.980; break;
            case 'lightslategray':
                $r = 0.467; $g = 0.533; $b = 0.6;   break;
            case 'lightsteelblue':
                $r = 0.690; $g = 0.769; $b = 0.871; break;
            case 'lightyellow':
                $r = 1.0;   $g = 1.0;   $b = 0.878; break;
            case 'limegreen':
                $r = 0.196; $g = 0.804; $b = 0.196; break;
            case 'linen':
                $r = 0.980; $g = 0.941; $b = 0.902; break;
            case 'magenta':
                $r = 1.0;   $g = 0.0;   $b = 1.0;   break;
            case 'mediumaquamarine':
                $r = 0.4;   $g = 0.804; $b = 0.667; break;
            case 'mediumblue':
                $r = 0.0;   $g = 0.0;   $b = 0.804; break;
            case 'mediumorchid':
                $r = 0.729; $g = 0.333; $b = 0.827; break;
            case 'mediumpurple':
                $r = 0.576; $g = 0.439; $b = 0.859; break;
            case 'mediumseagreen':
                $r = 0.235; $g = 0.702; $b = 0.443; break;
            case 'mediumslateblue':
                $r = 0.482; $g = 0.408; $b = 0.933; break;
            case 'mediumspringgreen':
                $r = 0.0;   $g = 0.980; $b = 0.604; break;
            case 'mediumturquoise':
                $r = 0.282; $g = 0.820; $b = 0.8;   break;
            case 'mediumvioletred':
                $r = 0.780; $g = 0.082; $b = 0.522; break;
            case 'midnightblue':
                $r = 0.098; $g = 0.098; $b = 0.439; break;
            case 'mintcream':
                $r = 0.961; $g = 1.0;   $b = 0.980; break;
            case 'mistyrose':
                $r = 1.0;   $g = 0.894; $b = 0.882; break;
            case 'moccasin':
                $r = 1.0;   $g = 0.894; $b = 0.710; break;
            case 'navajowhite':
                $r = 1.0;   $g = 0.871; $b = 0.678; break;
            case 'oldlace':
                $r = 0.992; $g = 0.961; $b = 0.902; break;
            case 'olivedrab':
                $r = 0.420; $g = 0.557; $b = 0.137; break;
            case 'orange':
                $r = 1.0;   $g = 0.647; $b = 0.0;   break;
            case 'orangered':
                $r = 1.0;   $g = 0.271; $b = 0.0;   break;
            case 'orchid':
                $r = 0.855; $g = 0.439; $b = 0.839; break;
            case 'palegoldenrod':
                $r = 0.933; $g = 0.910; $b = 0.667; break;
            case 'palegreen':
                $r = 0.596; $g = 0.984; $b = 0.596; break;
            case 'paleturquoise':
                $r = 0.686; $g = 0.933; $b = 0.933; break;
            case 'palevioletred':
                $r = 0.859; $g = 0.439; $b = 0.576; break;
            case 'papayawhip':
                $r = 1.0;   $g = 0.937; $b = 0.835; break;
            case 'peachpuff':
                $r = 1.0;   $g = 0.937; $b = 0.835; break;
            case 'peru':
                $r = 0.804; $g = 0.522; $b = 0.247; break;
            case 'pink':
                $r = 1.0;   $g = 0.753; $b = 0.796; break;
            case 'plum':
                $r = 0.867; $g = 0.627; $b = 0.867; break;
            case 'powderblue':
                $r = 0.690; $g = 0.878; $b = 0.902; break;
            case 'rosybrown':
                $r = 0.737; $g = 0.561; $b = 0.561; break;
            case 'royalblue':
                $r = 0.255; $g = 0.412; $b = 0.882; break;
            case 'saddlebrown':
                $r = 0.545; $g = 0.271; $b = 0.075; break;
            case 'salmon':
                $r = 0.980; $g = 0.502; $b = 0.447; break;
            case 'sandybrown':
                $r = 0.957; $g = 0.643; $b = 0.376; break;
            case 'seagreen':
                $r = 0.180; $g = 0.545; $b = 0.341; break;
            case 'seashell':
                $r = 1.0;   $g = 0.961; $b = 0.933; break;
            case 'sienna':
                $r = 0.627; $g = 0.322; $b = 0.176; break;
            case 'skyblue':
                $r = 0.529; $g = 0.808; $b = 0.922; break;
            case 'slateblue':
                $r = 0.416; $g = 0.353; $b = 0.804; break;
            case 'slategray':
                $r = 0.439; $g = 0.502; $b = 0.565; break;
            case 'snow':
                $r = 1.0;   $g = 0.980; $b = 0.980; break;
            case 'springgreen':
                $r = 0.0;   $g = 1.0;   $b = 0.498; break;
            case 'steelblue':
                $r = 0.275; $g = 0.510; $b = 0.706; break;
            case 'tan':
                $r = 0.824; $g = 0.706; $b = 0.549; break;
            case 'thistle':
                $r = 0.847; $g = 0.749; $b = 0.847; break;
            case 'tomato':
                $r = 0.992; $g = 0.388; $b = 0.278; break;
            case 'turquoise':
                $r = 0.251; $g = 0.878; $b = 0.816; break;
            case 'violet':
                $r = 0.933; $g = 0.510; $b = 0.933; break;
            case 'wheat':
                $r = 0.961; $g = 0.871; $b = 0.702; break;
            case 'whitesmoke':
                $r = 0.961; $g = 0.961; $b = 0.961; break;
            case 'yellowgreen':
                $r = 0.604; $g = 0.804; $b = 0.196; break;

            default:
                require_once 'Zend/Pdf/Exception.php';
                throw new Zend_Pdf_Exception('Unknown color name: ' . $color);
        }
        if (($r == $g) && ($g == $b)) {
            require_once 'Zend/Pdf/Color/GrayScale.php';
            return new Zend_Pdf_Color_GrayScale($r);
        } else {
            require_once 'Zend/Pdf/Color/Rgb.php';
            return new Zend_Pdf_Color_Rgb($r, $g, $b);
        }
    }
}


text:
<?php
/**
 * Zend Framework
 *
 * LICENSE
 *
 * This source file is subject to the new BSD license that is bundled
 * with this package in the file LICENSE.txt.
 * It is also available through the world-wide-web at this URL:
 * http://framework.zend.com/license/new-bsd
 * If you did not receive a copy of the license and are unable to
 * obtain it through the world-wide-web, please send an email
 * to license@zend.com so we can send you a copy immediately.
 *
 * @category   Zend
 * @package    Zend_Pdf
 * @copyright  Copyright (c) 2005-2011 Zend Technologies USA Inc. (http://www.zend.com)
 * @license    http://framework.zend.com/license/new-bsd     New BSD License
 * @version    $Id: Cmyk.php 23775 2011-03-01 17:25:24Z ralph $
 */

/** Internally used classes */
require_once 'Zend/Pdf/Element/Numeric.php';

/** Zend_Pdf_Color */
require_once 'Zend/Pdf/Color.php';

/**
 * CMYK color implementation
 *
 * @category   Zend
 * @package    Zend_Pdf
 * @copyright  Copyright (c) 2005-2011 Zend Technologies USA Inc. (http://www.zend.com)
 * @license    http://framework.zend.com/license/new-bsd     New BSD License
 */
class Zend_Pdf_Color_Cmyk extends Zend_Pdf_Color
{
    /**
     * Cyan level.
     * 0.0 (zero concentration) - 1.0 (maximum concentration)
     *
     * @var Zend_Pdf_Element_Numeric
     */
    private $_c;

    /**
     * Magenta level.
     * 0.0 (zero concentration) - 1.0 (maximum concentration)
     *
     * @var Zend_Pdf_Element_Numeric
     */
    private $_m;

    /**
     * Yellow level.
     * 0.0 (zero concentration) - 1.0 (maximum concentration)
     *
     * @var Zend_Pdf_Element_Numeric
     */
    private $_y;

    /**
     * Key (BlacK) level.
     * 0.0 (zero concentration) - 1.0 (maximum concentration)
     *
     * @var Zend_Pdf_Element_Numeric
     */
    private $_k;

    /**
     * Object constructor
     *
     * @param float $c
     * @param float $m
     * @param float $y
     * @param float $k
     */
    public function __construct($c, $m, $y, $k)
    {
        if ($c < 0) { $c = 0; }
        if ($c > 1) { $c = 1; }

        if ($m < 0) { $m = 0; }
        if ($m > 1) { $m = 1; }

        if ($y < 0) { $y = 0; }
        if ($y > 1) { $y = 1; }

        if ($k < 0) { $k = 0; }
        if ($k > 1) { $k = 1; }

        $this->_c = new Zend_Pdf_Element_Numeric($c);
        $this->_m = new Zend_Pdf_Element_Numeric($m);
        $this->_y = new Zend_Pdf_Element_Numeric($y);
        $this->_k = new Zend_Pdf_Element_Numeric($k);
    }

    /**
     * Instructions, which can be directly inserted into content stream
     * to switch color.
     * Color set instructions differ for stroking and nonstroking operations.
     *
     * @param boolean $stroking
     * @return string
     */
    public function instructions($stroking)
    {
        return $this->_c->toString() . ' '
             . $this->_m->toString() . ' '
             . $this->_y->toString() . ' '
             . $this->_k->toString() .     ($stroking? " K\n" : " k\n");
    }

    /**
     * Get color components (color space dependent)
     *
     * @return array
     */
    public function getComponents()
    {
        return array($this->_c->value, $this->_m->value, $this->_y->value, $this->_k->value);
    }
}

repo_name: michael-romer/zf-boilerplate

repo_language: PHP

mime_type: text/html


text:
<?php
/**
 * Zend Framework
 *
 * LICENSE
 *
 * This source file is subject to the new BSD license that is bundled
 * with this package in the file LICENSE.txt.
 * It is also available through the world-wide-web at this URL:
 * http://framework.zend.com/license/new-bsd
 * If you did not receive a copy of the license and are unable to
 * obtain it through the world-wide-web, please send an email
 * to license@zend.com so we can send you a copy immediately.
 *
 * @category   Zend
 * @package    Zend_Pdf
 * @copyright  Copyright (c) 2005-2011 Zend Technologies USA Inc. (http://www.zend.com)
 * @license    http://framework.zend.com/license/new-bsd     New BSD License
 * @version    $Id: GrayScale.php 23775 2011-03-01 17:25:24Z ralph $
 */

/** Internally used classes */
require_once 'Zend/Pdf/Element/Numeric.php';

/** Zend_Pdf_Color */
require_once 'Zend/Pdf/Color.php';

/**
 * GrayScale color implementation
 *
 * @category   Zend
 * @package    Zend_Pdf
 * @copyright  Copyright (c) 2005-2011 Zend Technologies USA Inc. (http://www.zend.com)
 * @license    http://framework.zend.com/license/new-bsd     New BSD License
 */
class Zend_Pdf_Color_GrayScale extends Zend_Pdf_Color
{
    /**
     * GrayLevel.
     * 0.0 (black) - 1.0 (white)
     *
     * @var Zend_Pdf_Element_Numeric
     */
    private $_grayLevel;

    /**
     * Object constructor
     *
     * @param float $grayLevel
     */
    public function __construct($grayLevel)
    {
        if ($grayLevel < 0) { $grayLevel = 0; }
        if ($grayLevel > 1) { $grayLevel = 1; }

        $this->_grayLevel = new Zend_Pdf_Element_Numeric($grayLevel);
    }

    /**
     * Instructions, which can be directly inserted into content stream
     * to switch color.
     * Color set instructions differ for stroking and nonstroking operations.
     *
     * @param boolean $stroking
     * @return string
     */
    public function instructions($stroking)
    {
        return $this->_grayLevel->toString() . ($stroking? " G\n" : " g\n");
    }

    /**
     * Get color components (color space dependent)
     *
     * @return array
     */
    public function getComponents()
    {
        return array($this->_grayLevel->value);
    }
}


text:
<?php
/**
 * Zend Framework
 *
 * LICENSE
 *
 * This source file is subject to the new BSD license that is bundled
 * with this package in the file LICENSE.txt.
 * It is also available through the world-wide-web at this URL:
 * http://framework.zend.com/license/new-bsd
 * If you did not receive a copy of the license and are unable to
 * obtain it through the world-wide-web, please send an email
 * to license@zend.com so we can send you a copy immediately.
 *
 * @category   Zend
 * @package    Zend_Test
 * @subpackage PHPUnit
 * @copyright  Copyright (c) 2005-2011 Zend Technologies USA Inc. (http://www.zend.com)
 * @license    http://framework.zend.com/license/new-bsd     New BSD License
 * @version    $Id: DbStatement.php 23953 2011-05-03 05:47:39Z ralph $
 */

/**
 * @see Zend_Db_Statement_Interface
 */
require_once "Zend/Db/Statement/Interface.php";

/**
 * Testing Database Statement that acts as a stack to SQL resultsets.
 *
 * @category   Zend
 * @package    Zend_Test
 * @subpackage PHPUnit
 * @copyright  Copyright (c) 2005-2011 Zend Technologies USA Inc. (http://www.zend.com)
 * @license    http://framework.zend.com/license/new-bsd     New BSD License
 */
class Zend_Test_DbStatement implements Zend_Db_Statement_Interface
{
    /**
     * @var array
     */
    protected $_fetchStack = array();

    /**
     * @var int
     */
    protected $_columnCount = 0;

    /**
     * @var int
     */
    protected $_rowCount = 0;

    /**
     * @var Zend_Db_Profiler_Query
     */
    protected $_queryProfile = null;

    /**
     * Create a Select statement which returns the given array of rows.
     *
     * @param array $rows
     * @return Zend_Test_DbStatement
     */
    static public function createSelectStatement(array $rows=array())
    {
        $stmt = new Zend_Test_DbStatement();
        foreach($rows AS $row) {
            $stmt->append($row);
        }
        return $stmt;
    }

    /**
     * Create an Insert Statement
     *
     * @param  int $affectedRows
     * @return Zend_Test_DbStatement
     */
    static public function createInsertStatement($affectedRows=0)
    {
        return self::_createRowCountStatement($affectedRows);
    }

    /**
     * Create an Delete Statement
     *
     * @param  int $affectedRows
     * @return Zend_Test_DbStatement
     */
    static public function createDeleteStatement($affectedRows=0)
    {
        return self::_createRowCountStatement($affectedRows);
    }

    /**
     * Create an Update Statement
     *
     * @param  int $affectedRows
     * @return Zend_Test_DbStatement
     */
    static public function createUpdateStatement($affectedRows=0)
    {
        return self::_createRowCountStatement($affectedRows);
    }

    /**
     * Create a Row Count Statement
     *
     * @param  int $affectedRows
     * @return Zend_Test_DbStatement
     */
    static protected function _createRowCountStatement($affectedRows)
    {
        $stmt = new Zend_Test_DbStatement();
        $stmt->setRowCount($affectedRows);
        return $stmt;
    }

    /**
     * @param Zend_Db_Profiler_Query $qp
     */
    public function setQueryProfile(Zend_Db_Profiler_Query $qp)
    {
        $this->_queryProfile = $qp;
    }

    /**
     * @param int $rowCount
     */
    public function setRowCount($rowCount)
    {
        $this->_rowCount = $rowCount;
    }

    /**
     * Append a new row to the fetch stack.
     *
     * @param array $row
     */
    public function append($row)
    {
        $this->_columnCount = count($row);
        $this->_fetchStack[] = $row;
    }

    /**
     * Bind a column of the statement result set to a PHP variable.
     *
     * @param string $column Name the column in the result set, either by
     *                       position or by name.
     * @param mixed  $param  Reference to the PHP variable containing the value.
     * @param mixed  $type   OPTIONAL
     * @return bool
     * @throws Zend_Db_Statement_Exception
     */
    public function bindColumn($column, &$param, $type = null)
    {
        return true;
    }

    /**
     * Binds a parameter to the specified variable name.
     *
     * @param mixed $parameter Name the parameter, either integer or string.
     * @param mixed $variable  Reference to PHP variable containing the value.
     * @param mixed $type      OPTIONAL Datatype of SQL parameter.
     * @param mixed $length    OPTIONAL Length of SQL parameter.
     * @param mixed $options   OPTIONAL Other options.
     * @return bool
     * @throws Zend_Db_Statement_Exception
     */
    public function bindParam($parameter, &$variable, $type = null, $length = null, $options = null)
    {
        if($this->_queryProfile !== null) {
            $this->_queryProfile->bindParam($parameter, $variable);
        }
        return true;
    }

    /**
     * Binds a value to a parameter.
     *
     * @param mixed $parameter Name the parameter, either integer or string.
     * @param mixed $value     Scalar value to bind to the parameter.
     * @param mixed $type      OPTIONAL Datatype of the parameter.
     * @return bool
     * @throws Zend_Db_Statement_Exception
     */
    public function bindValue($parameter, $value, $type = null)
    {
        return true;
    }

    /**
     * Closes the cursor, allowing the statement to be executed again.
     *
     * @return bool
     * @throws Zend_Db_Statement_Exception
     */
    public function closeCursor()
    {
        return true;
    }

    /**
     * Returns the number of columns in the result set.
     * Returns null if the statement has no result set metadata.
     *
     * @return int The number of columns.
     * @throws Zend_Db_Statement_Exception
     */
    public function columnCount()
    {
        return $this->_columnCount;
    }

    /**
     * Retrieves the error code, if any, associated with the last operation on
     * the statement handle.
     *
     * @return string error code.
     * @throws Zend_Db_Statement_Exception
     */
    public function errorCode()
    {
        return false;
    }

    /**
     * Retrieves an array of error information, if any, associated with the
     * last operation on the statement handle.
     *
     * @return array
     * @throws Zend_Db_Statement_Exception
     */
    public function errorInfo()
    {
        return false;
    }

    /**
     * Executes a prepared statement.
     *
     * @param array $params OPTIONAL Values to bind to parameter placeholders.
     * @return bool
     * @throws Zend_Db_Statement_Exception
     */
    public function execute(array $params = array())
    {
        if($this->_queryProfile !== null) {
            $this->_queryProfile->bindParams($params);
            $this->_queryProfile->end();
        }
        return true;
    }

    /**
     * Fetches a row from the result set.
     *
     * @param int $style  OPTIONAL Fetch mode for this fetch operation.
     * @param int $cursor OPTIONAL Absolute, relative, or other.
     * @param int $offset OPTIONAL Number for absolute or relative cursors.
     * @return mixed Array, object, or scalar depending on fetch mode.
     * @throws Zend_Db_Statement_Exception
     */
    public function fetch($style = null, $cursor = null, $offset = null)
    {
        if(count($this->_fetchStack)) {
            $row = array_shift($this->_fetchStack);
            return $row;
        } else {
            return false;
        }
    }

    /**
     * Returns an array containing all of the result set rows.
     *
     * @param int $style OPTIONAL Fetch mode.
     * @param int $col   OPTIONAL Column number, if fetch mode is by column.
     * @return array Collection of rows, each in a format by the fetch mode.
     * @throws Zend_Db_Statement_Exception
     */
    public function fetchAll($style = null, $col = null)
    {
        $rows = $this->_fetchStack;
        $this->_fetchStack = array();

        return $rows;
    }

    /**
     * Returns a single column from the next row of a result set.
     *
     * @param int $col OPTIONAL Position of the column to fetch.
     * @return string
     * @throws Zend_Db_Statement_Exception
     */
    public function fetchColumn($col = 0)
    {
        $row = $this->fetch();

        if($row == false) {
            return false;
        } else {
            if(count($row) < $col) {
                require_once "Zend/Db/Statement/Exception.php";
                throw new Zend_Db_Statement_Exception(
                    "Column Position '".$col."' is out of bounds."
                );
            }

            $keys = array_keys($row);
            return $row[$keys[$col]];
        }
    }

    /**
     * Fetches the next row and returns it as an object.
     *
     * @param string $class  OPTIONAL Name of the class to create.
     * @param array  $config OPTIONAL Constructor arguments for the class.
     * @return mixed One object instance of the specified class.
     * @throws Zend_Db_Statement_Exception
     */
    public function fetchObject($class = 'stdClass', array $config = array())
    {
        if(!class_exists($class)) {
            throw new Zend_Db_Statement_Exception("Class '".$class."' does not exist!");
        }

        $object = new $class();
        $row = $this->fetch();
        foreach($row AS $k => $v) {
            $object->$k = $v;
        }

        return $object;
    }

    /**
     * Retrieve a statement attribute.
     *
     * @param string $key Attribute name.
     * @return mixed      Attribute value.
     * @throws Zend_Db_Statement_Exception
     */
    public function getAttribute($key)
    {
        return false;
    }

    /**
     * Retrieves the next rowset (result set) for a SQL statement that has
     * multiple result sets.  An example is a stored procedure that returns
     * the results of multiple queries.
     *
     * @return bool
     * @throws Zend_Db_Statement_Exception
     */
    public function nextRowset()
    {
        return false;
    }

    /**
     * Returns the number of rows affected by the execution of the
     * last INSERT, DELETE, or UPDATE statement executed by this
     * statement object.
     *
     * @return int     The number of rows affected.
     * @throws Zend_Db_Statement_Exception
     */
    public function rowCount()
    {
        return $this->_rowCount;
    }

    /**
     * Set a statement attribute.
     *
     * @param string $key Attribute name.
     * @param mixed  $val Attribute value.
     * @return bool
     * @throws Zend_Db_Statement_Exception
     */
    public function setAttribute($key, $val)
    {
        return true;
    }

    /**
     * Set the default fetch mode for this statement.
     *
     * @param int   $mode The fetch mode.
     * @return bool
     * @throws Zend_Db_Statement_Exception
     */
    public function setFetchMode($mode)
    {
        return true;
    }
}


text:
<?php
/**
 * Zend Framework
 *
 * LICENSE
 *
 * This source file is subject to the new BSD license that is bundled
 * with this package in the file LICENSE.txt.
 * It is also available through the world-wide-web at this URL:
 * http://framework.zend.com/license/new-bsd
 * If you did not receive a copy of the license and are unable to
 * obtain it through the world-wide-web, please send an email
 * to license@zend.com so we can send you a copy immediately.
 *
 * @category   Zend
 * @package    Zend_Test
 * @subpackage PHPUnit
 * @copyright  Copyright (c) 2005-2011 Zend Technologies USA Inc. (http://www.zend.com)
 * @license    http://framework.zend.com/license/new-bsd     New BSD License
 * @version    $Id: DbAdapter.php 23953 2011-05-03 05:47:39Z ralph $
 */

/**
 * @see Zend_Db_Adapter_Abstract
 */
require_once "Zend/Db/Adapter/Abstract.php";

/**
 * @see Zend_Test_DbStatement
 */
require_once "Zend/Test/DbStatement.php";

/**
 * @see Zend_Db_Profiler
 */
require_once 'Zend/Db/Profiler.php';

/**
 * Testing Database Adapter which acts as a stack for SQL Results
 *
 * @category   Zend
 * @package    Zend_Test
 * @subpackage PHPUnit
 * @copyright  Copyright (c) 2005-2011 Zend Technologies USA Inc. (http://www.zend.com)
 * @license    http://framework.zend.com/license/new-bsd     New BSD License
 */
class Zend_Test_DbAdapter extends Zend_Db_Adapter_Abstract
{
    /**
     * @var array
     */
    protected $_statementStack = array();

    /**
     * @var boolean
     */
    protected $_connected = false;

    /**
     * @var array
     */
    protected $_listTables = array();

    /**
     * @var array
     */
    protected $_lastInsertIdStack = array();

    /**
     * @var array
     */
    protected $_describeTables = array();

    /**
     * @var string
     */
    protected $_quoteIdentifierSymbol = '';

    /**
     * Empty constructor to make it parameterless.
     */
    public function __construct()
    {
        $profiler = new Zend_Db_Profiler();
        $profiler->setEnabled(true);
        $this->setProfiler($profiler);
    }

    /**
     * Append a new Statement to the SQL Result Stack.
     *
     * @param  Zend_Test_DbStatement $stmt
     * @return Zend_Test_DbAdapter
     */
    public function appendStatementToStack(Zend_Test_DbStatement $stmt)
    {
        array_push($this->_statementStack, $stmt);
        return $this;
    }

    /**
     * Append a new Insert Id to the {@see lastInsertId}.
     *
     * @param  int|string $id
     * @return Zend_Test_DbAdapter
     */
    public function appendLastInsertIdToStack($id)
    {
        array_push($this->_lastInsertIdStack, $id);
        return $this;
    }

    /**
     * @var string
     */
    public function setQuoteIdentifierSymbol($symbol)
    {
        $this->_quoteIdentifierSymbol = $symbol;
    }

    /**
     * Returns the symbol the adapter uses for delimited identifiers.
     *
     * @return string
     */
    public function getQuoteIdentifierSymbol()
    {
        return $this->_quoteIdentifierSymbol;
    }

    /**
     * Set the result from {@see listTables()}.
     *
     * @param array $listTables
     */
    public function setListTables(array $listTables)
    {
        $this->_listTables = $listTables;
    }

    /**
     * Returns a list of the tables in the database.
     *
     * @return array
     */
    public function listTables()
    {
       return $this->_listTables;
    }

    /**
     *
     * @param  string $table
     * @param  array $tableInfo
     * @return Zend_Test_DbAdapter
     */
    public function setDescribeTable($table, $tableInfo)
    {
        $this->_describeTables[$table] = $tableInfo;
        return $this;
    }

    /**
     * Returns the column descriptions for a table.
     *
     * The return value is an associative array keyed by the column name,
     * as returned by the RDBMS.
     *
     * The value of each array element is an associative array
     * with the following keys:
     *
     * SCHEMA_NAME => string; name of database or schema
     * TABLE_NAME  => string;
     * COLUMN_NAME => string; column name
     * COLUMN_POSITION => number; ordinal position of column in table
     * DATA_TYPE   => string; SQL datatype name of column
     * DEFAULT     => string; default expression of column, null if none
     * NULLABLE    => boolean; true if column can have nulls
     * LENGTH      => number; length of CHAR/VARCHAR
     * SCALE       => number; scale of NUMERIC/DECIMAL
     * PRECISION   => number; precision of NUMERIC/DECIMAL
     * UNSIGNED    => boolean; unsigned property of an integer type
     * PRIMARY     => boolean; true if column is part of the primary key
     * PRIMARY_POSITION => integer; position of column in primary key
     *
     * @param string $tableName
     * @param string $schemaName OPTIONAL
     * @return array
     */
    public function describeTable($tableName, $schemaName = null)
    {
        if(isset($this->_describeTables[$tableName])) {
            return $this->_describeTables[$tableName];
        } else {
            return array();
        }
    }

    /**
     * Creates a connection to the database.
     *
     * @return void
     */
    protected function _connect()
    {
        $this->_connected = true;
    }

    /**
     * Test if a connection is active
     *
     * @return boolean
     */
    public function isConnected()
    {
        return $this->_connected;
    }

    /**
     * Force the connection to close.
     *
     * @return void
     */
    public function closeConnection()
    {
        $this->_connected = false;
    }

    /**
     * Prepare a statement and return a PDOStatement-like object.
     *
     * @param string|Zend_Db_Select $sql SQL query
     * @return Zend_Db_Statment|PDOStatement
     */
    public function prepare($sql)
    {
        $queryId = $this->getProfiler()->queryStart($sql);

        if(count($this->_statementStack)) {
            $stmt = array_pop($this->_statementStack);
        } else {
            $stmt = new Zend_Test_DbStatement();
        }

        if($this->getProfiler()->getEnabled() == true) {
            $qp = $this->getProfiler()->getQueryProfile($queryId);
            $stmt->setQueryProfile($qp);
        }

        return $stmt;
    }

    /**
     * Gets the last ID generated automatically by an IDENTITY/AUTOINCREMENT column.
     *
     * As a convention, on RDBMS brands that support sequences
     * (e.g. Oracle, PostgreSQL, DB2), this method forms the name of a sequence
     * from the arguments and returns the last id generated by that sequence.
     * On RDBMS brands that support IDENTITY/AUTOINCREMENT columns, this method
     * returns the last value generated for such a column, and the table name
     * argument is disregarded.
     *
     * @param string $tableName   OPTIONAL Name of table.
     * @param string $primaryKey  OPTIONAL Name of primary key column.
     * @return string
     */
    public function lastInsertId($tableName = null, $primaryKey = null)
    {
        if(count($this->_lastInsertIdStack)) {
            return array_pop($this->_lastInsertIdStack);
        } else {
            return false;
        }
    }

    /**
     * Begin a transaction.
     */
    protected function _beginTransaction()
    {
        return;
    }

    /**
     * Commit a transaction.
     */
    protected function _commit()
    {
        return;
    }

    /**
     * Roll-back a transaction.
     */
    protected function _rollBack()
    {

    }

    /**
     * Set the fetch mode.
     *
     * @param integer $mode
     * @return void
     * @throws Zend_Db_Adapter_Exception
     */
    public function setFetchMode($mode)
    {
        return;
    }

    /**
     * Adds an adapter-specific LIMIT clause to the SELECT statement.
     *
     * @param mixed $sql
     * @param integer $count
     * @param integer $offset
     * @return string
     */
    public function limit($sql, $count, $offset = 0)
    {
        return sprintf('%s LIMIT %d,%d', $sql, $offset, $count);
    }

    /**
     * Check if the adapter supports real SQL parameters.
     *
     * @param string $type 'positional' or 'named'
     * @return bool
     */
    public function supportsParameters($type)
    {
        return true;
    }

    /**
     * Retrieve server version in PHP style
     *
     * @return string
     */
    function getServerVersion()
    {
        return "1.0.0";
    }
}


text:
<?php
/**
 * Zend Framework
 *
 * LICENSE
 *
 * This source file is subject to the new BSD license that is bundled
 * with this package in the file LICENSE.txt.
 * It is also available through the world-wide-web at this URL:
 * http://framework.zend.com/license/new-bsd
 * If you did not receive a copy of the license and are unable to
 * obtain it through the world-wide-web, please send an email
 * to license@zend.com so we can send you a copy immediately.
 *
 * @category   Zend
 * @package    Zend_Test
 * @copyright  Copyright (c) 2005-2011 Zend Technologies USA Inc. (http://www.zend.com)
 * @license    http://framework.zend.com/license/new-bsd     New BSD License
 * @version    $Id: ControllerTestCase.php 24213 2011-07-08 21:16:45Z rdohms $
 */

/** @see PHPUnit_Runner_Version */
require_once 'PHPUnit/Runner/Version.php';

/**
 * Depending on version, include the proper PHPUnit support
 * @see PHPUnit_Autoload
 */
require_once (version_compare(PHPUnit_Runner_Version::id(), '3.5.0', '>=')) ? 'PHPUnit/Autoload.php' : 'PHPUnit/Framework.php';

/** @see Zend_Controller_Front */
require_once 'Zend/Controller/Front.php';

/** @see Zend_Controller_Action_HelperBroker */
require_once 'Zend/Controller/Action/HelperBroker.php';

/** @see Zend_Layout */
require_once 'Zend/Layout.php';

/** @see Zend_Session */
require_once 'Zend/Session.php';

/** @see Zend_Registry */
require_once 'Zend/Registry.php';

/**
 * Functional testing scaffold for MVC applications
 *
 * @uses       PHPUnit_Framework_TestCase
 * @category   Zend
 * @package    Zend_Test
 * @subpackage PHPUnit
 * @copyright  Copyright (c) 2005-2011 Zend Technologies USA Inc. (http://www.zend.com)
 * @license    http://framework.zend.com/license/new-bsd     New BSD License
 */
abstract class Zend_Test_PHPUnit_ControllerTestCase extends PHPUnit_Framework_TestCase
{
    /**
     * @var mixed Bootstrap file path or callback
     */
    public $bootstrap;

    /**
     * @var Zend_Controller_Front
     */
    protected $_frontController;

    /**
     * @var Zend_Dom_Query
     */
    protected $_query;

    /**
     * @var Zend_Controller_Request_Abstract
     */
    protected $_request;

    /**
     * @var Zend_Controller_Response_Abstract
     */
    protected $_response;

    /**
     * XPath namespaces
     * @var array
     */
    protected $_xpathNamespaces = array();

    /**
     * Overloading: prevent overloading to special properties
     *
     * @param  string $name
     * @param  mixed $value
     * @return void
     */
    public function __set($name, $value)
    {
        if (in_array($name, array('request', 'response', 'frontController'))) {
            require_once 'Zend/Exception.php';
            throw new Zend_Exception(sprintf('Setting %s object manually is not allowed', $name));
        }
        $this->$name = $value;
    }

    /**
     * Overloading for common properties
     *
     * Provides overloading for request, response, and frontController objects.
     *
     * @param mixed $name
     * @return void
     */
    public function __get($name)
    {
        switch ($name) {
            case 'request':
                return $this->getRequest();
            case 'response':
                return $this->getResponse();
            case 'frontController':
                return $this->getFrontController();
        }

        return null;
    }

    /**
     * Set up MVC app
     *
     * Calls {@link bootstrap()} by default
     *
     * @return void
     */
    protected function setUp()
    {
        $this->bootstrap();
    }

    /**
     * Bootstrap the front controller
     *
     * Resets the front controller, and then bootstraps it.
     *
     * If {@link $bootstrap} is a callback, executes it; if it is a file, it include's
     * it. When done, sets the test case request and response objects into the
     * front controller.
     *
     * @return void
     */
    final public function bootstrap()
    {
        $this->reset();
        if (null !== $this->bootstrap) {
            if ($this->bootstrap instanceof Zend_Application) {
                $this->bootstrap->bootstrap();
                $this->_frontController = $this->bootstrap->getBootstrap()->getResource('frontcontroller');
            } elseif (is_callable($this->bootstrap)) {
                call_user_func($this->bootstrap);
            } elseif (is_string($this->bootstrap)) {
                require_once 'Zend/Loader.php';
                if (Zend_Loader::isReadable($this->bootstrap)) {
                    include $this->bootstrap;
                }
            }
        }
        $this->frontController
             ->setRequest($this->getRequest())
             ->setResponse($this->getResponse());
    }

    /**
     * Dispatch the MVC
     *
     * If a URL is provided, sets it as the request URI in the request object.
     * Then sets test case request and response objects in front controller,
     * disables throwing exceptions, and disables returning the response.
     * Finally, dispatches the front controller.
     *
     * @param  string|null $url
     * @return void
     */
    public function dispatch($url = null)
    {
        // redirector should not exit
        $redirector = Zend_Controller_Action_HelperBroker::getStaticHelper('redirector');
        $redirector->setExit(false);

        // json helper should not exit
        $json = Zend_Controller_Action_HelperBroker::getStaticHelper('json');
        $json->suppressExit = true;

        $request    = $this->getRequest();
        if (null !== $url) {
            $request->setRequestUri($url);
        }
        $request->setPathInfo(null);

        $controller = $this->getFrontController();
        $this->frontController
             ->setRequest($request)
             ->setResponse($this->getResponse())
             ->throwExceptions(false)
             ->returnResponse(false);

        if ($this->bootstrap instanceof Zend_Application) {
            $this->bootstrap->run();
        } else {
            $this->frontController->dispatch();
        }
    }

    /**
     * Reset MVC state
     *
     * Creates new request/response objects, resets the front controller
     * instance, and resets the action helper broker.
     *
     * @todo   Need to update Zend_Layout to add a resetInstance() method
     * @return void
     */
    public function reset()
    {
        $_SESSION = array();
        $_GET     = array();
        $_POST    = array();
        $_COOKIE  = array();
        $this->resetRequest();
        $this->resetResponse();
        Zend_Layout::resetMvcInstance();
        Zend_Controller_Action_HelperBroker::resetHelpers();
        $this->frontController->resetInstance();
        Zend_Session::$_unitTestEnabled = true;
    }

    /**
     * Rest all view placeholders
     *
     * @return void
     */
    protected function _resetPlaceholders()
    {
        $registry = Zend_Registry::getInstance();
        $remove   = array();
        foreach ($registry as $key => $value) {
            if (strstr($key, '_View_')) {
                $remove[] = $key;
            }
        }

        foreach ($remove as $key) {
            unset($registry[$key]);
        }
    }

    /**
     * Reset the request object
     *
     * Useful for test cases that need to test multiple trips to the server.
     *
     * @return Zend_Test_PHPUnit_ControllerTestCase
     */
    public function resetRequest()
    {
        if ($this->_request instanceof Zend_Controller_Request_HttpTestCase) {
            $this->_request->clearQuery()
                           ->clearPost();
        }
        $this->_request = null;
        return $this;
    }

    /**
     * Reset the response object
     *
     * Useful for test cases that need to test multiple trips to the server.
     *
     * @return Zend_Test_PHPUnit_ControllerTestCase
     */
    public function resetResponse()
    {
        $this->_response = null;
        $this->_resetPlaceholders();
        return $this;
    }

    /**
     * Assert against DOM selection
     *
     * @param  string $path CSS selector path
     * @param  string $message
     * @return void
     */
    public function assertQuery($path, $message = '')
    {
        $this->_incrementAssertionCount();
        require_once 'Zend/Test/PHPUnit/Constraint/DomQuery.php';
        $constraint = new Zend_Test_PHPUnit_Constraint_DomQuery($path);
        $content    = $this->response->outputBody();
        if (!$constraint->evaluate($content, __FUNCTION__)) {
            $constraint->fail($path, $message);
        }
    }

    /**
     * Assert against DOM selection
     *
     * @param  string $path CSS selector path
     * @param  string $message
     * @return void
     */
    public function assertNotQuery($path, $message = '')
    {
        $this->_incrementAssertionCount();
        require_once 'Zend/Test/PHPUnit/Constraint/DomQuery.php';
        $constraint = new Zend_Test_PHPUnit_Constraint_DomQuery($path);
        $content    = $this->response->outputBody();
        if (!$constraint->evaluate($content, __FUNCTION__)) {
            $constraint->fail($path, $message);
        }
    }

    /**
     * Assert against DOM selection; node should contain content
     *
     * @param  string $path CSS selector path
     * @param  string $match content that should be contained in matched nodes
     * @param  string $message
     * @return void
     */
    public function assertQueryContentContains($path, $match, $message = '')
    {
        $this->_incrementAssertionCount();
        require_once 'Zend/Test/PHPUnit/Constraint/DomQuery.php';
        $constraint = new Zend_Test_PHPUnit_Constraint_DomQuery($path);
        $content    = $this->response->outputBody();
        if (!$constraint->evaluate($content, __FUNCTION__, $match)) {
            $constraint->fail($path, $message);
        }
    }

    /**
     * Assert against DOM selection; node should NOT contain content
     *
     * @param  string $path CSS selector path
     * @param  string $match content that should NOT be contained in matched nodes
     * @param  string $message
     * @return void
     */
    public function assertNotQueryContentContains($path, $match, $message = '')
    {
        $this->_incrementAssertionCount();
        require_once 'Zend/Test/PHPUnit/Constraint/DomQuery.php';
        $constraint = new Zend_Test_PHPUnit_Constraint_DomQuery($path);
        $content    = $this->response->outputBody();
        if (!$constraint->evaluate($content, __FUNCTION__, $match)) {
            $constraint->fail($path, $message);
        }
    }

    /**
     * Assert against DOM selection; node should match content
     *
     * @param  string $path CSS selector path
     * @param  string $pattern Pattern that should be contained in matched nodes
     * @param  string $message
     * @return void
     */
    public function assertQueryContentRegex($path, $pattern, $message = '')
    {
        $this->_incrementAssertionCount();
        require_once 'Zend/Test/PHPUnit/Constraint/DomQuery.php';
        $constraint = new Zend_Test_PHPUnit_Constraint_DomQuery($path);
        $content    = $this->response->outputBody();
        if (!$constraint->evaluate($content, __FUNCTION__, $pattern)) {
            $constraint->fail($path, $message);
        }
    }

    /**
     * Assert against DOM selection; node should NOT match content
     *
     * @param  string $path CSS selector path
     * @param  string $pattern pattern that should NOT be contained in matched nodes
     * @param  string $message
     * @return void
     */
    public function assertNotQueryContentRegex($path, $pattern, $message = '')
    {
        $this->_incrementAssertionCount();
        require_once 'Zend/Test/PHPUnit/Constraint/DomQuery.php';
        $constraint = new Zend_Test_PHPUnit_Constraint_DomQuery($path);
        $content    = $this->response->outputBody();
        if (!$constraint->evaluate($content, __FUNCTION__, $pattern)) {
            $constraint->fail($path, $message);
        }
    }

    /**
     * Assert against DOM selection; should contain exact number of nodes
     *
     * @param  string $path CSS selector path
     * @param  string $count Number of nodes that should match
     * @param  string $message
     * @return void
     */
    public function assertQueryCount($path, $count, $message = '')
    {
        $this->_incrementAssertionCount();
        require_once 'Zend/Test/PHPUnit/Constraint/DomQuery.php';
        $constraint = new Zend_Test_PHPUnit_Constraint_DomQuery($path);
        $content    = $this->response->outputBody();
        if (!$constraint->evaluate($content, __FUNCTION__, $count)) {
            $constraint->fail($path, $message);
        }
    }

    /**
     * Assert against DOM selection; should NOT contain exact number of nodes
     *
     * @param  string $path CSS selector path
     * @param  string $count Number of nodes that should NOT match
     * @param  string $message
     * @return void
     */
    public function assertNotQueryCount($path, $count, $message = '')
    {
        $this->_incrementAssertionCount();
        require_once 'Zend/Test/PHPUnit/Constraint/DomQuery.php';
        $constraint = new Zend_Test_PHPUnit_Constraint_DomQuery($path);
        $content    = $this->response->outputBody();
        if (!$constraint->evaluate($content, __FUNCTION__, $count)) {
            $constraint->fail($path, $message);
        }
    }

    /**
     * Assert against DOM selection; should contain at least this number of nodes
     *
     * @param  string $path CSS selector path
     * @param  string $count Minimum number of nodes that should match
     * @param  string $message
     * @return void
     */
    public function assertQueryCountMin($path, $count, $message = '')
    {
        $this->_incrementAssertionCount();
        require_once 'Zend/Test/PHPUnit/Constraint/DomQuery.php';
        $constraint = new Zend_Test_PHPUnit_Constraint_DomQuery($path);
        $content    = $this->response->outputBody();
        if (!$constraint->evaluate($content, __FUNCTION__, $count)) {
            $constraint->fail($path, $message);
        }
    }

    /**
     * Assert against DOM selection; should contain no more than this number of nodes
     *
     * @param  string $path CSS selector path
     * @param  string $count Maximum number of nodes that should match
     * @param  string $message
     * @return void
     */
    public function assertQueryCountMax($path, $count, $message = '')
    {
        $this->_incrementAssertionCount();
        require_once 'Zend/Test/PHPUnit/Constraint/DomQuery.php';
        $constraint = new Zend_Test_PHPUnit_Constraint_DomQuery($path);
        $content    = $this->response->outputBody();
        if (!$constraint->evaluate($content, __FUNCTION__, $count)) {
            $constraint->fail($path, $message);
        }
    }

    /**
     * Register XPath namespaces
     *
     * @param   array $xpathNamespaces
     * @return  void
     */
    public function registerXpathNamespaces($xpathNamespaces)
    {
        $this->_xpathNamespaces = $xpathNamespaces;
    }

    /**
     * Assert against XPath selection
     *
     * @param  string $path XPath path
     * @param  string $message
     * @return void
     */
    public function assertXpath($path, $message = '')
    {
        $this->_incrementAssertionCount();
        require_once 'Zend/Test/PHPUnit/Constraint/DomQuery.php';
        $constraint = new Zend_Test_PHPUnit_Constraint_DomQuery($path);
        $constraint->registerXpathNamespaces($this->_xpathNamespaces);
        $content    = $this->response->outputBody();
        if (!$constraint->evaluate($content, __FUNCTION__)) {
            $constraint->fail($path, $message);
        }
    }

    /**
     * Assert against XPath selection
     *
     * @param  string $path XPath path
     * @param  string $message
     * @return void
     */
    public function assertNotXpath($path, $message = '')
    {
        $this->_incrementAssertionCount();
        require_once 'Zend/Test/PHPUnit/Constraint/DomQuery.php';
        $constraint = new Zend_Test_PHPUnit_Constraint_DomQuery($path);
        $constraint->registerXpathNamespaces($this->_xpathNamespaces);
        $content    = $this->response->outputBody();
        if (!$constraint->evaluate($content, __FUNCTION__)) {
            $constraint->fail($path, $message);
        }
    }

    /**
     * Assert against XPath selection; node should contain content
     *
     * @param  string $path XPath path
     * @param  string $match content that should be contained in matched nodes
     * @param  string $message
     * @return void
     */
    public function assertXpathContentContains($path, $match, $message = '')
    {
        $this->_incrementAssertionCount();
        require_once 'Zend/Test/PHPUnit/Constraint/DomQuery.php';
        $constraint = new Zend_Test_PHPUnit_Constraint_DomQuery($path);
        $constraint->registerXpathNamespaces($this->_xpathNamespaces);
        $content    = $this->response->outputBody();
        if (!$constraint->evaluate($content, __FUNCTION__, $match)) {
            $constraint->fail($path, $message);
        }
    }

    /**
     * Assert against XPath selection; node should NOT contain content
     *
     * @param  string $path XPath path
     * @param  string $match content that should NOT be contained in matched nodes
     * @param  string $message
     * @return void
     */
    public function assertNotXpathContentContains($path, $match, $message = '')
    {
        $this->_incrementAssertionCount();
        require_once 'Zend/Test/PHPUnit/Constraint/DomQuery.php';
        $constraint = new Zend_Test_PHPUnit_Constraint_DomQuery($path);
        $constraint->registerXpathNamespaces($this->_xpathNamespaces);
        $content    = $this->response->outputBody();
        if (!$constraint->evaluate($content, __FUNCTION__, $match)) {
            $constraint->fail($path, $message);
        }
    }

    /**
     * Assert against XPath selection; node should match content
     *
     * @param  string $path XPath path
     * @param  string $pattern Pattern that should be contained in matched nodes
     * @param  string $message
     * @return void
     */
    public function assertXpathContentRegex($path, $pattern, $message = '')
    {
        $this->_incrementAssertionCount();
        require_once 'Zend/Test/PHPUnit/Constraint/DomQuery.php';
        $constraint = new Zend_Test_PHPUnit_Constraint_DomQuery($path);
        $constraint->registerXpathNamespaces($this->_xpathNamespaces);
        $content    = $this->response->outputBody();
        if (!$constraint->evaluate($content, __FUNCTION__, $pattern)) {
            $constraint->fail($path, $message);
        }
    }

    /**
     * Assert against XPath selection; node should NOT match content
     *
     * @param  string $path XPath path
     * @param  string $pattern pattern that should NOT be contained in matched nodes
     * @param  string $message
     * @return void
     */
    public function assertNotXpathContentRegex($path, $pattern, $message = '')
    {
        $this->_incrementAssertionCount();
        require_once 'Zend/Test/PHPUnit/Constraint/DomQuery.php';
        $constraint = new Zend_Test_PHPUnit_Constraint_DomQuery($path);
        $constraint->registerXpathNamespaces($this->_xpathNamespaces);
        $content    = $this->response->outputBody();
        if (!$constraint->evaluate($content, __FUNCTION__, $pattern)) {
            $constraint->fail($path, $message);
        }
    }

    /**
     * Assert against XPath selection; should contain exact number of nodes
     *
     * @param  string $path XPath path
     * @param  string $count Number of nodes that should match
     * @param  string $message
     * @return void
     */
    public function assertXpathCount($path, $count, $message = '')
    {
        $this->_incrementAssertionCount();
        require_once 'Zend/Test/PHPUnit/Constraint/DomQuery.php';
        $constraint = new Zend_Test_PHPUnit_Constraint_DomQuery($path);
        $constraint->registerXpathNamespaces($this->_xpathNamespaces);
        $content    = $this->response->outputBody();
        if (!$constraint->evaluate($content, __FUNCTION__, $count)) {
            $constraint->fail($path, $message);
        }
    }

    /**
     * Assert against XPath selection; should NOT contain exact number of nodes
     *
     * @param  string $path XPath path
     * @param  string $count Number of nodes that should NOT match
     * @param  string $message
     * @return void
     */
    public function assertNotXpathCount($path, $count, $message = '')
    {
        $this->_incrementAssertionCount();
        require_once 'Zend/Test/PHPUnit/Constraint/DomQuery.php';
        $constraint = new Zend_Test_PHPUnit_Constraint_DomQuery($path);
        $constraint->registerXpathNamespaces($this->_xpathNamespaces);
        $content    = $this->response->outputBody();
        if (!$constraint->evaluate($content, __FUNCTION__, $count)) {
            $constraint->fail($path, $message);
        }
    }

    /**
     * Assert against XPath selection; should contain at least this number of nodes
     *
     * @param  string $path XPath path
     * @param  string $count Minimum number of nodes that should match
     * @param  string $message
     * @return void
     */
    public function assertXpathCountMin($path, $count, $message = '')
    {
        $this->_incrementAssertionCount();
        require_once 'Zend/Test/PHPUnit/Constraint/DomQuery.php';
        $constraint = new Zend_Test_PHPUnit_Constraint_DomQuery($path);
        $constraint->registerXpathNamespaces($this->_xpathNamespaces);
        $content    = $this->response->outputBody();
        if (!$constraint->evaluate($content, __FUNCTION__, $count)) {
            $constraint->fail($path, $message);
        }
    }

    /**
     * Assert against XPath selection; should contain no more than this number of nodes
     *
     * @param  string $path XPath path
     * @param  string $count Maximum number of nodes that should match
     * @param  string $message
     * @return void
     */
    public function assertXpathCountMax($path, $count, $message = '')
    {
        $this->_incrementAssertionCount();
        require_once 'Zend/Test/PHPUnit/Constraint/DomQuery.php';
        $constraint = new Zend_Test_PHPUnit_Constraint_DomQuery($path);
        $constraint->registerXpathNamespaces($this->_xpathNamespaces);
        $content    = $this->response->outputBody();
        if (!$constraint->evaluate($content, __FUNCTION__, $count)) {
            $constraint->fail($path, $message);
        }
    }

    /**
     * Assert that response is a redirect
     *
     * @param  string $message
     * @return void
     */
    public function assertRedirect($message = '')
    {
        $this->_incrementAssertionCount();
        require_once 'Zend/Test/PHPUnit/Constraint/Redirect.php';
        $constraint = new Zend_Test_PHPUnit_Constraint_Redirect();
        $response   = $this->response;
        if (!$constraint->evaluate($response, __FUNCTION__)) {
            $constraint->fail($response, $message);
        }
    }

    /**
     * Assert that response is NOT a redirect
     *
     * @param  string $message
     * @return void
     */
    public function assertNotRedirect($message = '')
    {
        $this->_incrementAssertionCount();
        require_once 'Zend/Test/PHPUnit/Constraint/Redirect.php';
        $constraint = new Zend_Test_PHPUnit_Constraint_Redirect();
        $response   = $this->response;
        if (!$constraint->evaluate($response, __FUNCTION__)) {
            $constraint->fail($response, $message);
        }
    }

    /**
     * Assert that response redirects to given URL
     *
     * @param  string $url
     * @param  string $message
     * @return void
     */
    public function assertRedirectTo($url, $message = '')
    {
        $this->_incrementAssertionCount();
        require_once 'Zend/Test/PHPUnit/Constraint/Redirect.php';
        $constraint = new Zend_Test_PHPUnit_Constraint_Redirect();
        $response   = $this->response;
        if (!$constraint->evaluate($response, __FUNCTION__, $url)) {
            $constraint->fail($response, $message);
        }
    }

    /**
     * Assert that response does not redirect to given URL
     *
     * @param  string $url
     * @param  string $message
     * @return void
     */
    public function assertNotRedirectTo($url, $message = '')
    {
        $this->_incrementAssertionCount();
        require_once 'Zend/Test/PHPUnit/Constraint/Redirect.php';
        $constraint = new Zend_Test_PHPUnit_Constraint_Redirect();
        $response   = $this->response;
        if (!$constraint->evaluate($response, __FUNCTION__, $url)) {
            $constraint->fail($response, $message);
        }
    }

    /**
     * Assert that redirect location matches pattern
     *
     * @param  string $pattern
     * @param  string $message
     * @return void
     */
    public function assertRedirectRegex($pattern, $message = '')
    {
        $this->_incrementAssertionCount();
        require_once 'Zend/Test/PHPUnit/Constraint/Redirect.php';
        $constraint = new Zend_Test_PHPUnit_Constraint_Redirect();
        $response   = $this->response;
        if (!$constraint->evaluate($response, __FUNCTION__, $pattern)) {
            $constraint->fail($response, $message);
        }
    }

    /**
     * Assert that redirect location does not match pattern
     *
     * @param  string $pattern
     * @param  string $message
     * @return void
     */
    public function assertNotRedirectRegex($pattern, $message = '')
    {
        $this->_incrementAssertionCount();
        require_once 'Zend/Test/PHPUnit/Constraint/Redirect.php';
        $constraint = new Zend_Test_PHPUnit_Constraint_Redirect();
        $response   = $this->response;
        if (!$constraint->evaluate($response, __FUNCTION__, $pattern)) {
            $constraint->fail($response, $message);
        }
    }

    /**
     * Assert response code
     *
     * @param  int $code
     * @param  string $message
     * @return void
     */
    public function assertResponseCode($code, $message = '')
    {
        $this->_incrementAssertionCount();
        require_once 'Zend/Test/PHPUnit/Constraint/ResponseHeader.php';
        $constraint = new Zend_Test_PHPUnit_Constraint_ResponseHeader();
        $response   = $this->response;
        if (!$constraint->evaluate($response, __FUNCTION__, $code)) {
            $constraint->fail($response, $message);
        }
    }

    /**
     * Assert response code
     *
     * @param  int $code
     * @param  string $message
     * @return void
     */
    public function assertNotResponseCode($code, $message = '')
    {
        $this->_incrementAssertionCount();
        require_once 'Zend/Test/PHPUnit/Constraint/ResponseHeader.php';
        $constraint = new Zend_Test_PHPUnit_Constraint_ResponseHeader();
        $constraint->setNegate(true);
        $response   = $this->response;
        if (!$constraint->evaluate($response, __FUNCTION__, $code)) {
            $constraint->fail($response, $message);
        }
    }

    /**
     * Assert response header exists
     *
     * @param  string $header
     * @param  string $message
     * @return void
     */
    public function assertHeader($header, $message = '')
    {
        $this->_incrementAssertionCount();
        require_once 'Zend/Test/PHPUnit/Constraint/ResponseHeader.php';
        $constraint = new Zend_Test_PHPUnit_Constraint_ResponseHeader();
        $response   = $this->response;
        if (!$constraint->evaluate($response, __FUNCTION__, $header)) {
            $constraint->fail($response, $message);
        }
    }

    /**
     * Assert response header does not exist
     *
     * @param  string $header
     * @param  string $message
     * @return void
     */
    public function assertNotHeader($header, $message = '')
    {
        $this->_incrementAssertionCount();
        require_once 'Zend/Test/PHPUnit/Constraint/ResponseHeader.php';
        $constraint = new Zend_Test_PHPUnit_Constraint_ResponseHeader();
        $constraint->setNegate(true);
        $response   = $this->response;
        if (!$constraint->evaluate($response, __FUNCTION__, $header)) {
            $constraint->fail($response, $message);
        }
    }

    /**
     * Assert response header exists and contains the given string
     *
     * @param  string $header
     * @param  string $match
     * @param  string $message
     * @return void
     */
    public function assertHeaderContains($header, $match, $message = '')
    {
        $this->_incrementAssertionCount();
        require_once 'Zend/Test/PHPUnit/Constraint/ResponseHeader.php';
        $constraint = new Zend_Test_PHPUnit_Constraint_ResponseHeader();
        $response   = $this->response;
        if (!$constraint->evaluate($response, __FUNCTION__, $header, $match)) {
            $constraint->fail($response, $message);
        }
    }

    /**
     * Assert response header does not exist and/or does not contain the given string
     *
     * @param  string $header
     * @param  string $match
     * @param  string $message
     * @return void
     */
    public function assertNotHeaderContains($header, $match, $message = '')
    {
        $this->_incrementAssertionCount();
        require_once 'Zend/Test/PHPUnit/Constraint/ResponseHeader.php';
        $constraint = new Zend_Test_PHPUnit_Constraint_ResponseHeader();
        $constraint->setNegate(true);
        $response   = $this->response;
        if (!$constraint->evaluate($response, __FUNCTION__, $header, $match)) {
            $constraint->fail($response, $message);
        }
    }

    /**
     * Assert response header exists and matches the given pattern
     *
     * @param  string $header
     * @param  string $pattern
     * @param  string $message
     * @return void
     */
    public function assertHeaderRegex($header, $pattern, $message = '')
    {
        $this->_incrementAssertionCount();
        require_once 'Zend/Test/PHPUnit/Constraint/ResponseHeader.php';
        $constraint = new Zend_Test_PHPUnit_Constraint_ResponseHeader();
        $response   = $this->response;
        if (!$constraint->evaluate($response, __FUNCTION__, $header, $pattern)) {
            $constraint->fail($response, $message);
        }
    }

    /**
     * Assert response header does not exist and/or does not match the given regex
     *
     * @param  string $header
     * @param  string $pattern
     * @param  string $message
     * @return void
     */
    public function assertNotHeaderRegex($header, $pattern, $message = '')
    {
        $this->_incrementAssertionCount();
        require_once 'Zend/Test/PHPUnit/Constraint/ResponseHeader.php';
        $constraint = new Zend_Test_PHPUnit_Constraint_ResponseHeader();
        $constraint->setNegate(true);
        $response   = $this->response;
        if (!$constraint->evaluate($response, __FUNCTION__, $header, $pattern)) {
            $constraint->fail($response, $message);
        }
    }

    /**
     * Assert that the last handled request used the given module
     *
     * @param  string $module
     * @param  string $message
     * @return void
     */
    public function assertModule($module, $message = '')
    {
        $this->_incrementAssertionCount();
        if ($module != $this->request->getModuleName()) {
            $msg = sprintf('Failed asserting last module used <"%s"> was "%s"',
                $this->request->getModuleName(),
                $module
            );
            if (!empty($message)) {
                $msg = $message . "\n" . $msg;
            }
            $this->fail($msg);
        }
    }

    /**
     * Assert that the last handled request did NOT use the given module
     *
     * @param  string $module
     * @param  string $message
     * @return void
     */
    public function assertNotModule($module, $message = '')
    {
        $this->_incrementAssertionCount();
        if ($module == $this->request->getModuleName()) {
            $msg = sprintf('Failed asserting last module used was NOT "%s"', $module);
            if (!empty($message)) {
                $msg = $message . "\n" . $msg;
            }
            $this->fail($msg);
        }
    }

    /**
     * Assert that the last handled request used the given controller
     *
     * @param  string $controller
     * @param  string $message
     * @return void
     */
    public function assertController($controller, $message = '')
    {
        $this->_incrementAssertionCount();
        if ($controller != $this->request->getControllerName()) {
            $msg = sprintf('Failed asserting last controller used <"%s"> was "%s"',
                $this->request->getControllerName(),
                $controller
            );
            if (!empty($message)) {
                $msg = $message . "\n" . $msg;
            }
            $this->fail($msg);
        }
    }

    /**
     * Assert that the last handled request did NOT use the given controller
     *
     * @param  string $controller
     * @param  string $message
     * @return void
     */
    public function assertNotController($controller, $message = '')
    {
        $this->_incrementAssertionCount();
        if ($controller == $this->request->getControllerName()) {
            $msg = sprintf('Failed asserting last controller used <"%s"> was NOT "%s"',
                $this->request->getControllerName(),
                $controller
            );
            if (!empty($message)) {
                $msg = $message . "\n" . $msg;
            }
            $this->fail($msg);
        }
    }

    /**
     * Assert that the last handled request used the given action
     *
     * @param  string $action
     * @param  string $message
     * @return void
     */
    public function assertAction($action, $message = '')
    {
        $this->_incrementAssertionCount();
        if ($action != $this->request->getActionName()) {
            $msg = sprintf('Failed asserting last action used <"%s"> was "%s"', $this->request->getActionName(), $action);
            if (!empty($message)) {
                $msg = $message . "\n" . $msg;
            }
            $this->fail($msg);
        }
    }

    /**
     * Assert that the last handled request did NOT use the given action
     *
     * @param  string $action
     * @param  string $message
     * @return void
     */
    public function assertNotAction($action, $message = '')
    {
        $this->_incrementAssertionCount();
        if ($action == $this->request->getActionName()) {
            $msg = sprintf('Failed asserting last action used <"%s"> was NOT "%s"', $this->request->getActionName(), $action);
            if (!empty($message)) {
                $msg = $message . "\n" . $msg;
            }
            $this->fail($msg);
        }
    }

    /**
     * Assert that the specified route was used
     *
     * @param  string $route
     * @param  string $message
     * @return void
     */
    public function assertRoute($route, $message = '')
    {
        $this->_incrementAssertionCount();
        $router = $this->frontController->getRouter();
        if ($route != $router->getCurrentRouteName()) {
            $msg = sprintf('Failed asserting matched route was "%s", actual route is %s',
                $route,
                $router->getCurrentRouteName()
            );
            if (!empty($message)) {
                $msg = $message . "\n" . $msg;
            }
            $this->fail($msg);
        }
    }

    /**
     * Assert that the route matched is NOT as specified
     *
     * @param  string $route
     * @param  string $message
     * @return void
     */
    public function assertNotRoute($route, $message = '')
    {
        $this->_incrementAssertionCount();
        $router = $this->frontController->getRouter();
        if ($route == $router->getCurrentRouteName()) {
            $msg = sprintf('Failed asserting route matched was NOT "%s"', $route);
            if (!empty($message)) {
                $msg = $message . "\n" . $msg;
            }
            $this->fail($msg);
        }
    }

    /**
     * Retrieve front controller instance
     *
     * @return Zend_Controller_Front
     */
    public function getFrontController()
    {
        if (null === $this->_frontController) {
            $this->_frontController = Zend_Controller_Front::getInstance();
        }
        return $this->_frontController;
    }

    /**
     * Retrieve test case request object
     *
     * @return Zend_Controller_Request_HttpTestCase
     */
    public function getRequest()
    {
        if (null === $this->_request) {
            require_once 'Zend/Controller/Request/HttpTestCase.php';
            $this->_request = new Zend_Controller_Request_HttpTestCase;
        }
        return $this->_request;
    }

    /**
     * Retrieve test case response object
     *
     * @return Zend_Controller_Response_HttpTestCase
     */
    public function getResponse()
    {
        if (null === $this->_response) {
            require_once 'Zend/Controller/Response/HttpTestCase.php';
            $this->_response = new Zend_Controller_Response_HttpTestCase;
        }
        return $this->_response;
    }

    /**
     * Retrieve DOM query object
     *
     * @return Zend_Dom_Query
     */
    public function getQuery()
    {
        if (null === $this->_query) {
            require_once 'Zend/Dom/Query.php';
            $this->_query = new Zend_Dom_Query;
        }
        return $this->_query;
    }

    /**
     * URL Helper
     *
     * @param array $urlOptions
     * @param string $name
     * @param bool $reset
     * @param bool $encode
     */
    public function url($urlOptions = array(), $name = null, $reset = false, $encode = true)
    {
        $frontController = $this->getFrontController();
        $router = $frontController->getRouter();
        if (!$router instanceof Zend_Controller_Router_Rewrite) {
            throw new Exception('This url helper utility function only works when the router is of type Zend_Controller_Router_Rewrite');
        }
        if (count($router->getRoutes()) == 0) {
            $router->addDefaultRoutes();
        }
        return $router->assemble($urlOptions, $name, $reset, $encode);
    }

    public function urlizeOptions($urlOptions, $actionControllerModuleOnly = true)
    {
        $ccToDash = new Zend_Filter_Word_CamelCaseToDash();
        foreach ($urlOptions as $n => $v) {
            if (in_array($n, array('action', 'controller', 'module'))) {
                $urlOptions[$n] = $ccToDash->filter($v);
            }
        }
        return $urlOptions;
    }

    /**
     * Increment assertion count
     *
     * @return void
     */
    protected function _incrementAssertionCount()
    {
        $stack = debug_backtrace();
        foreach (debug_backtrace() as $step) {
            if (isset($step['object'])
                && $step['object'] instanceof PHPUnit_Framework_TestCase
            ) {
                if (version_compare(PHPUnit_Runner_Version::id(), '3.3.0', 'lt')) {
                    break;
                } elseif (version_compare(PHPUnit_Runner_Version::id(), '3.3.3', 'lt')) {
                    $step['object']->incrementAssertionCounter();
                } else {
                    $step['object']->addToAssertionCount(1);
                }
                break;
            }
        }
    }
}


text:
<?php
/**
 * Zend Framework
 *
 * LICENSE
 *
 * This source file is subject to the new BSD license that is bundled
 * with this package in the file LICENSE.txt.
 * It is also available through the world-wide-web at this URL:
 * http://framework.zend.com/license/new-bsd
 * If you did not receive a copy of the license and are unable to
 * obtain it through the world-wide-web, please send an email
 * to license@zend.com so we can send you a copy immediately.
 *
 * @category   Zend
 * @package    Zend_Test
 * @subpackage PHPUnit
 * @copyright  Copyright (c) 2005-2011 Zend Technologies USA Inc. (http://www.zend.com)
 * @license    http://framework.zend.com/license/new-bsd     New BSD License
 * @version    $Id: DatabaseTestCase.php 23953 2011-05-03 05:47:39Z ralph $
 */

/**
 * @see PHPUnit_Extensions_Database_TestCase
 */
require_once "PHPUnit/Extensions/Database/TestCase.php";

/**
 * @see Zend_Test_PHPUnit_Db_Operation_Truncate
 */
require_once "Zend/Test/PHPUnit/Db/Operation/Truncate.php";

/**
 * @see Zend_Test_PHPUnit_Db_Operation_Insert
 */
require_once "Zend/Test/PHPUnit/Db/Operation/Insert.php";

/**
 * @see Zend_Test_PHPUnit_Db_DataSet_DbTableDataSet
 */
require_once "Zend/Test/PHPUnit/Db/DataSet/DbTableDataSet.php";

/**
 * @see Zend_Test_PHPUnit_Db_DataSet_DbTable
 */
require_once "Zend/Test/PHPUnit/Db/DataSet/DbTable.php";

/**
 * @see Zend_Test_PHPUnit_Db_DataSet_DbRowset
 */
require_once "Zend/Test/PHPUnit/Db/DataSet/DbRowset.php";

/**
 * Generic Testcase for Zend Framework related DbUnit Testing with PHPUnit
 *
 * @uses       PHPUnit_Extensions_Database_TestCase
 * @category   Zend
 * @package    Zend_Test
 * @subpackage PHPUnit
 * @copyright  Copyright (c) 2005-2011 Zend Technologies USA Inc. (http://www.zend.com)
 * @license    http://framework.zend.com/license/new-bsd     New BSD License
 */
abstract class Zend_Test_PHPUnit_DatabaseTestCase extends PHPUnit_Extensions_Database_TestCase
{
    /**
     * Creates a new Zend Database Connection using the given Adapter and database schema name.
     *
     * @param  Zend_Db_Adapter_Abstract $connection
     * @param  string $schema
     * @return Zend_Test_PHPUnit_Db_Connection
     */
    protected function createZendDbConnection(Zend_Db_Adapter_Abstract $connection, $schema)
    {
        return new Zend_Test_PHPUnit_Db_Connection($connection, $schema);
    }

    /**
     * Convenience function to get access to the database connection.
     *
     * @return Zend_Db_Adapter_Abstract
     */
    protected function getAdapter()
    {
        return $this->getConnection()->getConnection();
    }

    /**
     * Returns the database operation executed in test setup.
     *
     * @return PHPUnit_Extensions_Database_Operation_DatabaseOperation
     */
    protected function getSetUpOperation()
    {
        return new PHPUnit_Extensions_Database_Operation_Composite(array(
            new Zend_Test_PHPUnit_Db_Operation_Truncate(),
            new Zend_Test_PHPUnit_Db_Operation_Insert(),
        ));
    }

    /**
     * Returns the database operation executed in test cleanup.
     *
     * @return PHPUnit_Extensions_Database_Operation_DatabaseOperation
     */
    protected function getTearDownOperation()
    {
        return PHPUnit_Extensions_Database_Operation_Factory::NONE();
    }

    /**
     * Create a dataset based on multiple Zend_Db_Table instances
     *
     * @param  array $tables
     * @return Zend_Test_PHPUnit_Db_DataSet_DbTableDataSet
     */
    protected function createDbTableDataSet(array $tables=array())
    {
        $dataSet = new Zend_Test_PHPUnit_Db_DataSet_DbTableDataSet();
        foreach($tables AS $table) {
            $dataSet->addTable($table);
        }
        return $dataSet;
    }

    /**
     * Create a table based on one Zend_Db_Table instance
     *
     * @param Zend_Db_Table_Abstract $table
     * @param string $where
     * @param string $order
     * @param string $count
     * @param string $offset
     * @return Zend_Test_PHPUnit_Db_DataSet_DbTable
     */
    protected function createDbTable(Zend_Db_Table_Abstract $table, $where=null, $order=null, $count=null, $offset=null)
    {
        return new Zend_Test_PHPUnit_Db_DataSet_DbTable($table, $where, $order, $count, $offset);
    }

    /**
     * Create a data table based on a Zend_Db_Table_Rowset instance
     *
     * @param  Zend_Db_Table_Rowset_Abstract $rowset
     * @param  string
     * @return Zend_Test_PHPUnit_Db_DataSet_DbRowset
     */
    protected function createDbRowset(Zend_Db_Table_Rowset_Abstract $rowset, $tableName = null)
    {
        return new Zend_Test_PHPUnit_Db_DataSet_DbRowset($rowset, $tableName);
    }
}


text:
<?php
/**
 * Zend Framework
 *
 * LICENSE
 *
 * This source file is subject to the new BSD license that is bundled
 * with this package in the file LICENSE.txt.
 * It is also available through the world-wide-web at this URL:
 * http://framework.zend.com/license/new-bsd
 * If you did not receive a copy of the license and are unable to
 * obtain it through the world-wide-web, please send an email
 * to license@zend.com so we can send you a copy immediately.
 *
 * @category   Zend
 * @package    Zend_Test
 * @subpackage PHPUnit
 * @copyright  Copyright (c) 2005-2011 Zend Technologies USA Inc. (http://www.zend.com)
 * @license    http://framework.zend.com/license/new-bsd     New BSD License
 * @version    $Id: Exception.php 23775 2011-03-01 17:25:24Z ralph $
 */

/**
 * @see Zend_Exception
 */
require_once "Zend/Exception.php";

/**
 * Exception for Zend_Test_PHPUnit_Database package
 *
 * @uses       Zend_Exception
 * @category   Zend
 * @package    Zend_Test
 * @subpackage PHPUnit
 * @copyright  Copyright (c) 2005-2011 Zend Technologies USA Inc. (http://www.zend.com)
 * @license    http://framework.zend.com/license/new-bsd     New BSD License
 */
class Zend_Test_PHPUnit_Db_Exception extends Zend_Exception
{
}


text:
<?php
/**
 * Zend Framework
 *
 * LICENSE
 *
 * This source file is subject to the new BSD license that is bundled
 * with this package in the file LICENSE.txt.
 * It is also available through the world-wide-web at this URL:
 * http://framework.zend.com/license/new-bsd
 * If you did not receive a copy of the license and are unable to
 * obtain it through the world-wide-web, please send an email
 * to license@zend.com so we can send you a copy immediately.
 *
 * @category   Zend
 * @package    Zend_Test
 * @subpackage PHPUnit
 * @copyright  Copyright (c) 2005-2011 Zend Technologies USA Inc. (http://www.zend.com)
 * @license    http://framework.zend.com/license/new-bsd     New BSD License
 * @version    $Id: Connection.php 23775 2011-03-01 17:25:24Z ralph $
 */

/**
 * @see PHPUnit_Extensions_Database_DB_DefaultDatabaseConnection
 */
require_once "PHPUnit/Extensions/Database/DB/DefaultDatabaseConnection.php";

/**
 * @see Zend_Test_PHPUnit_Db_DataSet_QueryTable
 */
require_once "Zend/Test/PHPUnit/Db/DataSet/QueryTable.php";

/**
 * @see Zend_Test_PHPUnit_Db_Metadata_Generic
 */
require_once "Zend/Test/PHPUnit/Db/Metadata/Generic.php";

/**
 * Generic Abstraction of Zend_Db Connections in the PHPUnit Database Extension context.
 *
 * @uses       Zend_Db_Adapter_Abstract
 * @uses       PHPUnit_Extensions_Database_DB_DefaultDatabaseConnection
 * @category   Zend
 * @package    Zend_Test
 * @subpackage PHPUnit
 * @copyright  Copyright (c) 2005-2011 Zend Technologies USA Inc. (http://www.zend.com)
 * @license    http://framework.zend.com/license/new-bsd     New BSD License
 */
class Zend_Test_PHPUnit_Db_Connection extends PHPUnit_Extensions_Database_DB_DefaultDatabaseConnection
{
    /**
     * Zend_Db_Adapter_Abstract
     *
     * @var Zend_Db_Adapter_Abstract
     */
    protected $_connection;

    /**
     * Database Schema
     *
     * @var string $db
     */
    protected $_schema;

    /**
     * Metadata
     *
     * @param PHPUnit_Extensions_Database_DB_IMetaData $db
     */
    protected $_metaData;

    /**
     * Construct Connection based on Zend_Db_Adapter_Abstract
     *
     * @param Zend_Db_Adapter_Abstract $db
     * @param string $schema
     */
    public function __construct(Zend_Db_Adapter_Abstract $db, $schema)
    {
        $this->_connection = $db;
        $this->_schema = $schema;
    }

    /**
     * Close this connection.
     *
     * @return void
     */
    public function close()
    {
        $this->_connection->closeConnection();
    }

    /**
     * Creates a table with the result of the specified SQL statement.
     *
     * @param string $resultName
     * @param string $sql
     * @return PHPUnit_Extensions_Database_DataSet_ITable
     */
    public function createQueryTable($resultName, $sql)
    {
        return new Zend_Test_PHPUnit_Db_DataSet_QueryTable($resultName, $sql, $this);
    }

    /**
     * Returns a Zend_Db Connection
     *
     * @return Zend_Db_Adapter_Abstract
     */
    public function getConnection()
    {
        return $this->_connection;
    }

    /**
     * Returns a database metadata object that can be used to retrieve table
     * meta data from the database.
     *
     * @return PHPUnit_Extensions_Database_DB_IMetaData
     */
    public function getMetaData()
    {
        if($this->_metaData === null) {
            $this->_metaData = new Zend_Test_PHPUnit_Db_Metadata_Generic($this->getConnection(), $this->getSchema());
        }
        return $this->_metaData;
    }

    /**
     * Returns the schema for the connection.
     *
     * @return string
     */
    public function getSchema()
    {
        return $this->_schema;
    }

    /**
     * Returns the command used to truncate a table.
     *
     * @return string
     */
    public function getTruncateCommand()
    {
        return "DELETE";
    }
}


text:
<?php
/**
 * Zend Framework
 *
 * LICENSE
 *
 * This source file is subject to the new BSD license that is bundled
 * with this package in the file LICENSE.txt.
 * It is also available through the world-wide-web at this URL:
 * http://framework.zend.com/license/new-bsd
 * If you did not receive a copy of the license and are unable to
 * obtain it through the world-wide-web, please send an email
 * to license@zend.com so we can send you a copy immediately.
 *
 * @category   Zend
 * @package    Zend_Test
 * @subpackage PHPUnit
 * @copyright  Copyright (c) 2005-2011 Zend Technologies USA Inc. (http://www.zend.com)
 * @license    http://framework.zend.com/license/new-bsd     New BSD License
 * @version    $Id: SimpleTester.php 23775 2011-03-01 17:25:24Z ralph $
 */

/**
 * @see PHPUnit_Extensions_Database_DefaultTester
 */
require_once "PHPUnit/Extensions/Database/DefaultTester.php";

/**
 * @see PHPUnit_Extensions_Database_DB_IDatabaseConnection
 */
require_once "PHPUnit/Extensions/Database/DB/IDatabaseConnection.php";

/**
 * @see Zend_Test_PHPUnit_Db_Operation_Truncate
 */
require_once "Zend/Test/PHPUnit/Db/Operation/Truncate.php";

/**
 * @see Zend_Test_PHPUnit_Db_Operation_Insert
 */
require_once "Zend/Test/PHPUnit/Db/Operation/Insert.php";

/**
 * @see PHPUnit_Extensions_Database_Operation_Factory
 */
require_once "PHPUnit/Extensions/Database/Operation/Factory.php";

/**
 * @see PHPUnit_Extensions_Database_DataSet_IDataSet
 */
require_once "PHPUnit/Extensions/Database/DataSet/IDataSet.php";

/**
 * Simple Tester for Database Tests when the Abstract Test Case cannot be used.
 *
 * @uses       PHPUnit_Extensions_Database_DefaultTester
 * @category   Zend
 * @package    Zend_Test
 * @subpackage PHPUnit
 * @copyright  Copyright (c) 2005-2011 Zend Technologies USA Inc. (http://www.zend.com)
 * @license    http://framework.zend.com/license/new-bsd     New BSD License
 */
class Zend_Test_PHPUnit_Db_SimpleTester extends PHPUnit_Extensions_Database_DefaultTester
{
    /**
     * Creates a new default database tester using the given connection.
     *
     * @param PHPUnit_Extensions_Database_DB_IDatabaseConnection $connection
     */
    public function __construct(PHPUnit_Extensions_Database_DB_IDatabaseConnection $connection)
    {
        if(!($connection instanceof Zend_Test_PHPUnit_Db_Connection)) {
            require_once "Zend/Test/PHPUnit/Db/Exception.php";
            throw new Zend_Test_PHPUnit_Db_Exception("Not a valid Zend_Test_PHPUnit_Db_Connection instance, ".get_class($connection)." given!");
        }

        $this->connection = $connection;
        $this->setUpOperation = new PHPUnit_Extensions_Database_Operation_Composite(array(
            new Zend_Test_PHPUnit_Db_Operation_Truncate(),
            new Zend_Test_PHPUnit_Db_Operation_Insert(),
        ));
        $this->tearDownOperation = PHPUnit_Extensions_Database_Operation_Factory::NONE();
    }

    /**
     * Set Up the database using the given Dataset and the SetUp strategy "Truncate, then Insert"
     *
     * @param PHPUnit_Extensions_Database_DataSet_IDataSet $dataSet
     */
    public function setUpDatabase(PHPUnit_Extensions_Database_DataSet_IDataSet $dataSet)
    {
        $this->setDataSet($dataSet);
        $this->onSetUp();
    }
}


text:
<?php
/**
 * Zend Framework
 *
 * LICENSE
 *
 * This source file is subject to the new BSD license that is bundled
 * with this package in the file LICENSE.txt.
 * It is also available through the world-wide-web at this URL:
 * http://framework.zend.com/license/new-bsd
 * If you did not receive a copy of the license and are unable to
 * obtain it through the world-wide-web, please send an email
 * to license@zend.com so we can send you a copy immediately.
 *
 * @category   Zend
 * @package    Zend_Test
 * @subpackage PHPUnit
 * @copyright  Copyright (c) 2005-2011 Zend Technologies USA Inc. (http://www.zend.com)
 * @license    http://framework.zend.com/license/new-bsd     New BSD License
 * @version    $Id: QueryTable.php 23775 2011-03-01 17:25:24Z ralph $
 */

/**
 * @see PHPUnit_Extensions_Database_DataSet_QueryTable
 */
require_once "PHPUnit/Extensions/Database/DataSet/QueryTable.php";

/**
 * @see PHPUnit_Extensions_Database_DB_IDatabaseConnection
 */
require_once "PHPUnit/Extensions/Database/DB/IDatabaseConnection.php";

/**
 * Represent a PHPUnit Database Extension table with Queries using a Zend_Db adapter for assertion against other tables.
 *
 * @uses       PHPUnit_Extensions_Database_DataSet_QueryTable
 * @category   Zend
 * @package    Zend_Test
 * @subpackage PHPUnit
 * @copyright  Copyright (c) 2005-2011 Zend Technologies USA Inc. (http://www.zend.com)
 * @license    http://framework.zend.com/license/new-bsd     New BSD License
 */
class Zend_Test_PHPUnit_Db_DataSet_QueryTable extends PHPUnit_Extensions_Database_DataSet_QueryTable
{
    /**
     * Creates a new database query table object.
     *
     * @param string $table_name
     * @param string $query
     * @param PHPUnit_Extensions_Database_DB_IDatabaseConnection $databaseConnection
     */
    public function __construct($tableName, $query, PHPUnit_Extensions_Database_DB_IDatabaseConnection $databaseConnection)
    {
        if( !($databaseConnection instanceof Zend_Test_PHPUnit_Db_Connection) ) {
            require_once "Zend/Test/PHPUnit/Db/Exception.php";
            throw new Zend_Test_PHPUnit_Db_Exception("Zend_Test_PHPUnit_Db_DataSet_QueryTable only works with Zend_Test_PHPUnit_Db_Connection connections-");
        }
        parent::__construct($tableName, $query, $databaseConnection);
    }

    /**
     * Load data from the database.
     *
     * @return void
     */
    protected function loadData()
    {
        if($this->data === null) {
            $stmt = $this->databaseConnection->getConnection()->query($this->query);
            $this->data = $stmt->fetchAll(Zend_Db::FETCH_ASSOC);
        }
    }

    /**
     * Create Table Metadata
     */
    protected function createTableMetaData()
    {
        if ($this->tableMetaData === NULL)
        {
            $this->loadData();
            $keys = array();
            if(count($this->data) > 0) {
                $keys = array_keys($this->data[0]);
            }
            $this->tableMetaData = new PHPUnit_Extensions_Database_DataSet_DefaultTableMetaData(
                $this->tableName, $keys
            );
        }
    }
}