Example #1
0
	/**
	 * @test
	 */
	public function getQueryArgumentsWithMethodGetPostMergesParameters() {
		$_GET = array(
			'key1' => 'GET1',
			'key2' => 'GET2',
			'key3' => array(
				'key31' => 'GET31',
				'key32' => 'GET32',
				'key33' => array(
					'key331' => 'GET331',
					'key332' => 'GET332',
				)
			)
		);
		$_POST = array(
			'key2' => 'POST2',
			'key3' => array(
				'key32' => 'POST32',
				'key33' => array(
					'key331' => 'POST331',
				)
			)
		);
		$getQueryArgumentsConfiguration = array();
		$getQueryArgumentsConfiguration['method'] = 'GET,POST';
		$expectedResult = $this->rawUrlEncodeSquareBracketsInUrl('&key1=GET1&key2=POST2&key3[key31]=GET31&key3[key32]=POST32&key3[key33][key331]=POST331&key3[key33][key332]=GET332');
		$actualResult = $this->subject->getQueryArguments($getQueryArgumentsConfiguration);
		$this->assertEquals($expectedResult, $actualResult);
	}
 /**
  * @test
  */
 public function getQueryArgumentsOverrulesMultiDimensionalForcedParameters()
 {
     $_SERVER['QUERY_STRING'] = 'key1=value1' . '&key2=value2' . '&key3[key31]=value31' . '&key3[key32][key321]=value321' . '&key3[key32][key322]=value322';
     $_POST = array('key1' => 'value1', 'key2' => 'value2', 'key3' => array('key31' => 'value31', 'key32' => array('key321' => 'value321', 'key322' => 'value322')));
     $getQueryArgumentsConfiguration = array();
     $getQueryArgumentsConfiguration['exclude'] = array();
     $getQueryArgumentsConfiguration['exclude'][] = 'key1';
     $getQueryArgumentsConfiguration['exclude'][] = 'key3[key31]';
     $getQueryArgumentsConfiguration['exclude'][] = 'key3[key32][key321]';
     $getQueryArgumentsConfiguration['exclude'][] = 'key3[key32][key322]';
     $getQueryArgumentsConfiguration['exclude'] = implode(',', $getQueryArgumentsConfiguration['exclude']);
     $overruleArguments = array('key2' => 'value2Overruled', 'key3' => array('key32' => array('key321' => 'value321Overruled', 'key323' => 'value323Overruled')));
     $expectedResult = $this->rawUrlEncodeSquareBracketsInUrl('&key2=value2Overruled&key3[key32][key321]=value321Overruled&key3[key32][key323]=value323Overruled');
     $actualResult = $this->cObj->getQueryArguments($getQueryArgumentsConfiguration, $overruleArguments, TRUE);
     $this->assertEquals($expectedResult, $actualResult);
     $getQueryArgumentsConfiguration['method'] = 'POST';
     $actualResult = $this->cObj->getQueryArguments($getQueryArgumentsConfiguration, $overruleArguments, TRUE);
     $this->assertEquals($expectedResult, $actualResult);
 }