Sebastian Bergmann »
27 June 2008 »
in PHPUnit »
I took Derick's blog posting on Phar as an incentive to finally experiment with it myself.
<?php
$phar = new Phar('phpunit-3.3-svn.phar', 0, 'phpunit-3.3-svn.phar');
$phar->buildFromDirectory('/usr/local/src/phpunit/release/3.3', '/\.php$/');
$stub = <<<ENDSTUB
#! /usr/local/php-5.3/bin/php
<?php
Phar::mapPhar('phpunit-3.3-svn.phar');
require 'phar://phpunit-3.3-svn.phar/PHPUnit/TextUI/Command.php';
__HALT_COMPILER();
ENDSTUB;
$phar->setStub($stub);
$phar->compressFiles(Phar::GZ);
$phar->stopBuffering();
?>
Running the script above will create a phpunit-3.3-svn.phar Phar archive that contains the complete PHPUnit distribution.
Furthermore, you can directly invoke the PHPUnit command-line test runner by execution the Phar archive.
Sebastian Bergmann »
17 June 2008 »
in Announcements »

The eZ Components development team is happy to announce the eZ Components 2008.1 release. Starting from this version, eZ Components requires PHP 5.2.1.
In this release, there are three new components:
- The Document component enables you to convert documents between different formats.
- The Feed component parses and generates RSS1, RSS2 and ATOM feeds.
- The new Search component provides a unified interface to different search engine back-ends, quite similar to what the Database and PersistentObject components provide for database access.
The eZ Components 2008.1 release also comes with a new version of my workflow engine, Workflow 1.2. Here are the highlights of this update:
A new tie-in component, WorkflowSignalSlotTiein, has been added to allow integration between the Workflow and SignalSlot components.
Sebastian Bergmann »
17 June 2008 »
in Articles »
In PHP, global variables work like this:
- A global variable
$foo = 'bar'; is stored as $GLOBALS['foo'] = 'bar';. $GLOBALS is a so-called superglobal.- Superglobals are built-in variables that are always available in all scopes.
- In the scope of a function or method, you may access the global variable
$foo by either directly accessing $GLOBALS['foo'] or by using global $foo; to create a local variable with a reference to the global variable.
It is hard to test code that uses singletons. The same is true for code that uses global variables.
Typically, the code you want to test is coupled strongly with a global variable and you cannot control its creation. An additional problem is the fact that one test's change to a global variable might break another test.
By default, PHPUnit runs your tests in a way where even changes to global and super-global variables (such as $GLOBALS) do not affect other tests.
The implementation of the backup and restore operations for the global and super-global variables uses serialize() and unserialize(). Objects of some classes that are provided by PHP itself, such as PDO, cannot be serialized and the backup operation will break when such an object is stored in the $GLOBALS array, for instance.
The backup and restore operations for the global and super-global variables can be disabled like this:
<?php
class MyTest extends PHPUnit_Framework_TestCase
{
protected $backupGlobals = FALSE;
}
?>
Please note that setting the $backupGlobals attribute inside the setUp() method, for instance, has no effect.
Starting with PHPUnit 3.3, the configuration of the $GLOBALS isolation is also supported on the TestSuite level. See ticket #497 for details.
Starting with PHPUnit 4.0, there will be support for running each test in a separate PHP process. Among other benefits, this will allow for testing singletons in an isolated environment.
Sebastian Bergmann »
16 June 2008 »
in Announcements »
- Fixed an issue with --coverage-html. [3211]
- Fixed #462: CLEAN_INSERT operation breaks when the flat XML dataset contains an empty table. [3172]
- Fixed #472: PHPUnit_Extensions_Database_DB_TableIterator::getTable() does not return anything. [3169]
- Fixed #491: PMD reports zero coverage for empty method. [3217]
- Fixed #498: Methods and statements incorrectly counted in Clover XML. [3105]