Code Duplication    Length = 33-36 lines in 2 locations

tests/ElasticSearchPageControllerTest.php 2 locations

@@ 472-507 (lines=36) @@
469
 */
470
471
472
	public function testSearchOnePageNoAggregation() {
473
		$this->enableHighlights();
474
		$this->autoFollowRedirection = false;
475
		$searchTerm = 'mineralogy';
476
477
		//Note pages need to be published, by default fixtures only reside in Stage
478
		$searchPageObj = $this->ElasticSearchPage2;
479
		$url = rtrim($searchPageObj->Link(), '/');
480
		$url = $url.'?q='.$searchTerm;
481
		$response = $this->get($url);
482
		$this->assertEquals(200, $response->getStatusCode());
483
484
		//There are 3 results for mineralogy
485
		$this->assertSelectorStartsWithOrEquals('div.resultsFound', 0,
486
			"Page 1 of 1  (3 results found");
487
488
489
		//Check all the result highlights for mineralogy matches
490
		$this->assertSelectorStartsWithOrEquals('strong.hl', 1, 'mineralogy');
491
		$this->assertSelectorStartsWithOrEquals('strong.hl', 2, 'Mineralogy');
492
		$this->assertSelectorStartsWithOrEquals('strong.hl', 3, 'mineralogy');
493
		$this->assertSelectorStartsWithOrEquals('strong.hl', 4, 'Mineralogy');
494
		$this->assertSelectorStartsWithOrEquals('strong.hl', 5, 'mineralogy');
495
496
497
		// Check the start text of the 3 results
498
		$this->assertSelectorStartsWithOrEquals('div.searchResult h4 a', 0,
499
			"Image taken from page 273 of");
500
		$this->assertSelectorStartsWithOrEquals('div.searchResult h4 a', 1,
501
			'Image taken from page 69 of');
502
		$this->assertSelectorStartsWithOrEquals('div.searchResult h4 a', 2,
503
			'Image taken from page 142 of');
504
505
		// No span.count means no aggregations
506
		$this->assertExactHTMLMatchBySelector('span.count', array());
507
	}
508
509
510
	/* When a search is posted, should redirect to the same URL with the search term attached.  This
@@ 539-571 (lines=33) @@
536
	/*
537
	Test a search for an uncommon term, no pagination here
538
	 */
539
	public function testSearchOnePage() {
540
		$this->enableHighlights();
541
		$this->autoFollowRedirection = false;
542
		$searchTerm = 'mineralogy';
543
544
		//Note pages need to be published, by default fixtures only reside in Stage
545
		$searchPageObj = $this->ElasticSearchPage;
546
		$url = rtrim($searchPageObj->Link(), '/');
547
		$url = $url.'?q='.$searchTerm;
548
		$response = $this->get($url);
549
		$this->assertEquals(200, $response->getStatusCode());
550
551
		//There are 3 results for mineralogy
552
		$this->assertSelectorStartsWithOrEquals('div.resultsFound', 0,
553
			"Page 1 of 1  (3 results found");
554
555
556
		//Check all the result highlights for mineralogy matches
557
		$this->assertSelectorStartsWithOrEquals('strong.hl', 1, 'mineralogy');
558
		$this->assertSelectorStartsWithOrEquals('strong.hl', 2, 'Mineralogy');
559
		$this->assertSelectorStartsWithOrEquals('strong.hl', 3, 'mineralogy');
560
		$this->assertSelectorStartsWithOrEquals('strong.hl', 4, 'Mineralogy');
561
		$this->assertSelectorStartsWithOrEquals('strong.hl', 5, 'mineralogy');
562
563
564
		// Check the start text of the 3 results
565
		$this->assertSelectorStartsWithOrEquals('div.searchResult h4 a', 0,
566
			"Image taken from page 273 of");
567
		$this->assertSelectorStartsWithOrEquals('div.searchResult h4 a', 1,
568
			'Image taken from page 69 of');
569
		$this->assertSelectorStartsWithOrEquals('div.searchResult h4 a', 2,
570
			'Image taken from page 142 of');
571
	}
572
573
574