presenter = new ClosurePresenter();
$this->manager = new PresenterManager();
$this->manager->addPresenter(new ScalarPresenter());
$this->manager->addPresenter(new ObjectPresenter());
$this->manager->addPresenter($this->presenter);
}
/**
* @dataProvider presentData
*/
public function testPresent($closure, $expect)
{
$this->assertEquals($expect, $this->presenter->present($closure));
}
/**
* @dataProvider presentData
*/
public function testPresentRef($closure, $expect)
{
$this->assertEquals($expect, $this->presenter->presentRef($closure));
}
public function presentData()
{
$null = null;
$eol = version_compare(PHP_VERSION, '5.4.3', '>=') ? 'PHP_EOL' : '"\n"';
return array(
array(
function () {
},
'function () { ... }',
),
array(
function ($foo) {
},
'function ($foo) { ... }',
),
array(
function ($foo, $bar = null) {
},
'function ($foo, $bar = null) { ... }',
),
array(
function ($foo = "bar") {
},
'function ($foo = "bar") { ... }',
),
array(
function ($foo = \PHP_EOL) {
},
'function ($foo = ' . $eol . ') { ... }',
),
array(
function ($foo) use ($eol, $null) {
},
'function ($foo) use ($eol, $null) { ... }',
),
);
}
}