"Call to undefined method PHPUnit_Framework_AssertionFailedError::getComparisonFailure()" #716

Closed
wants to merge 1 commit into
from

Conversation

Projects
None yet
5 participants

deg84 commented Jul 16, 2012

No description provided.

@deg84 deg84 Update /lib/Cake/TestSuite/Reporter/CakeHtmlReporter.php paintFail()
"Call to undefined method PHPUnit_Framework_AssertionFailedError::getComparisonFailure()"
7875cf7
Member

AD7six commented Jul 16, 2012

under what circumstances are you getting an error? "No description given" isn't a very convincing argument to delete code

Owner

markstory commented Jul 16, 2012

This was recently added to allow the webrunner to display failures as diffs. What version of PHPUnit are you using?

deg84 commented Jul 17, 2012

using PHPUnit 3.6.11

1.create users table

CREATE TABLE users (
  id int(20) NOT NULL AUTO_INCREMENT,
  username varchar(191) CHARACTER SET ascii NOT NULL,
  `password` varchar(191) CHARACTER SET ascii COLLATE ascii_bin NOT NULL,
  email varchar(191) CHARACTER SET ascii COLLATE ascii_bin NOT NULL,
  created datetime NOT NULL,
  modified datetime NOT NULL,
  PRIMARY KEY (id)
) ENGINE=InnoDB DEFAUL

2.execute "./cake bake all user"
3.open "/Test/Case/Model/UserTest.php"

<?php
App::uses('User', 'Model');

/**
 * User Test Case
 *
 */
class UserTest extends CakeTestCase {

/**
 * Fixtures
 *
 * @var array
 */
    public $fixtures = array(
        'app.user'
    );

/**
 * setUp method
 *
 * @return void
 */
    public function setUp() {
        parent::setUp();
        $this->User = ClassRegistry::init('User');
    }

/**
 * tearDown method
 *
 * @return void
 */
    public function tearDown() {
        unset($this->User);

        parent::tearDown();
    }

}

4.access "/test.php?case=Model%2FUser"
5.error "Call to undefined method PHPUnit_Framework_AssertionFailedError::getComparisonFailure()"

Owner

markstory commented Jul 17, 2012

Thanks, there is a better solution to this other than just deleting the code that provides a different feature :D

deg84 commented Jul 17, 2012

I got it :D

deg84 closed this Jul 18, 2012

Member

dereuromark commented Jul 21, 2012

has there been any attempt to fix it so far? I get this in cake2.2.1 / phpunit3.6.11 with Windows:

Fatal error: Call to undefined method PHPUnit_Framework_AssertionFailedError::getComparisonFailure() in E:\...\lib\Cake\TestSuite\Reporter\CakeHtmlReporter.php on line 252

The problem seems to be that the $failure object is actually a PHPUnit_Framework_AssertionFailedError instead of Exception. The exception (which extends the error) contains the method, though.

see my fix: #726

Owner

markstory commented Jul 21, 2012

No I forgot to fix the issue, sorry about that. Thanks for the pull request.

I was still getting this error but it was in fact just the fact that I had just started building my app and had yet to put in any test cases.

Here is the Blog link that helped me out. http://www.kpsolution.com/cakephp/cakephp-test-failure-with-error-phpunit_framework_assertionfailederrorgetcomparisonfailure/105/

Should CakePHP handle this error more gracefully and hand this back to the test.php view stating there are no tests written? I've just got into this framework but I might look into a fix and make a Pull request.

Wrote a pull request #898.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment