diff --git a/tests/search/FulltextFilterTest.php b/tests/search/FulltextFilterTest.php index efca15c6e..0bbe7e8cc 100755 --- a/tests/search/FulltextFilterTest.php +++ b/tests/search/FulltextFilterTest.php @@ -40,26 +40,36 @@ class FulltextFilterTest extends SapphireTest { } public function testGenerateQuery() { + // Test if columns have table identifier + $filter1 = new FulltextFilter('SearchFields', 'SilverStripe'); + $filter1->setModel('FulltextFilterTest_DataObject'); + $query1 = FulltextFilterTest_DataObject::get()->dataQuery(); + $filter1->apply($query1); + $this->assertNotEquals('"ColumnA", "ColumnB"', $filter1->getDbName()); + $this->assertNotEquals( + array("MATCH (\"ColumnA\", \"ColumnB\") AGAINST ('SilverStripe')"), + $query1->query()->getWhere() + ); + // Test SearchFields $filter1 = new FulltextFilter('SearchFields', 'SilverStripe'); $filter1->setModel('FulltextFilterTest_DataObject'); $query1 = FulltextFilterTest_DataObject::get()->dataQuery(); $filter1->apply($query1); - $this->assertEquals('"ColumnA", "ColumnB"', $filter1->getDbName()); + $this->assertEquals('"FulltextFilterTest_DataObject"."ColumnA", "FulltextFilterTest_DataObject"."ColumnB"', $filter1->getDbName()); $this->assertEquals( - array("MATCH (\"ColumnA\", \"ColumnB\") AGAINST ('SilverStripe')"), + array("MATCH (\"FulltextFilterTest_DataObject\".\"ColumnA\", \"FulltextFilterTest_DataObject\".\"ColumnB\") AGAINST ('SilverStripe')"), $query1->query()->getWhere() ); - // Test Other searchfields $filter2 = new FulltextFilter('OtherSearchFields', 'SilverStripe'); $filter2->setModel('FulltextFilterTest_DataObject'); $query2 = FulltextFilterTest_DataObject::get()->dataQuery(); $filter2->apply($query2); - $this->assertEquals('"ColumnC", "ColumnD"', $filter2->getDbName()); + $this->assertEquals('"FulltextFilterTest_DataObject"."ColumnC", "FulltextFilterTest_DataObject"."ColumnD"', $filter2->getDbName()); $this->assertEquals( - array("MATCH (\"ColumnC\", \"ColumnD\") AGAINST ('SilverStripe')"), + array("MATCH (\"FulltextFilterTest_DataObject\".\"ColumnC\", \"FulltextFilterTest_DataObject\".\"ColumnD\") AGAINST ('SilverStripe')"), $query2->query()->getWhere() ); @@ -102,4 +112,4 @@ class FulltextFilterTest_DataObject extends DataObject implements TestOnly { "MySQLDatabase" => "ENGINE=MyISAM", ); -} \ No newline at end of file +}