Author: as
Date: Fri Aug 3 12:50:11 2007
New Revision: 5812
Log:
- Implemented feature request #10896: Allow aggregation of unordered parameter
values if the parameter names appear more than once.
Added:
trunk/Url/docs/tutorial/tutorial_get_params_aggregate.php (with props)
Modified:
trunk/Url/ChangeLog
trunk/Url/docs/tutorial.txt
trunk/Url/src/url.php
trunk/Url/src/url_configuration.php
trunk/Url/tests/url_test.php
Modified: trunk/Url/ChangeLog
==============================================================================
--- trunk/Url/ChangeLog [iso-8859-1] (original)
+++ trunk/Url/ChangeLog [iso-8859-1] Fri Aug 3 12:50:11 2007
@@ -3,6 +3,8 @@
- Implemented feature request #11000: Added ability to include script name
when building an URL through a buildUrl() parameter.
+- Implemented feature request #10896: Allow aggregation of unordered parameter
+ values if the parameter names appear more than once.
1.1 - Monday 02 July 2007
Modified: trunk/Url/docs/tutorial.txt
==============================================================================
--- trunk/Url/docs/tutorial.txt [iso-8859-1] (original)
+++ trunk/Url/docs/tutorial.txt [iso-8859-1] Fri Aug 3 12:50:11 2007
@@ -202,6 +202,40 @@
string(82) "http://www.example.com/mydir/index.php/groups/Games/Adventure/
Adult/(game)/Larry/7"
+Getting parameters by aggregating values for unordered parameters
+-----------------------------------------------------------------
+
+If the URL contains multiple appearances of an unordered parameter (for example
+'http://www.example.com/(param1)/x/(param1)/y/z'), then by default only the
last
+encountered values are returned when calling getParam().
+
+To return all the values (to aggregate values), use
+ezcUrlConfiguration::AGGREGATE_ARGUMENTS as the second parameter when calling
+addUnorderedParameter(), like in the example:
+
+.. include:: tutorial/tutorial_get_params_aggregate.php
+ :literal:
+
+The output will be: ::
+
+ string(1) "y"
+ array(2) {
+ [0]=>
+ string(1) "y"
+ [1]=>
+ string(1) "z"
+ }
+ array(3) {
+ [0]=>
+ string(1) "x"
+ [1]=>
+ string(1) "y"
+ [2]=>
+ string(1) "z"
+ }
+ string(46) "http://www.example.com/(param1)/x/(param1)/y/z"
+
+
Setting parameters using a url configuration
--------------------------------------------
Added: trunk/Url/docs/tutorial/tutorial_get_params_aggregate.php
==============================================================================
--- trunk/Url/docs/tutorial/tutorial_get_params_aggregate.php (added)
+++ trunk/Url/docs/tutorial/tutorial_get_params_aggregate.php [iso-8859-1] Fri
Aug 3 12:50:11 2007
@@ -1,0 +1,24 @@
+<?php
+require_once 'tutorial_autoload.php';
+
+// create an ezcUrlConfiguration object
+$urlCfg = new ezcUrlConfiguration();
+
+// single parameter value
+$urlCfg->addUnorderedParameter( 'param1' );
+$url = new ezcUrl( 'http://www.example.com/(param1)/x/(param1)/y/z', $urlCfg );
+var_dump( $url->getParam( 'param1' ) ); // will output "y"
+
+// multiple parameter values
+$urlCfg->addUnorderedParameter( 'param1',
ezcUrlConfiguration::MULTIPLE_ARGUMENTS );
+$url = new ezcUrl( 'http://www.example.com/(param1)/x/(param1)/y/z', $urlCfg );
+var_dump( $url->getParam( 'param1' ) ); // will output array( "y", "z" )
+
+// multiple parameter values with aggregation
+$urlCfg->addUnorderedParameter( 'param1',
ezcUrlConfiguration::AGGREGATE_ARGUMENTS );
+$url = new ezcUrl( 'http://www.example.com/(param1)/x/(param1)/y/z', $urlCfg );
+var_dump( $url->getParam( 'param1' ) ); // will output array( "x", "y", "z" )
+
+// output the url (it will be similar to the input url)
+var_dump( $url->buildUrl() );
+?>
Propchange: trunk/Url/docs/tutorial/tutorial_get_params_aggregate.php
------------------------------------------------------------------------------
svn:eol-style = native
Modified: trunk/Url/src/url.php
==============================================================================
--- trunk/Url/src/url.php [iso-8859-1] (original)
+++ trunk/Url/src/url.php [iso-8859-1] Fri Aug 3 12:50:11 2007
@@ -329,6 +329,45 @@
/**
* Returns unordered parameters from the $path array.
*
+ * The format of the returned array is:
+ * <code>
+ * array( param_name1 => array( 0 => array( value1, value2, ... ),
+ * 1 => array( value1, value2, ... ) ),
+ * param_name2 = array( 0 => array( value1, value2, ... ),
+ * 1 => array( value1, value2, ... ) ), ... )
+ * </code>
+ * where 0, 1, etc are numbers meaning the nth encounter of each param_name
+ * in the url.
+ *
+ * For example, if the URL is
'http://www.example.com/(param1)/a/(param2)/x/(param2)/y/z'
+ * then the result of this function will be:
+ * <code>
+ * array( 'param1' => array( 0 => array( 'a' ) ),
+ * 'param2' => array( 0 => array( 'x' ),
+ * 1 => array( 'y', 'z' ) ) );
+ * </code>
+ *
+ * For the URL 'http://www.example.com/(param1)/x/(param1)/y/z', these
+ * methods can be employed to get the values of param1:
+ * <code>
+ * $urlCfg = new ezcUrlConfiguration();
+ *
+ * // single parameter value
+ * $urlCfg->addUnorderedParameter( 'param1' );
+ * $url = new ezcUrl( 'http://www.example.com/(param1)/x/(param1)/y/z',
$urlCfg );
+ * $param1 = $url->getParam( 'param1' ); // will return "y"
+ *
+ * // multiple parameter values
+ * $urlCfg->addUnorderedParameter( 'param1',
ezcUrlConfiguration::MULTIPLE_ARGUMENTS );
+ * $url = new ezcUrl( 'http://www.example.com/(param1)/x/(param1)/y/z',
$urlCfg );
+ * $param1 = $url->getParam( 'param1' ); // will return array( "y", "z" )
+ *
+ * // multiple parameter values with aggregation
+ * $urlCfg->addUnorderedParameter( 'param1',
ezcUrlConfiguration::AGGREGATE_ARGUMENTS );
+ * $url = new ezcUrl( 'http://www.example.com/(param1)/x/(param1)/y/z',
$urlCfg );
+ * $param1 = $url->getParam( 'param1' ); // will return array( "x", "y",
"z" )
+ * </code>
+ *
* @param array(string) $config An array of unordered parameters names,
from the URL configuration used in parsing
* @param int $index The index in the URL path part from where to start
the matching of $config
* @return array(string=>mixed)
@@ -336,6 +375,13 @@
public function parseUnorderedParameters( $config, $index )
{
$result = array();
+
+ // holds how many times a parameter name is encountered in the URL.
+ // for example, for '/(param1)/a/(param2)/x/(param2)/y',
+ // $encounters = array( 'param1' => 1, 'param2' => 2 );
+ $encounters = array();
+
+ $urlCfg = $this->configuration;
$pathCount = count( $this->path );
if ( $pathCount == 0 || ( $pathCount == 1 && trim( $this->path[0] )
=== "" ) )
{
@@ -346,14 +392,22 @@
for ( $i = $index; $i < $pathCount; $i++ )
{
$param = $this->path[$i];
- if ( $param{0} == $this->configuration->unorderedDelimiters[0] )
- {
- $param = trim( trim( $param,
$this->configuration->unorderedDelimiters[0] ),
$this->configuration->unorderedDelimiters[1] );
- $result[$param] = array();
+ if ( $param{0} == $urlCfg->unorderedDelimiters[0] )
+ {
+ $param = trim( trim( $param, $urlCfg->unorderedDelimiters[0]
), $urlCfg->unorderedDelimiters[1] );
+ if ( isset( $encounters[$param] ) )
+ {
+ $encounters[$param]++;
+ }
+ else
+ {
+ $encounters[$param] = 0;
+ }
+ $result[$param][$encounters[$param]] = array();
$j = 1;
- while ( ( $i + $j ) < $pathCount && $this->path[$i + $j]{0} !=
$this->configuration->unorderedDelimiters[0] )
- {
- $result[$param][] = trim( trim( $this->path[$i + $j],
$this->configuration->unorderedDelimiters[0] ),
$this->configuration->unorderedDelimiters[1] );
+ while ( ( $i + $j ) < $pathCount && $this->path[$i + $j]{0} !=
$urlCfg->unorderedDelimiters[0] )
+ {
+ $result[$param][$encounters[$param]][] = trim( trim(
$this->path[$i + $j], $urlCfg->unorderedDelimiters[0] ),
$urlCfg->unorderedDelimiters[1] );
$j++;
}
}
@@ -430,9 +484,12 @@
if ( $this->uparams && count( $this->uparams ) != 0 )
{
- foreach ( $this->properties['uparams'] as $key => $values )
- {
- $url .= '/(' . $key . ')/' . implode( '/', $values );
+ foreach ( $this->properties['uparams'] as $key => $encounters )
+ {
+ foreach ( $encounters as $encounter => $values )
+ {
+ $url .= '/(' . $key . ')/' . implode( '/', $values );
+ }
}
}
}
@@ -472,7 +529,39 @@
}
/**
- * Returns the specified parameter from the URL based on the URL
configuration.
+ * Returns the value of the specified parameter from the URL based on the
+ * active URL configuration.
+ *
+ * Unordered parameter examples:
+ * <code>
+ * $urlCfg = new ezcUrlConfiguration();
+ *
+ * // single parameter value
+ * $urlCfg->addUnorderedParameter( 'param1' );
+ * $url = new ezcUrl( 'http://www.example.com/(param1)/x/(param1)/y/z',
$urlCfg );
+ * $param1 = $url->getParam( 'param1' ); // will return "y"
+ *
+ * // multiple parameter values
+ * $urlCfg->addUnorderedParameter( 'param1',
ezcUrlConfiguration::MULTIPLE_ARGUMENTS );
+ * $url = new ezcUrl( 'http://www.example.com/(param1)/x/(param1)/y/z',
$urlCfg );
+ * $param1 = $url->getParam( 'param1' ); // will return array( "y", "z" )
+ *
+ * // multiple parameter values with aggregation
+ * $urlCfg->addUnorderedParameter( 'param1',
ezcUrlConfiguration::AGGREGATE_ARGUMENTS );
+ * $url = new ezcUrl( 'http://www.example.com/(param1)/x/(param1)/y/z',
$urlCfg );
+ * $param1 = $url->getParam( 'param1' ); // will return array( "x", "y",
"z" )
+ * </code>
+ *
+ * Ordered parameter examples:
+ * <code>
+ * $urlCfg = new ezcUrlConfiguration();
+ *
+ * $urlCfg->addOrderedParameter( 'param1' );
+ * $urlCfg->addOrderedParameter( 'param2' );
+ * $url = new ezcUrl( 'http://www.example.com/x/y', $urlCfg );
+ * $param1 = $url->getParam( 'param1' ); // will return "x"
+ * $param2 = $url->getParam( 'param2' ); // will return "y"
+ * </code>
*
* @throws ezcUrlNoConfigurationException
* if an URL configuration is not defined
@@ -483,40 +572,60 @@
*/
public function getParam( $name )
{
- if ( $this->configuration != null )
- {
- if ( !( isset( $this->configuration->orderedParameters[$name] ) ||
- isset( $this->configuration->unorderedParameters[$name] )
) )
+ $urlCfg = $this->configuration;
+ if ( $urlCfg != null )
+ {
+ if ( !( isset( $urlCfg->orderedParameters[$name] ) ||
+ isset( $urlCfg->unorderedParameters[$name] ) ) )
{
throw new ezcUrlInvalidParameterException( $name );
}
$params = $this->params;
$uparams = $this->uparams;
- if ( isset( $this->configuration->orderedParameters[$name] ) &&
- isset(
$params[$this->configuration->orderedParameters[$name]] ) )
- {
- return $params[$this->configuration->orderedParameters[$name]];
- }
-
- if ( isset( $this->configuration->unorderedParameters[$name] ) &&
- isset( $uparams[$name] ) )
- {
- if ( $this->configuration->unorderedParameters[$name] ==
ezcUrlConfiguration::SINGLE_ARGUMENT )
- {
- if ( count( $uparams[$name] ) > 0 )
+ if ( isset( $urlCfg->orderedParameters[$name] ) &&
+ isset( $params[$urlCfg->orderedParameters[$name]] ) )
+ {
+ return $params[$urlCfg->orderedParameters[$name]];
+ }
+
+ if ( isset( $urlCfg->unorderedParameters[$name] ) &&
+ isset( $uparams[$name][0] ) )
+ {
+ if ( $urlCfg->unorderedParameters[$name] ===
ezcUrlConfiguration::SINGLE_ARGUMENT )
+ {
+ if ( count( $uparams[$name][0] ) > 0 )
{
- return $uparams[$name][0];
+ return $uparams[$name][count( $uparams[$name] ) -
1][0];
}
+ else
+ {
+ return null;
+ }
}
else
{
- return $uparams[$name];
+ if ( $urlCfg->unorderedParameters[$name] ===
ezcUrlConfiguration::AGGREGATE_ARGUMENTS )
+ {
+ $result = array();
+ foreach ( $uparams[$name] as $encounter => $values )
+ {
+ $result = array_merge( $result,
$uparams[$name][$encounter] );
+ }
+ return $result;
+ }
+ else
+ {
+ return $uparams[$name][count( $uparams[$name] ) - 1];
+ }
}
}
return null;
}
- throw new ezcUrlNoConfigurationException( $name );
+ else
+ {
+ throw new ezcUrlNoConfigurationException( $name );
+ }
}
/**
@@ -531,33 +640,42 @@
*/
public function setParam( $name, $value )
{
- if ( $this->configuration != null )
- {
- if ( !( isset( $this->configuration->orderedParameters[$name] ) ||
- isset( $this->configuration->unorderedParameters[$name] )
) )
+ $urlCfg = $this->configuration;
+ if ( $urlCfg != null )
+ {
+ if ( !( isset( $urlCfg->orderedParameters[$name] ) ||
+ isset( $urlCfg->unorderedParameters[$name] ) ) )
{
throw new ezcUrlInvalidParameterException( $name );
}
- if ( isset( $this->configuration->orderedParameters[$name] ) )
- {
-
$this->properties['params'][$this->configuration->orderedParameters[$name]] =
$value;
+ if ( isset( $urlCfg->orderedParameters[$name] ) )
+ {
+ $this->properties['params'][$urlCfg->orderedParameters[$name]]
= $value;
return;
}
- if ( isset( $this->configuration->unorderedParameters[$name] ) )
- {
+ if ( isset( $urlCfg->unorderedParameters[$name] ) )
+ {
+ if ( !isset( $this->properties['uparams'][$name] ) )
+ {
+ $this->properties['uparams'][$name] = array();
+ }
+
if ( is_array( $value ) )
{
- $this->properties['uparams'][$name] = $value;
+ $this->properties['uparams'][$name][count(
$this->properties['uparams'][$name] ) - 1] = $value;
}
else
{
- $this->properties['uparams'][$name] = array( $value );
+ $this->properties['uparams'][$name][count(
$this->properties['uparams'][$name] ) - 1] = array( $value );
}
}
return;
}
- throw new ezcUrlNoConfigurationException( $name );
+ else
+ {
+ throw new ezcUrlNoConfigurationException( $name );
+ }
}
/**
Modified: trunk/Url/src/url_configuration.php
==============================================================================
--- trunk/Url/src/url_configuration.php [iso-8859-1] (original)
+++ trunk/Url/src/url_configuration.php [iso-8859-1] Fri Aug 3 12:50:11 2007
@@ -49,6 +49,16 @@
* // to remove parameters from the URL configuration stored in the URL
* $url->configuration->removeOrderedParameter( 'subcategory' );
* $url->configuration->removeUnorderedParameter( 'game' );
+ * </code>
+ *
+ * Example of aggregating values for unordered parameters:
+ * <code>
+ * $urlCfg = new ezcUrlConfiguration();
+ *
+ * $urlCfg->addUnorderedParameter( 'param1',
ezcUrlConfiguration::AGGREGATE_ARGUMENTS );
+ * $url = new ezcUrl( 'http://www.example.com/(param1)/x/(param1)/y', $urlCfg
);
+ *
+ * $param1 = $url->getParam( 'param1' ); // will be array( "x", "y" )
* </code>
*
* @property string $basedir
@@ -90,6 +100,15 @@
const MULTIPLE_ARGUMENTS = 2;
/**
+ * Flag for specifying aggregation for unordered parameter values if the
+ * parameter name appears more than once in the URL.
+ *
+ * For example, if the URL is
'http://www.example.com/(param1)/x/(param2)/y',
+ * then both values will be considered for the parameter param1.
+ */
+ const AGGREGATE_ARGUMENTS = 4;
+
+ /**
* Holds the properties of this class.
*
* @var array(string=>mixed)
@@ -238,9 +257,35 @@
/**
* Adds an unordered parameter to the URL configuration.
*
- * The default type of the parameter is [EMAIL PROTECTED] SINGLE_ARGUMENT}.
- *
- * Other valid types are [EMAIL PROTECTED] MULTIPLE_ARGUMENTS}.
+ * The possible values for the $type parameter are:
+ * - [EMAIL PROTECTED] ezcUrlConfiguration::SINGLE_ARGUMENT} (default):
the getParam()
+ * method in ezcUrl will return a string containing the value of the
+ * parameter $name
+ * - [EMAIL PROTECTED] ezcUrlConfiguration::MULTIPLE_ARGUMENTS}: the
getParam() method
+ * will return an array containing the last encountered values of the
+ * parameter $name
+ * - [EMAIL PROTECTED] ezcUrlConfiguration::AGGREGATE_ARGUMENTS}: the
getParam() method
+ * will return an array with all encountered values for the parameter
$name
+ *
+ * Examples:
+ * <code>
+ * $urlCfg = new ezcUrlConfiguration();
+ *
+ * // single parameter value
+ * $urlCfg->addUnorderedParameter( 'param1' );
+ * $url = new ezcUrl( 'http://www.example.com/(param1)/x', $urlCfg );
+ * $param1 = $url->getParam( 'param1' ); // will return "x"
+ *
+ * // multiple parameter values
+ * $urlCfg->addUnorderedParameter( 'param1',
ezcUrlConfiguration::MULTIPLE_ARGUMENTS );
+ * $url = new ezcUrl( 'http://www.example.com/(param1)/x/y', $urlCfg );
+ * $param1 = $url->getParam( 'param1' ); // will return array( "x", "y" )
+ *
+ * // multiple parameter values with aggregation
+ * $urlCfg->addUnorderedParameter( 'param1',
ezcUrlConfiguration::AGGREGATE_ARGUMENTS );
+ * $url = new ezcUrl( 'http://www.example.com/(param1)/x/(param1)/y',
$urlCfg );
+ * $param1 = $url->getParam( 'param1' ); // will return array( "x", "y" )
+ * </code>
*
* @param string $name The name of the unordered parameter to add to the
configuration
* @param int $type The type of the unordered parameter
Modified: trunk/Url/tests/url_test.php
==============================================================================
--- trunk/Url/tests/url_test.php [iso-8859-1] (original)
+++ trunk/Url/tests/url_test.php [iso-8859-1] Fri Aug 3 12:50:11 2007
@@ -586,6 +586,116 @@
$url = new ezcUrl(
'http://www.example.com/mydir/shop/doc/components/view/trunk', $urlCfg );
$expected =
'http://www.example.com/mydir/shop/doc/components/view/trunk';
$this->assertEquals( $expected, $url->buildUrl( true ) );
+ }
+
+ public function testGetUnorderedParametersMultipleValuesTypeSingle()
+ {
+ $urlCfg = new ezcUrlConfiguration();
+ $urlCfg->addOrderedParameter( 'section' );
+ $urlCfg->addOrderedParameter( 'module' );
+ $urlCfg->addOrderedParameter( 'view' );
+ $urlCfg->addOrderedParameter( 'content' );
+ $urlCfg->addUnorderedParameter( 'param1' );
+ $urlCfg->addUnorderedParameter( 'param2',
ezcUrlConfiguration::SINGLE_ARGUMENT );
+
+ $url = new ezcUrl(
"http://www.example.com/doc/components/view/trunk/(param1)/a/(param2)/x/(param2)/y",
$urlCfg );
+ $expected =
'http://www.example.com/doc/components/view/trunk/(param1)/a/(param2)/y';
+ //$this->assertEquals( $expected, $url->buildUrl() );
+
+ $this->assertEquals( 'doc', $url->getParam( 'section' ) );
+ $this->assertEquals( 'components', $url->getParam( 'module' ) );
+ $this->assertEquals( 'view', $url->getParam( 'view' ) );
+ $this->assertEquals( 'trunk', $url->getParam( 'content' ) );
+ $this->assertEquals( 'a', $url->getParam( 'param1' ) );
+ $this->assertEquals( 'y', $url->getParam( 'param2' ) );
+ }
+
+ public function testGetUnorderedParametersMultipleValuesTypeMultiple()
+ {
+ $urlCfg = new ezcUrlConfiguration();
+ $urlCfg->addOrderedParameter( 'section' );
+ $urlCfg->addOrderedParameter( 'module' );
+ $urlCfg->addOrderedParameter( 'view' );
+ $urlCfg->addOrderedParameter( 'content' );
+ $urlCfg->addUnorderedParameter( 'param1' );
+ $urlCfg->addUnorderedParameter( 'param2',
ezcUrlConfiguration::MULTIPLE_ARGUMENTS );
+
+ $url = new ezcUrl(
"http://www.example.com/doc/components/view/trunk/(param1)/a/(param2)/x/(param2)/y/z",
$urlCfg );
+ $expected =
'http://www.example.com/doc/components/view/trunk/(param1)/a/(param2)/x/(param2)/y/z';
+ $this->assertEquals( $expected, $url->buildUrl() );
+
+ $this->assertEquals( 'doc', $url->getParam( 'section' ) );
+ $this->assertEquals( 'components', $url->getParam( 'module' ) );
+ $this->assertEquals( 'view', $url->getParam( 'view' ) );
+ $this->assertEquals( 'trunk', $url->getParam( 'content' ) );
+ $this->assertEquals( 'a', $url->getParam( 'param1' ) );
+ $this->assertEquals( array( 'y', 'z' ), $url->getParam( 'param2' ) );
+ }
+
+ public function
testGetUnorderedParametersMultipleValuesTypeMultipleSingle()
+ {
+ $urlCfg = new ezcUrlConfiguration();
+ $urlCfg->addOrderedParameter( 'section' );
+ $urlCfg->addOrderedParameter( 'module' );
+ $urlCfg->addOrderedParameter( 'view' );
+ $urlCfg->addOrderedParameter( 'content' );
+ $urlCfg->addUnorderedParameter( 'param1' );
+ $urlCfg->addUnorderedParameter( 'param2',
ezcUrlConfiguration::MULTIPLE_ARGUMENTS );
+
+ $url = new ezcUrl(
"http://www.example.com/doc/components/view/trunk/(param1)/a/(param2)/x/(param2)/y",
$urlCfg );
+ $expected =
'http://www.example.com/doc/components/view/trunk/(param1)/a/(param2)/x/(param2)/y';
+ $this->assertEquals( $expected, $url->buildUrl() );
+
+ $this->assertEquals( 'doc', $url->getParam( 'section' ) );
+ $this->assertEquals( 'components', $url->getParam( 'module' ) );
+ $this->assertEquals( 'view', $url->getParam( 'view' ) );
+ $this->assertEquals( 'trunk', $url->getParam( 'content' ) );
+ $this->assertEquals( 'a', $url->getParam( 'param1' ) );
+ $this->assertEquals( array( 'y' ), $url->getParam( 'param2' ) );
+ }
+
+ public function testGetUnorderedParametersMultipleValuesTypeAggregate()
+ {
+ $urlCfg = new ezcUrlConfiguration();
+ $urlCfg->addOrderedParameter( 'section' );
+ $urlCfg->addOrderedParameter( 'module' );
+ $urlCfg->addOrderedParameter( 'view' );
+ $urlCfg->addOrderedParameter( 'content' );
+ $urlCfg->addUnorderedParameter( 'param1' );
+ $urlCfg->addUnorderedParameter( 'param2',
ezcUrlConfiguration::AGGREGATE_ARGUMENTS );
+
+ $url = new ezcUrl(
"http://www.example.com/doc/components/view/trunk/(param1)/a/(param2)/x/(param2)/y/z",
$urlCfg );
+ $expected =
'http://www.example.com/doc/components/view/trunk/(param1)/a/(param2)/x/(param2)/y/z';
+ $this->assertEquals( $expected, $url->buildUrl() );
+
+ $this->assertEquals( 'doc', $url->getParam( 'section' ) );
+ $this->assertEquals( 'components', $url->getParam( 'module' ) );
+ $this->assertEquals( 'view', $url->getParam( 'view' ) );
+ $this->assertEquals( 'trunk', $url->getParam( 'content' ) );
+ $this->assertEquals( 'a', $url->getParam( 'param1' ) );
+ $this->assertEquals( array( 'x', 'y', 'z' ), $url->getParam( 'param2'
) );
+ }
+
+ public function
testGetUnorderedParametersMultipleValuesTypeAggregateSingle()
+ {
+ $urlCfg = new ezcUrlConfiguration();
+ $urlCfg->addOrderedParameter( 'section' );
+ $urlCfg->addOrderedParameter( 'module' );
+ $urlCfg->addOrderedParameter( 'view' );
+ $urlCfg->addOrderedParameter( 'content' );
+ $urlCfg->addUnorderedParameter( 'param1' );
+ $urlCfg->addUnorderedParameter( 'param2',
ezcUrlConfiguration::AGGREGATE_ARGUMENTS );
+
+ $url = new ezcUrl(
"http://www.example.com/doc/components/view/trunk/(param1)/a/(param2)/x/(param2)/y",
$urlCfg );
+ $expected =
'http://www.example.com/doc/components/view/trunk/(param1)/a/(param2)/x/(param2)/y';
+ $this->assertEquals( $expected, $url->buildUrl() );
+
+ $this->assertEquals( 'doc', $url->getParam( 'section' ) );
+ $this->assertEquals( 'components', $url->getParam( 'module' ) );
+ $this->assertEquals( 'view', $url->getParam( 'view' ) );
+ $this->assertEquals( 'trunk', $url->getParam( 'content' ) );
+ $this->assertEquals( 'a', $url->getParam( 'param1' ) );
+ $this->assertEquals( array( 'x', 'y' ), $url->getParam( 'param2' ) );
}
public function testIsSet()
--
svn-components mailing list
[email protected]
http://lists.ez.no/mailman/listinfo/svn-components