Extends
lithium\test\Unit
Tests exporting a the details of a compiled route to an array.
Source
public function testRouteExporting() {
$result = new Route(array(
'template' => '/{:controller}/{:action}',
'params' => array('action' => 'view')
));
$result = $result->export();
$expected = array(
'template' => '/{:controller}/{:action}',
'pattern' => '@^(?:/(?P<controller>[^\\/]+))(?:/(?P<action>[^\\/]+)?)?$@',
'params' => array('action' => 'view'),
'defaults' => array('action' => 'view'),
'match' => array(),
'meta' => array(),
'keys' => array('controller' => 'controller', 'action' => 'action'),
'subPatterns' => array(),
'persist' => array('controller'),
'handler' => null
);
$this->assertEqual($expected, $result);
$result = new Route(array(
'template' => '/images/image_{:width}x{:height}.{:format}',
'params' => array('format' => 'png')
));
$pattern = '@^/images/image_(?P<width>[^\\/]+)x(?P<height>[^\\/]+)\\.(?P<format>[^\\/]+)?$@';
$expected = array(
'template' => '/images/image_{:width}x{:height}.{:format}',
'pattern' => $pattern,
'params' => array('format' => 'png', 'action' => 'index'),
'match' => array('action' => 'index'),
'meta' => array(),
'keys' => array('width' => 'width', 'height' => 'height', 'format' => 'format'),
'defaults' => array('format' => 'png'),
'subPatterns' => array(),
'persist' => array(),
'handler' => null
);
$result = $result->export();
$this->assertEqual($expected, $result);
}