Source for file ComparisonFailure.php
Documentation is available at ComparisonFailure.php
// +------------------------------------------------------------------------+
// +------------------------------------------------------------------------+
// | Copyright (c) 2002-2004 Sebastian Bergmann <sb@sebastian-bergmann.de>. |
// +------------------------------------------------------------------------+
// | This source file is subject to version 3.00 of the PHP License, |
// | that is available at http://www.php.net/license/3_0.txt. |
// | If you did not receive a copy of the PHP license and are unable to |
// | obtain it through the world-wide-web, please send a note to |
// | license@php.net so we can mail you a copy immediately. |
// +------------------------------------------------------------------------+
// $Id: ComparisonFailure.php,v 1.5 2004/07/10 08:03:41 sebastian Exp $
require_once 'PHPUnit2/Framework/AssertionFailedError.php';
* Thrown when an assertion for string equality failed.
* @author Sebastian Bergmann <sb@sebastian-bergmann.de>
* @copyright Copyright © 2002-2004 Sebastian Bergmann <sb@sebastian-bergmann.de>
* @license http://www.php.net/license/3_0.txt The PHP License, Version 3.0
// {{{ public function __construct($expected, $actual, $message = '')
* Constructs a comparison failure.
* @param string $expected
public function __construct($expected, $actual, $message = '') {
parent ::__construct ($message);
$this->expected = ($expected === null ) ? 'null' : $expected;
$this->actual = ($actual === null ) ? 'null' : $actual;
// {{{ public function toString()
* Returns "..." in place of common prefix and "..." in
* place of common suffix between expected and actual.
$j = strlen($this->expected) - 1;
$k = strlen($this->actual) - 1;
for (; $i < $end; $i++ ) {
if ($this->expected[$i] != $this->actual[$i]) {
for (; $k >= $i && $j >= $i; $k-- ,$j-- ) {
if ($this->expected[$j] != $this->actual[$k]) {
if ($j < $i && $k < $i) {
$expected = $this->expected;
$expected = substr($this->expected, $i, ($j + 1 - $i));
$actual = substr($this->actual, $i, ($k + 1 - $i));;
if ($i <= $end && $i > 0 ) {
$expected = '...' . $expected;
$actual = '...' . $actual;
if ($j < strlen($this->expected) - 1 ) {
if ($k < strlen($this->actual) - 1 ) {
* vim600: et sw=2 ts=2 fdm=marker
Documentation generated on Mon, 11 Mar 2019 13:55:58 -0400 by phpDocumentor 1.4.4. PEAR Logo Copyright © PHP Group 2004.
|