for testing and deploying your application
for finding and fixing issues
for empowering human code reviews
<?php
namespace Fwk\Di\Definitions;
use Fwk\Di\Container;
use Fwk\Di\Reference;
/**
* Test class for CallableDefinition.
* Generated by PHPUnit on 2013-06-28 at 00:09:38.
*/
class CallableDefinitionTest extends \PHPUnit_Framework_TestCase {
* @var CallableDefinition
protected $object;
public $testPoint = false;
public function setUp()
{
$me = $this;
$this->object = new CallableDefinition(function() use ($me) {
$me->testPoint = true;
});
}
protected function getContainer()
$container = new Container();
$container['className'] = '\stdClass';
$container->set('temp.dir', function($c) { return sys_get_temp_dir(); });
return $container;
public function testSimpleInvocation()
$this->assertFalse($this->testPoint);
$this->object->invoke($this->getContainer());
$this->assertTrue($this->testPoint);
public function testSimpleInvocationError()
\PHPUnit_Framework_Error_Notice::$enabled = FALSE;
$this->object->setCallable(array('SimplyNot', 'callable'));
$this->setExpectedException('\Fwk\Di\Exceptions\InvalidCallableDefinitionException');
public function testInvokeWithErroneousArguments() {
$this->object->setCallable('date_default_timezone_set');
$this->object->addArgument(new Reference('invalid_ref'));
$this->setExpectedException('Fwk\Di\Exceptions\InvalidCallableDefinitionException');
$it = $this->object->invoke($this->getContainer());
$it
This check looks for variable assignements that are either overwritten by other assignments or where the variable is not used subsequently.
$myVar = 'Value'; $higher = false; if (rand(1, 6) > 3) { $higher = true; } else { $higher = false; }
Both the $myVar assignment in line 1 and the $higher assignment in line 2 are dead. The first because $myVar is never used and the second because $higher is always overwritten for every possible time line.
$myVar
$higher
This check looks for variable assignements that are either overwritten by other assignments or where the variable is not used subsequently.
Both the
$myVar
assignment in line 1 and the$higher
assignment in line 2 are dead. The first because$myVar
is never used and the second because$higher
is always overwritten for every possible time line.