Code Duplication    Length = 19-20 lines in 5 locations

tests/lib/appframework/http/RequestTest.php 5 locations

@@ 611-629 (lines=19) @@
608
		$this->assertSame('http', $requestHttp->getServerProtocol());
609
	}
610
611
	public function testGetServerProtocolWithHttpsServerValueOn() {
612
		$this->config
613
			->expects($this->once())
614
			->method('getSystemValue')
615
			->with('overwriteprotocol')
616
			->will($this->returnValue(''));
617
618
		$request = new Request(
619
			[
620
				'server' => [
621
					'HTTPS' => 'on'
622
				],
623
			],
624
			$this->secureRandom,
625
			$this->config,
626
			$this->stream
627
		);
628
		$this->assertSame('https', $request->getServerProtocol());
629
	}
630
631
	public function testGetServerProtocolWithHttpsServerValueOff() {
632
		$this->config
@@ 631-649 (lines=19) @@
628
		$this->assertSame('https', $request->getServerProtocol());
629
	}
630
631
	public function testGetServerProtocolWithHttpsServerValueOff() {
632
		$this->config
633
			->expects($this->once())
634
			->method('getSystemValue')
635
			->with('overwriteprotocol')
636
			->will($this->returnValue(''));
637
638
		$request = new Request(
639
			[
640
				'server' => [
641
					'HTTPS' => 'off'
642
				],
643
			],
644
			$this->secureRandom,
645
			$this->config,
646
			$this->stream
647
		);
648
		$this->assertSame('http', $request->getServerProtocol());
649
	}
650
651
	public function testGetServerProtocolDefault() {
652
		$this->config
@@ 667-686 (lines=20) @@
664
		$this->assertSame('http', $request->getServerProtocol());
665
	}
666
667
	public function testGetServerProtocolBehindLoadBalancers() {
668
		$this->config
669
			->expects($this->once())
670
			->method('getSystemValue')
671
			->with('overwriteprotocol')
672
			->will($this->returnValue(''));
673
674
		$request = new Request(
675
			[
676
				'server' => [
677
					'HTTP_X_FORWARDED_PROTO' => 'https,http,http'
678
				],
679
			],
680
			$this->secureRandom,
681
			$this->config,
682
			$this->stream
683
		);
684
685
		$this->assertSame('https', $request->getServerProtocol());
686
	}
687
688
	/**
689
	 * @dataProvider userAgentProvider
@@ 891-910 (lines=20) @@
888
		$this->assertSame('my.overwritten.host',  $request->getServerHost());
889
	}
890
891
	public function testGetServerHostWithTrustedDomain() {
892
		$this->config
893
			->expects($this->at(3))
894
			->method('getSystemValue')
895
			->with('trusted_domains')
896
			->will($this->returnValue(['my.trusted.host']));
897
898
		$request = new Request(
899
			[
900
				'server' => [
901
					'HTTP_X_FORWARDED_HOST' => 'my.trusted.host',
902
				],
903
			],
904
			$this->secureRandom,
905
			$this->config,
906
			$this->stream
907
		);
908
909
		$this->assertSame('my.trusted.host',  $request->getServerHost());
910
	}
911
912
	public function testGetServerHostWithUntrustedDomain() {
913
		$this->config
@@ 1183-1202 (lines=20) @@
1180
		];
1181
	}
1182
1183
	public function testGetRequestUriWithoutOverwrite() {
1184
		$this->config
1185
			->expects($this->once())
1186
			->method('getSystemValue')
1187
			->with('overwritewebroot')
1188
			->will($this->returnValue(''));
1189
1190
		$request = new Request(
1191
			[
1192
				'server' => [
1193
					'REQUEST_URI' => '/test.php'
1194
				]
1195
			],
1196
			$this->secureRandom,
1197
			$this->config,
1198
			$this->stream
1199
		);
1200
1201
		$this->assertSame('/test.php', $request->getRequestUri());
1202
	}
1203
1204
	public function providesGetRequestUriWithOverwriteData() {
1205
		return [