2011-08-21 13:14:15 +02:00
< ? php
/**
*
* @ package testing
* @ copyright ( c ) 2011 phpBB Group
2011-12-31 16:05:02 +00:00
* @ license http :// opensource . org / licenses / gpl - 2.0 . php GNU General Public License v2
2011-08-21 13:14:15 +02:00
*
*/
require_once dirname ( __FILE__ ) . '/../../phpBB/includes/functions.php' ;
class phpbb_session_append_sid_test extends phpbb_test_case
{
public function append_sid_data ()
{
return array (
2011-08-21 18:56:47 +02:00
array ( 'viewtopic.php?t=1&f=2' , false , true , false , 'viewtopic.php?t=1&f=2' , 'parameters in url-argument' ),
array ( 'viewtopic.php' , 't=1&f=2' , true , false , 'viewtopic.php?t=1&f=2' , 'parameters in params-argument using amp' ),
array ( 'viewtopic.php' , 't=1&f=2' , false , false , 'viewtopic.php?t=1&f=2' , 'parameters in params-argument using &' ),
array ( 'viewtopic.php' , array ( 't' => 1 , 'f' => 2 ), true , false , 'viewtopic.php?t=1&f=2' , 'parameters in params-argument as array' ),
2011-08-21 13:14:15 +02:00
// Custom sid parameter
2011-08-21 18:56:47 +02:00
array ( 'viewtopic.php' , 't=1&f=2' , true , 'custom-sid' , 'viewtopic.php?t=1&f=2&sid=custom-sid' , 'using session_id' ),
2011-08-21 13:14:15 +02:00
// Testing anchors
2011-08-21 18:56:47 +02:00
array ( 'viewtopic.php?t=1&f=2#anchor' , false , true , false , 'viewtopic.php?t=1&f=2#anchor' , 'anchor in url-argument' ),
array ( 'viewtopic.php' , 't=1&f=2#anchor' , true , false , 'viewtopic.php?t=1&f=2#anchor' , 'anchor in params-argument' ),
array ( 'viewtopic.php' , array ( 't' => 1 , 'f' => 2 , '#' => 'anchor' ), true , false , 'viewtopic.php?t=1&f=2#anchor' , 'anchor in params-argument (array)' ),
2011-08-21 13:14:15 +02:00
// Anchors and custom sid
2011-08-21 18:56:47 +02:00
array ( 'viewtopic.php?t=1&f=2#anchor' , false , true , 'custom-sid' , 'viewtopic.php?t=1&f=2&sid=custom-sid#anchor' , 'anchor in url-argument using session_id' ),
array ( 'viewtopic.php' , 't=1&f=2#anchor' , true , 'custom-sid' , 'viewtopic.php?t=1&f=2&sid=custom-sid#anchor' , 'anchor in params-argument using session_id' ),
array ( 'viewtopic.php' , array ( 't' => 1 , 'f' => 2 , '#' => 'anchor' ), true , 'custom-sid' , 'viewtopic.php?t=1&f=2&sid=custom-sid#anchor' , 'anchor in params-argument (array) using session_id' ),
2011-08-21 13:14:15 +02:00
// Empty parameters should not append the ?
2011-08-21 18:56:47 +02:00
array ( 'viewtopic.php' , false , true , false , 'viewtopic.php' , 'no params using bool false' ),
array ( 'viewtopic.php' , '' , true , false , 'viewtopic.php' , 'no params using empty string' ),
array ( 'viewtopic.php' , array (), true , false , 'viewtopic.php' , 'no params using empty array' ),
2011-08-21 13:14:15 +02:00
);
}
/**
* @ dataProvider append_sid_data
*/
2011-08-21 18:56:47 +02:00
public function test_append_sid ( $url , $params , $is_amp , $session_id , $expected , $description )
2011-08-21 13:14:15 +02:00
{
$this -> assertEquals ( $expected , append_sid ( $url , $params , $is_amp , $session_id ));
}
}