PHPUnit 3.5: Less $this Required
The feature discussed below has been removed from PHPUnit due to community feedback.
Over the years, I have gotten quite a few "complaints" from PHPUnit users that they do not like typing $this-> as often as they have to:
<?php
class StackTest extends PHPUnit_Framework_TestCase
{
public function testPushAndPop()
{
$stack = array();
$this->assertEquals(0, count($stack));
array_push($stack, 'foo');
$this->assertEquals('foo', $stack[count($stack)-1]);
$this->assertEquals(1, count($stack));
$this->assertEquals('foo', array_pop($stack));
$this->assertEquals(0, count($stack));
}
}
?>
As of PHPUnit 3.5, they can write test code that requires less $this-> statements:
<?php
require_once 'PHPUnit/Framework/Assert/Functions.php';
class StackTest extends PHPUnit_Framework_TestCase
{
public function testPushAndPop()
{
$stack = array();
assertEquals(0, count($stack));
array_push($stack, 'foo');
assertEquals('foo', $stack[count($stack)-1]);
assertEquals(1, count($stack));
assertEquals('foo', array_pop($stack));
assertEquals(0, count($stack));
}
}
?>
Here's hoping that this makes some people happy :-)
