PhpRiot
News Archive
PhpRiot Newsletter
Your Email Address:

More information

Mike Purcell's Blog: PHPUnit - Upgrade - Convert assertType to assertInternalType

Note: This article was originally published at PHPDeveloper on 22 May 2012.
PHPDeveloper

In this quick post to his blog, Mike Purcell mentions the deprecation of the "assertType" assertion and includes some code you can add to correct the issue in your tests.

We recently upgraded phpunit from a very old version to the current 3.6.x version (at time of writing). During the upgrade I noticed that assertType is no longer supported in many of our tests which were testing if something was a string, an array, or an object. So I had to write a quick script to update assertType to assertInternalType and figured I would post it for others if they needed to do the same.

The code goes into each of your tests (recursively) and finds the places where the "assertType" assertion is used and replaces it with its newer cousin "assertIntrnalType".