From 4fc8da1d152035b107dc9b8e38149f9eebab9356 Mon Sep 17 00:00:00 2001 From: Romain Neutron Date: Wed, 11 Jan 2012 14:46:06 +0100 Subject: [PATCH 1/3] Fix #206 : search by date --- lib/classes/module/prod.class.php | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/lib/classes/module/prod.class.php b/lib/classes/module/prod.class.php index 4c6757d98a..9f07050663 100644 --- a/lib/classes/module/prod.class.php +++ b/lib/classes/module/prod.class.php @@ -70,10 +70,10 @@ class module_prod $name = $meta->get_name(); if ($meta->get_type() == 'date') { - if (isset($dates[$id])) - $dates[$id]['sbas'][] = $sbas_id; + if (isset($dates[$name])) + $dates[$name]['sbas'][] = $sbas_id; else - $dates[$id] = array('sbas' => array($sbas_id), 'fieldname' => $name); + $dates[$name] = array('sbas' => array($sbas_id), 'fieldname' => $name); } if (isset($fields[$name])) From bffd7e6ce7920765e9aca85ceba29261ead67709 Mon Sep 17 00:00:00 2001 From: Romain Neutron Date: Wed, 11 Jan 2012 15:33:46 +0100 Subject: [PATCH 2/3] Fix #207 : cache is not well refreshed --- lib/classes/searchEngine/options.class.php | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/lib/classes/searchEngine/options.class.php b/lib/classes/searchEngine/options.class.php index aaff7c25f6..33fe812ea8 100644 --- a/lib/classes/searchEngine/options.class.php +++ b/lib/classes/searchEngine/options.class.php @@ -442,8 +442,14 @@ class searchEngine_options implements Serializable foreach ($serialized as $key => $value) { - if (in_array($key, array('date_min', 'date_max'))) + if(is_null($value)) + { + $value = null; + } + elseif (in_array($key, array('date_min', 'date_max'))) + { $value = new DateTime($value); + } elseif ($value instanceof stdClass) $value = (array) $value; From 3840bf42d11bf714390dbad61bcfceb847d66a16 Mon Sep 17 00:00:00 2001 From: Romain Neutron Date: Wed, 11 Jan 2012 15:34:07 +0100 Subject: [PATCH 3/3] Add unitTests for #207 --- lib/unitTest/searchEngine_optionsTest.php | 360 ++++++++++++++++++++++ 1 file changed, 360 insertions(+) create mode 100644 lib/unitTest/searchEngine_optionsTest.php diff --git a/lib/unitTest/searchEngine_optionsTest.php b/lib/unitTest/searchEngine_optionsTest.php new file mode 100644 index 0000000000..11e9e47e3d --- /dev/null +++ b/lib/unitTest/searchEngine_optionsTest.php @@ -0,0 +1,360 @@ +object = new searchEngine_options(); + } + + /** + * Tears down the fixture, for example, closes a network connection. + * This method is called after a test is executed. + */ + public function tearDown() + { + + } + + /** + * @covers {className}::{origMethodName} + */ + public function testSet_locale() + { + $locale = 'BABA'; + $this->object->set_locale($locale); + $this->assertEquals($locale, $this->object->get_locale()); + } + + /** + * @covers {className}::{origMethodName} + * @todo Implement testGet_locale(). + */ + public function testGet_locale() + { + $locale = null; + $this->object->set_locale($locale); + $this->assertEquals($locale, $this->object->get_locale()); + } + + /** + * @covers {className}::{origMethodName} + * @todo Implement testSet_sort(). + */ + public function testSet_sort() + { + $by = 'NAME'; + $sort = 'ASC'; + $this->object->set_sort($by, $sort); + $this->assertEquals($by, $this->object->get_sortby()); + $this->assertEquals($sort, $this->object->get_sortord()); + $this->object->set_sort($by); + $this->assertEquals($by, $this->object->get_sortby()); + $this->assertEquals(searchEngine_options::SORT_MODE_DESC, $this->object->get_sortord()); + } + + /** + * @covers {className}::{origMethodName} + * @todo Implement testGet_sortby(). + */ + public function testGet_sortby() + { + $by = 'NAME'; + $sort = 'DESC'; + $this->object->set_sort($by, $sort); + $this->assertEquals($by, $this->object->get_sortby()); + $this->assertEquals($sort, $this->object->get_sortord()); + } + + /** + * @covers {className}::{origMethodName} + * @todo Implement testGet_sortord(). + */ + public function testGet_sortord() + { + $by = 'NAME'; + $sort = 'DESC'; + $this->object->set_sort($by, $sort); + $this->assertEquals($by, $this->object->get_sortby()); + $this->assertEquals($sort, $this->object->get_sortord()); + } + + /** + * @covers {className}::{origMethodName} + * @todo Implement testSet_use_stemming(). + */ + public function testSet_use_stemming() + { + $bool = true; + $this->object->set_use_stemming($bool); + $this->assertEquals($bool, $this->object->get_use_stemming()); + $bool = false; + $this->object->set_use_stemming($bool); + $this->assertEquals($bool, $this->object->get_use_stemming()); + } + + /** + * @covers {className}::{origMethodName} + * @todo Implement testGet_use_stemming(). + */ + public function testGet_use_stemming() + { + $bool = true; + $this->object->set_use_stemming($bool); + $this->assertEquals($bool, $this->object->get_use_stemming()); + $bool = false; + $this->object->set_use_stemming($bool); + $this->assertEquals($bool, $this->object->get_use_stemming()); + } + + /** + * @covers {className}::{origMethodName} + * @todo Implement testSet_search_type(). + */ + public function testSet_search_type() + { + $type = "caca"; + $this->object->set_search_type($type); + $this->assertEquals(searchEngine_options::RECORD_RECORD, $this->object->get_search_type()); + $type = searchEngine_options::RECORD_RECORD; + $this->object->set_search_type($type); + $this->assertEquals(searchEngine_options::RECORD_RECORD, $this->object->get_search_type()); + $type = searchEngine_options::RECORD_GROUPING; + $this->object->set_search_type($type); + $this->assertEquals(searchEngine_options::RECORD_GROUPING, $this->object->get_search_type()); + } + + /** + * @covers {className}::{origMethodName} + * @todo Implement testGet_search_type(). + */ + public function testGet_search_type() + { + $type = "caca"; + $this->object->set_search_type($type); + $this->assertEquals(searchEngine_options::RECORD_RECORD, $this->object->get_search_type()); + $type = searchEngine_options::RECORD_RECORD; + $this->object->set_search_type($type); + $this->assertEquals(searchEngine_options::RECORD_RECORD, $this->object->get_search_type()); + $type = searchEngine_options::RECORD_GROUPING; + $this->object->set_search_type($type); + $this->assertEquals(searchEngine_options::RECORD_GROUPING, $this->object->get_search_type()); + } + + /** + * @covers {className}::{origMethodName} + * @todo Implement testSet_bases(). + */ + public function testSet_bases() + { + $bases = array_keys(self::$user->ACL()->get_granted_base()); + $this->object->set_bases($bases, self::$user->ACL()); + $this->assertEquals(array_values($bases), array_values($this->object->get_bases())); + } + + /** + * @covers {className}::{origMethodName} + * @todo Implement testGet_bases(). + */ + public function testGet_bases() + { + $bases = array_keys(self::$user->ACL()->get_granted_base()); + $this->object->set_bases($bases, self::$user->ACL()); + $this->assertEquals(array_values($bases), array_values($this->object->get_bases())); + } + + /** + * @covers {className}::{origMethodName} + * @todo Implement testSet_fields(). + */ + public function testSet_fields() + { + // Remove the following lines when you implement this test. + $this->markTestIncomplete( + 'This test has not been implemented yet.' + ); + } + + /** + * @covers {className}::{origMethodName} + * @todo Implement testGet_fields(). + */ + public function testGet_fields() + { + // Remove the following lines when you implement this test. + $this->markTestIncomplete( + 'This test has not been implemented yet.' + ); + } + + /** + * @covers {className}::{origMethodName} + * @todo Implement testSet_status(). + */ + public function testSet_status() + { + // Remove the following lines when you implement this test. + $this->markTestIncomplete( + 'This test has not been implemented yet.' + ); + } + + /** + * @covers {className}::{origMethodName} + * @todo Implement testGet_status(). + */ + public function testGet_status() + { + // Remove the following lines when you implement this test. + $this->markTestIncomplete( + 'This test has not been implemented yet.' + ); + } + + /** + * @covers {className}::{origMethodName} + * @todo Implement testSet_record_type(). + */ + public function testSet_record_type() + { + // Remove the following lines when you implement this test. + $this->markTestIncomplete( + 'This test has not been implemented yet.' + ); + } + + /** + * @covers {className}::{origMethodName} + * @todo Implement testGet_record_type(). + */ + public function testGet_record_type() + { + // Remove the following lines when you implement this test. + $this->markTestIncomplete( + 'This test has not been implemented yet.' + ); + } + + /** + * @covers {className}::{origMethodName} + * @todo Implement testSet_min_date(). + */ + public function testSet_min_date() + { + // Remove the following lines when you implement this test. + $this->markTestIncomplete( + 'This test has not been implemented yet.' + ); + } + + /** + * @covers {className}::{origMethodName} + * @todo Implement testGet_min_date(). + */ + public function testGet_min_date() + { + // Remove the following lines when you implement this test. + $this->markTestIncomplete( + 'This test has not been implemented yet.' + ); + } + + /** + * @covers {className}::{origMethodName} + * @todo Implement testSet_max_date(). + */ + public function testSet_max_date() + { + // Remove the following lines when you implement this test. + $this->markTestIncomplete( + 'This test has not been implemented yet.' + ); + } + + /** + * @covers {className}::{origMethodName} + * @todo Implement testGet_max_date(). + */ + public function testGet_max_date() + { + // Remove the following lines when you implement this test. + $this->markTestIncomplete( + 'This test has not been implemented yet.' + ); + } + + /** + * @covers {className}::{origMethodName} + * @todo Implement testSet_date_fields(). + */ + public function testSet_date_fields() + { + // Remove the following lines when you implement this test. + $this->markTestIncomplete( + 'This test has not been implemented yet.' + ); + } + + /** + * @covers {className}::{origMethodName} + * @todo Implement testGet_date_fields(). + */ + public function testGet_date_fields() + { + // Remove the following lines when you implement this test. + $this->markTestIncomplete( + 'This test has not been implemented yet.' + ); + } + + /** + * @covers {className}::{origMethodName} + * @todo Implement testSerialize(). + */ + public function testSerialize() + { + $bases = array_keys(self::$user->ACL()->get_granted_base()); + $this->object->set_bases($bases, self::$user->ACL()); + $this->object->set_date_fields(array()); + $this->object->set_locale('fr_FR'); + $this->object->set_max_date(null); + $this->object->set_min_date(null); + $this->object->set_record_type(searchEngine_options::TYPE_AUDIO); + $this->object->set_search_type(searchEngine_options::RECORD_RECORD); + $this->object->set_sort('Name','DESC'); + $this->object->set_status(array()); + $this->object->set_use_stemming(true); + $this->assertEquals($this->object, unserialize(serialize($this->object))); + } + + /** + * @covers {className}::{origMethodName} + * @todo Implement testUnserialize(). + */ + public function testUnserialize() + { + // Remove the following lines when you implement this test. + $this->markTestIncomplete( + 'This test has not been implemented yet.' + ); + } + +} + +?>