'file.php',
'line' => 10
];
$panel = $this->getPanel();
$this->assertEquals('file.php:10', $panel->getTraceLine($traceConfig));
}
public function testGetTraceLine_DefaultLink_CustomText()
{
$traceConfig = [
'file' => 'file.php',
'line' => 10,
'text' => 'custom text'
];
$panel = $this->getPanel();
$this->assertEquals('custom text',
$panel->getTraceLine($traceConfig));
}
public function testGetTraceLine_TextOnly()
{
$panel = $this->getPanel();
$panel->module->traceLine = false;
$traceConfig = [
'file' => 'file.php',
'line' => 10
];
$this->assertEquals('file.php:10', $panel->getTraceLine($traceConfig));
}
public function testGetTraceLine_CustomLinkByString()
{
$traceConfig = [
'file' => 'file.php',
'line' => 10
];
$panel = $this->getPanel();
$panel->module->traceLine = 'my custom phpstorm protocol';
$this->assertEquals('my custom phpstorm protocol',
$panel->getTraceLine($traceConfig));
}
public function testGetTraceLine_CustomLinkByCallback()
{
$traceConfig = [
'file' => 'file.php',
'line' => 10,
];
$panel = $this->getPanel();
$expected = 'http://my.custom.link';
$panel->module->traceLine = function () use ($expected) {
return $expected;
};
$this->assertEquals($expected, $panel->getTraceLine($traceConfig));
}
public function testGetTraceLine_CustomLinkByCallback_CustomText()
{
$traceConfig = [
'file' => 'file.php',
'line' => 10,
'text' => 'custom text'
];
$panel = $this->getPanel();
$panel->module->traceLine = function () {
return '{text}';
};
$this->assertEquals('custom text',
$panel->getTraceLine($traceConfig));
}
public function testGetTraceLine_tracePathMappings()
{
$traceConfig = [
'file' => '/app/file.php',
'line' => 10,
];
$panel = $this->getPanel();
$panel->module->tracePathMappings = [
'/app' => '/newpath/' // intentional mismatch of trailing slashes
];
$this->assertEquals('/app/file.php:10',
$panel->getTraceLine($traceConfig));
}
public function testGetTraceLine_tracePathMappings_Multiple()
{
$traceConfig = [
'file' => '/app/data/file.php',
'line' => 10,
];
$panel = $this->getPanel();
$panel->module->tracePathMappings = [
'/app/data' => '/app/localdata',
'/app' => '/newpath'
];
$this->assertEquals('/app/data/file.php:10',
$panel->getTraceLine($traceConfig));
}
protected function setUp()
{
parent::setUp();
$this->mockWebApplication();
}
private function getPanel()
{
return new Panel(['module' => new Module('debug')]);
}
}