Code Duplication    Length = 81-81 lines in 2 locations

tests/php/controller/viewcontrollerTest.php 2 locations

@@ 314-394 (lines=81) @@
311
	/**
312
	 * @dataProvider indexPublicDataProvider
313
	 */
314
	public function testPublicIndex($serverVersion, $isIE, $shareeActions, $shareeCanEdit) {
315
		$this->request->expects($this->once())
316
			->method('isUserAgent')
317
			->with(['/(MSIE)|(Trident)/'])
318
			->will($this->returnValue($isIE));
319
320
		$this->config->expects($this->at(0))
321
			->method('getSystemValue')
322
			->with('version')
323
			->will($this->returnValue($serverVersion));
324
325
		$this->config->expects($this->at(1))
326
			->method('getAppValue')
327
			->with($this->appName, 'installed_version')
328
			->will($this->returnValue('42.13.37'));
329
330
		$this->config->expects($this->at(2))
331
			->method('getAppValue')
332
			->with('theming', 'color', '#0082C9')
333
			->will($this->returnValue('#ff00ff'));
334
335
		$this->request->expects($this->at(1))
336
			->method('getServerProtocol')
337
			->will($this->returnValue('fancy_protocol'));
338
339
		$this->request->expects($this->at(2))
340
			->method('getServerHost')
341
			->will($this->returnValue('nextcloud-host.tld'));
342
343
		$this->request->expects($this->at(3))
344
			->method('getRequestUri')
345
			->will($this->returnValue('/request/uri/123/42'));
346
347
		$this->urlGenerator->expects($this->at(0))
348
			->method('imagePath')
349
			->with('core', 'favicon-touch.png')
350
			->will($this->returnValue('/core/img/foo'));
351
352
		$this->urlGenerator->expects($this->at(1))
353
			->method('getAbsoluteURL')
354
			->with('/core/img/foo')
355
			->will($this->returnValue('fancy_protocol://foo.bar/core/img/foo'));
356
357
		$this->urlGenerator->expects($this->at(2))
358
			->method('linkTo')
359
			->with('', 'remote.php')
360
			->will($this->returnValue('remote.php'));
361
362
		$this->urlGenerator->expects($this->at(3))
363
			->method('getAbsoluteURL')
364
			->with('remote.php/dav/public-calendars/fancy_token_123?export')
365
			->will($this->returnValue('fancy_protocol://foo.bar/remote.php/dav/public-calendars/fancy_token_123?export'));
366
367
		$this->request->expects($this->at(4))
368
			->method('getServerProtocol')
369
			->will($this->returnValue('fancy_protocol'));
370
371
		$actual = $this->controller->publicIndexForEmbedding('fancy_token_123');
372
373
		$this->assertInstanceOf('OCP\AppFramework\Http\TemplateResponse', $actual);
374
		$this->assertEquals([
375
			'appVersion' => '42.13.37',
376
			'initialView' => 'month',
377
			'emailAddress' => '',
378
			'skipPopover' => 'no',
379
			'weekNumbers' => 'no',
380
			'isPublic' => true,
381
			'isEmbedded' => true,
382
			'shareURL' => 'fancy_protocol://nextcloud-host.tld/request/uri/123/42',
383
			'previewImage' => 'fancy_protocol://foo.bar/core/img/foo',
384
			'firstRun' => 'no',
385
			'isIE' => $isIE,
386
			'defaultColor' => '#ff00ff',
387
			'webcalURL' => 'webcal://foo.bar/remote.php/dav/public-calendars/fancy_token_123?export',
388
			'downloadURL' => 'fancy_protocol://foo.bar/remote.php/dav/public-calendars/fancy_token_123?export',
389
			'token' => 'fancy_token_123',
390
			'shareeCanEditShares' => $shareeActions,
391
			'shareeCanEditCalendarProperties' => $shareeCanEdit,
392
		], $actual->getParams());
393
		$this->assertEquals('main', $actual->getTemplateName());
394
	}
