ZF-10849: PHPUnit showing deprecated warning on use of assertType() in PHPUnit 3.5.6 against current unit tests

Issue Type: Bug Created: 2010-12-19T13:13:00.000+0000 Last Updated: 2012-03-12T13:50:36.000+0000 Status: Closed Fix version(s): Reporter: Marc Hodgins (mjh_ca) Assignee: Adam Lundrigan (adamlundrigan) Tags: Related issues: - ZF-10844



Latest update to PHPUnit 3.5.6 causes the following messages to be repeated many times when running the test suite:

<pre class="literal">
assertType() will be removed in PHPUnit 3.6 and should no longer be used. assertInternalType()
should be used for asserting internal types such as "integer" or "string" whereas
assertInstanceOf() should be used for asserting that an object is an instance of a specified
class or interface.

Since it seems we are now supporting the use of both PHPUnit 3.4 and PHPUnit 3.5 for ZF1 tests (see ZF-10830, ZF-10844), what is the best solution here? My suggestion to maintain compatibility with PHPUnit 3.4 is to replace $this->assertType('ExpectedClass', $actualObject) with $this->assertTrue($actualObject instanceof ExpectedClass). But, the downside is that you lose some verbosity on the reason for a test failure on these assertions without manually digging into the test code.

Any better suggestions?


Posted by Phoenix Zerin (todofixthis) on 2010-12-25T07:52:16.000+0000

What about $this->assertEquals('ExpectedClass', get_class($actualObject))?

Posted by Aaron S. Hawley (ashawley) on 2011-01-21T05:52:20.000+0000

And $this->assertEquals('string', gettype($var)) for internal types.

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

The official word from [~Matthew] is that PHPUnit versions >3.4 are not supported, and there are no plans to update ZFv1 to be compatible with versions later than v3.4

Have you found an issue?

See the Overview section for more details.


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

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