Code Duplication    Length = 33-36 lines in 2 locations

tests/ElasticSearchPageControllerTest.php 2 locations

@@ 496-531 (lines=36) @@
493
 */
494
495
496
	public function testSearchOnePageNoAggregation() {
497
		$this->enableHighlights();
498
		$this->autoFollowRedirection = false;
499
		$searchTerm = 'mineralogy';
500
501
		//Note pages need to be published, by default fixtures only reside in Stage
502
		$searchPageObj = $this->ElasticSearchPage2;
503
		$url = rtrim($searchPageObj->Link(), '/');
504
		$url = $url.'?q='.$searchTerm;
505
		$response = $this->get($url);
506
		$this->assertEquals(200, $response->getStatusCode());
507
508
		//There are 3 results for mineralogy
509
		$this->assertSelectorStartsWithOrEquals('div.resultsFound', 0,
510
			"Page 1 of 1  (3 results found");
511
512
513
		//Check all the result highlights for mineralogy matches
514
		$this->assertSelectorStartsWithOrEquals('strong.hl', 1, 'mineralogy');
515
		$this->assertSelectorStartsWithOrEquals('strong.hl', 2, 'Mineralogy');
516
		$this->assertSelectorStartsWithOrEquals('strong.hl', 3, 'mineralogy');
517
		$this->assertSelectorStartsWithOrEquals('strong.hl', 4, 'Mineralogy');
518
		$this->assertSelectorStartsWithOrEquals('strong.hl', 5, 'mineralogy');
519
520
521
		// Check the start text of the 3 results
522
		$this->assertSelectorStartsWithOrEquals('div.searchResult h4 a', 0,
523
			"Image taken from page 273 of");
524
		$this->assertSelectorStartsWithOrEquals('div.searchResult h4 a', 1,
525
			'Image taken from page 69 of');
526
		$this->assertSelectorStartsWithOrEquals('div.searchResult h4 a', 2,
527
			'Image taken from page 142 of');
528
529
		// No span.count means no aggregations
530
		$this->assertExactHTMLMatchBySelector('span.count', array());
531
	}
532
533
534
	/* When a search is posted, should redirect to the same URL with the search term attached.  This
@@ 563-595 (lines=33) @@
560
	/*
561
	Test a search for an uncommon term, no pagination here
562
	 */
563
	public function testSearchOnePage() {
564
		$this->enableHighlights();
565
		$this->autoFollowRedirection = false;
566
		$searchTerm = 'mineralogy';
567
568
		//Note pages need to be published, by default fixtures only reside in Stage
569
		$searchPageObj = $this->ElasticSearchPage;
570
		$url = rtrim($searchPageObj->Link(), '/');
571
		$url = $url.'?q='.$searchTerm;
572
		$response = $this->get($url);
573
		$this->assertEquals(200, $response->getStatusCode());
574
575
		//There are 3 results for mineralogy
576
		$this->assertSelectorStartsWithOrEquals('div.resultsFound', 0,
577
			"Page 1 of 1  (3 results found");
578
579
580
		//Check all the result highlights for mineralogy matches
581
		$this->assertSelectorStartsWithOrEquals('strong.hl', 1, 'mineralogy');
582
		$this->assertSelectorStartsWithOrEquals('strong.hl', 2, 'Mineralogy');
583
		$this->assertSelectorStartsWithOrEquals('strong.hl', 3, 'mineralogy');
584
		$this->assertSelectorStartsWithOrEquals('strong.hl', 4, 'Mineralogy');
585
		$this->assertSelectorStartsWithOrEquals('strong.hl', 5, 'mineralogy');
586
587
588
		// Check the start text of the 3 results
589
		$this->assertSelectorStartsWithOrEquals('div.searchResult h4 a', 0,
590
			"Image taken from page 273 of");
591
		$this->assertSelectorStartsWithOrEquals('div.searchResult h4 a', 1,
592
			'Image taken from page 69 of');
593
		$this->assertSelectorStartsWithOrEquals('div.searchResult h4 a', 2,
594
			'Image taken from page 142 of');
595
	}
596
597
598