395
396
	/**
397
	 * @dataProvider indexPublicDataProvider
@@ 399-479 (lines=81) @@
396
	/**
397
	 * @dataProvider indexPublicDataProvider
398
	 */
399
	public function testPublicIndexWithBranding($serverVersion, $isIE, $shareeActions, $shareeCanEdit) {
400
		$this->request->expects($this->once())
401
			->method('isUserAgent')
402
			->with(['/(MSIE)|(Trident)/'])
403
			->will($this->returnValue($isIE));
404
405
		$this->config->expects($this->at(0))
406
			->method('getSystemValue')
407
			->with('version')
408
			->will($this->returnValue($serverVersion));
409
410
		$this->config->expects($this->at(1))
411
			->method('getAppValue')
412
			->with($this->appName, 'installed_version')
413
			->will($this->returnValue('42.13.37'));
414
415
		$this->config->expects($this->at(2))
416
			->method('getAppValue')
417
			->with('theming', 'color', '#0082C9')
418
			->will($this->returnValue('#ff00ff'));
419
420
		$this->request->expects($this->at(1))
421
			->method('getServerProtocol')
422
			->will($this->returnValue('fancy_protocol'));
423
424
		$this->request->expects($this->at(2))
425
			->method('getServerHost')
426
			->will($this->returnValue('nextcloud-host.tld'));
427
428
		$this->request->expects($this->at(3))
429
			->method('getRequestUri')
430
			->will($this->returnValue('/request/uri/123/42'));
431
432
		$this->urlGenerator->expects($this->at(0))
433
			->method('imagePath')
434
			->with('core', 'favicon-touch.png')
435
			->will($this->returnValue('/core/img/foo'));
436
437
		$this->urlGenerator->expects($this->at(1))
438
			->method('getAbsoluteURL')
439
			->with('/core/img/foo')
440
			->will($this->returnValue('fancy_protocol://foo.bar/core/img/foo'));
441
442
		$this->urlGenerator->expects($this->at(2))
443
			->method('linkTo')
444
			->with('', 'remote.php')
445
			->will($this->returnValue('remote.php'));
446
447
		$this->urlGenerator->expects($this->at(3))
448
			->method('getAbsoluteURL')
449
			->with('remote.php/dav/public-calendars/fancy_token_123?export')
450
			->will($this->returnValue('fancy_protocol://foo.bar/remote.php/dav/public-calendars/fancy_token_123?export'));
451
452
		$this->request->expects($this->at(4))
453
			->method('getServerProtocol')
454
			->will($this->returnValue('fancy_protocol'));
455
456
		$actual = $this->controller->publicIndexWithBranding('fancy_token_123');
457
458
		$this->assertInstanceOf('OCP\AppFramework\Http\TemplateResponse', $actual);
459
		$this->assertEquals([
460
			'appVersion' => '42.13.37',
461
			'initialView' => 'month',
462
			'emailAddress' => '',
463
			'skipPopover' => 'no',
464
			'weekNumbers' => 'no',
465
			'isPublic' => true,
466
			'isEmbedded' => false,
467
			'shareURL' => 'fancy_protocol://nextcloud-host.tld/request/uri/123/42',
468
			'previewImage' => 'fancy_protocol://foo.bar/core/img/foo',
469
			'firstRun' => 'no',
470
			'isIE' => $isIE,
471
			'defaultColor' => '#ff00ff',
472
			'webcalURL' => 'webcal://foo.bar/remote.php/dav/public-calendars/fancy_token_123?export',
473
			'downloadURL' => 'fancy_protocol://foo.bar/remote.php/dav/public-calendars/fancy_token_123?export',
474
			'token' => 'fancy_token_123',
475
			'shareeCanEditShares' => $shareeActions,
476
			'shareeCanEditCalendarProperties' => $shareeCanEdit,
477
		], $actual->getParams());
478
		$this->assertEquals('public', $actual->getTemplateName());
479
	}
480
481
	public function indexPublicDataProvider() {
482
		return [