Code Duplication    Length = 33-36 lines in 2 locations

tests/ElasticSearchPageControllerTest.php 2 locations

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