Issues

ZF-11871: Zend_Test_PHPUnit_Constraint_Redirect is no longer compatible to PHPUnit_Framework_Constraint

Issue Type: Bug Created: 2011-11-04T17:35:17.000+0000 Last Updated: 2012-04-13T13:01:13.000+0000 Status: Closed Fix version(s): Reporter: Rene Roesch (reneroesch) Assignee: Adam Lundrigan (adamlundrigan) Tags: - Zend_Test_PHPUnit

Related issues: - ZF-10849

Attachments:

Description

Hi,

since PHPUnit 3.6 it seems that Zend_Test is no longer completely compatible.

The methods "evaluate" and "fail" in class PHPUnit_Framework_Constraint changed amount, type and usage of their parameters. The class Zend_Test_PHPUnit_Constraint_Redirect doesn't override them correctly anymore.

<pre class="highlight">
public function evaluate($other, $assertType = null)
{
}
public function fail($other, $description, $not = false)
{
}

Should be:

<pre class="highlight">
public function evaluate($other, $assertType = null, $returnResult = false)
{
    //$returnResult needs to be implemented...
}
public function fail($other, $description, PHPUnit_Framework_ComparisonFailure $comparisonFailure = null)
{
    //$comparisonFailure needs to be implemented...
}

I hope this changes will get implemented into 1.11 branch, too, not only 2.0.

Thank you in advance and greetings, Rene

Comments

Posted by Adam Lundrigan (adamlundrigan) on 2011-11-04T18:02:20.000+0000

The supported branch of PHPUnit for Zend Framework v1 is v3.4.x. There are no plans to update ZFv1 to any newer version of PHPUnit.

On a side note, I've been using various releases of 3.5 without any obvious negative side-effects (beside the flood of deprecation notices). YMMV, though.

Posted by Sam (samthephpdev) on 2012-04-13T13:01:13.000+0000

In the mean time, try sticking something like this in your Controller test case. It circumvents the evaluate() method that causes problems when testing Controller redirection or response codes.

/** * @param string $expectedCode * @param string $message */ public function assertResponseCode($expectedCode, $message = '') { $this->assertEquals($expectedCode, $this->getResponse()->getHttpResponseCode(), $message); }

/** * @param string $expectedUrl * @param string $message */ public function assertRedirectTo($expectedUrl, $message = '') { $headers = $this->getResponse()->getHeaders();

$actualUrl = '';

foreach($headers as $header) {
    if ($header['name'] === 'Location') {
        $actualUrl = $header['value'];
    }
}

$this->assertEquals($expectedUrl, $actualUrl, $message);

}

Have you found an issue?

See the Overview section for more details.

Copyright

© 2006-2016 by Zend, a Rogue Wave Company. Made with by awesome contributors.

This website is built using zend-expressive and it runs on PHP 7.

Contacts