<commit_before><?php
/**
 * @package cms
 * @subpackage testing
 * 
 * @todo Fix unpublished pages check in testPublishedPagesMatchedByTitle()
 * @todo All tests run on unpublished pages at the moment, due to the searchform not distinguishing between them
 */
class SearchFormTest extends FunctionalTest {
	
	static $fixture_file = 'SearchFormTest.yml';
	
	protected $mockController;
	
	function waitUntilIndexingFinished() {
		$db = DB::getConn();
		if (method_exists($db, 'waitUntilIndexingFinished')) DB::getConn()->waitUntilIndexingFinished();
	}
	
	function setUpOnce() {
		// HACK Postgres doesn't refresh TSearch indexes when the schema changes after CREATE TABLE
		if(is_a(DB::getConn(), 'PostgreSQLDatabase')) {
			self::kill_temp_db();
		}
		FulltextSearchable::enable();
		parent::setUpOnce();
	}
	
	function setUp() {
		parent::setUp();
		
		$holderPage = $this->objFromFixture('SiteTree', 'searchformholder');
		$this->mockController = new ContentController($holderPage);
		
		$this->waitUntilIndexingFinished();
	}
	
	function testPublishedPagesMatchedByTitle() {<commit_msg>MINOR: Fixed SearchFormTest to run last, and to recreate the test database so that MyISAM tables are used.<commit_after><?php
/**
 * @package cms
 * @subpackage testing
 * 
 * @todo Fix unpublished pages check in testPublishedPagesMatchedByTitle()
 * @todo All tests run on unpublished pages at the moment, due to the searchform not distinguishing between them
 * 
 * Because this manipulates the test database in severe ways, I've renamed the test to force it to run last...
 */
class ZZZSearchFormTest extends FunctionalTest {
	
	static $fixture_file = 'SearchFormTest.yml';
	
	protected $mockController;
	
	function waitUntilIndexingFinished() {
		$db = DB::getConn();
		if (method_exists($db, 'waitUntilIndexingFinished')) DB::getConn()->waitUntilIndexingFinished();
	}
	
	function setUpOnce() {
		// HACK Postgres doesn't refresh TSearch indexes when the schema changes after CREATE TABLE
		// MySQL will need a different table type
		self::kill_temp_db();
		FulltextSearchable::enable();
		self::create_temp_db();
		$this->resetDBSchema(true);
		parent::setUpOnce();
	}
	
	function setUp() {
		parent::setUp();
		
		$holderPage = $this->objFromFixture('SiteTree', 'searchformholder');
		$this->mockController = new ContentController($holderPage);
		
		$this->waitUntilIndexingFinished();
	}
	
	function testPublishedPagesMatchedByTitle() {
{'fraction_non_alphanumeric': 0.11339359079704191, 'fraction_numerical': 0.0, 'mean_word_length': 5.211734693877551, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 12, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '340825', 'n_tokens_mistral': 779, 'n_tokens_neox': 695, 'n_words': 201}