DictionaryLoaderTest.php 2.5 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677
  1. <?php
  2. /**
  3. * Zend Framework
  4. *
  5. * LICENSE
  6. *
  7. * This source file is subject to the new BSD license that is bundled
  8. * with this package in the file LICENSE.txt.
  9. * It is also available through the world-wide-web at this URL:
  10. * http://framework.zend.com/license/new-bsd
  11. * If you did not receive a copy of the license and are unable to
  12. * obtain it through the world-wide-web, please send an email
  13. * to license@zend.com so we can send you a copy immediately.
  14. *
  15. * @category Zend
  16. * @package Zend_Search_Lucene
  17. * @subpackage UnitTests
  18. * @copyright Copyright (c) 2005-2010 Zend Technologies USA Inc. (http://www.zend.com)
  19. * @license http://framework.zend.com/license/new-bsd New BSD License
  20. * @version $Id$
  21. */
  22. /**
  23. * Zend_Search_Lucene_Storage_Directory_Filesystem
  24. */
  25. require_once 'Zend/Search/Lucene/Storage/Directory/Filesystem.php';
  26. /**
  27. * Zend_Search_Lucene_Index_SegmentInfo
  28. */
  29. require_once 'Zend/Search/Lucene/Index/SegmentInfo.php';
  30. /**
  31. * Zend_Search_Lucene_Index_DictionaryLoader
  32. */
  33. require_once 'Zend/Search/Lucene/Index/DictionaryLoader.php';
  34. /**
  35. * PHPUnit test case
  36. */
  37. require_once 'PHPUnit/Framework/TestCase.php';
  38. /**
  39. * @category Zend
  40. * @package Zend_Search_Lucene
  41. * @subpackage UnitTests
  42. * @copyright Copyright (c) 2005-2010 Zend Technologies USA Inc. (http://www.zend.com)
  43. * @license http://framework.zend.com/license/new-bsd New BSD License
  44. * @group Zend_Search_Lucene
  45. */
  46. class Zend_Search_Lucene_Index_DictionaryLoaderTest extends PHPUnit_Framework_TestCase
  47. {
  48. public function testCreate()
  49. {
  50. $directory = new Zend_Search_Lucene_Storage_Directory_Filesystem(dirname(__FILE__) . '/_source/_files');
  51. $stiFile = $directory->getFileObject('_1.sti');
  52. $stiFileData = $stiFile->readBytes($directory->fileLength('_1.sti'));
  53. // Load dictionary index data
  54. list($termDictionary, $termDictionaryInfos) = unserialize($stiFileData);
  55. $segmentInfo = new Zend_Search_Lucene_Index_SegmentInfo($directory, '_1', 2);
  56. $tiiFile = $segmentInfo->openCompoundFile('.tii');
  57. $tiiFileData = $tiiFile->readBytes($segmentInfo->compoundFileLength('.tii'));
  58. // Load dictionary index data
  59. list($loadedTermDictionary, $loadedTermDictionaryInfos) =
  60. Zend_Search_Lucene_Index_DictionaryLoader::load($tiiFileData);
  61. $this->assertTrue($termDictionary == $loadedTermDictionary);
  62. $this->assertTrue($termDictionaryInfos == $loadedTermDictionaryInfos);
  63. }
  64. }