Structures_BibTex
[ class tree: Structures_BibTex ] [ index: Structures_BibTex ] [ all elements ]

Source for file BibTexTest.php

Documentation is available at BibTexTest.php

  1. <?php
  2.   // Call Structures_BibTexTest::main() if this source file is executed directly.
  3. if (!defined("PHPUnit2_MAIN_METHOD")) {
  4.     define("PHPUnit2_MAIN_METHOD""BibTexTest::main");
  5.  }
  6.  
  7. require_once "PHPUnit2/Framework/TestCase.php";
  8. require_once "PHPUnit2/Framework/TestSuite.php";
  9.  
  10. // You may remove the following line when all tests have been implemented.
  11. require_once "PHPUnit2/Framework/IncompleteTestError.php";
  12.  
  13. require_once "./BibTex.php";
  14. require_once "PEAR.php";
  15.  
  16. /**
  17.  * Test class for Structures_BibTex.
  18.  * Generated by PHPUnit2_Util_Skeleton on 2006-06-06 at 22:13:11.
  19.  */
  20. class BibTexTest extends PHPUnit2_Framework_TestCase
  21. {
  22.     var $obj;
  23.  
  24.     /**
  25.      * Runs the test methods of this class.
  26.      *
  27.      * @access public
  28.      * @static
  29.      */
  30.     public static function main({
  31.         require_once "PHPUnit2/TextUI/TestRunner.php";
  32.         $suite  = new PHPUnit2_Framework_TestSuite("Structures_BibTexTest");
  33.         $result = PHPUnit2_TextUI_TestRunner::run($suite);
  34.     }
  35.  
  36.     /**
  37.      * Sets up the fixture, for example, open a network connection.
  38.      * This method is called before a test is executed.
  39.      *
  40.      * @access protected
  41.      */
  42.     protected function setUp({
  43.         $this->obj = new Structures_BibTex();
  44.     }
  45.  
  46.     /**
  47.      * Tears down the fixture, for example, close a network connection.
  48.      * This method is called after a test is executed.
  49.      *
  50.      * @access protected
  51.      */
  52.     protected function tearDown({
  53.         unset($this->obj);
  54.     }
  55.  
  56.     public function testLoadFileFileExists({
  57.         $ret $this->obj->loadFile("BibTexTest.php");
  58.         $this->content ''//Erasing the loaded content again because it is senseless
  59.         $this->assertTrue($ret);
  60.     }
  61.  
  62.     public function testLoadFileFileDoesNotExists({
  63.         $ret $this->obj->loadFile((string)time());
  64.         $this->assertTrue(PEAR::isError($ret));
  65.     }
  66.  
  67.     /**
  68.      * @todo Implement test_parseEntry().
  69.      */
  70.     public function test_parseEntry({
  71.         //Remember here that there is no closing brace!
  72.         $test "@foo{bar,john=doe";
  73.         $shouldbe = array();
  74.         $shouldbe['john''doe';
  75.         $shouldbe['cite''bar';
  76.         $shouldbe['type''foo';
  77.         $this->assertEquals($shouldbe$this->obj->_parseEntry($test));
  78.     }
  79.  
  80.     public function test_checkEqualSignTrue({
  81.         $test "={=}";
  82.         $this->assertTrue($this->obj->_checkEqualSign($test,0));
  83.     }
  84.     public function test_checkEqualSignFalse({
  85.         $test "={=}";
  86.         $this->assertFalse($this->obj->_checkEqualSign($test,2));
  87.     }
  88.  
  89.     public function testClearWarnings({
  90.         $this->obj->clearWarnings();
  91.         $this->obj->_generateWarning('type''entry');
  92.         $this->obj->clearWarnings();
  93.         $this->assertFalse($this->obj->hasWarning());
  94.     }
  95.  
  96.     /*
  97.      * the next tests check for the generation of the following Warnings:
  98.      * - WARNING_AT_IN_BRACES
  99.      * - WARNING_ESCAPED_DOUBLE_QUOTE_INSIDE_DOUBLE_QUOTES
  100.      * - WARNING_UNBALANCED_AMOUNT_OF_BRACES
  101.      */
  102.     public function test_validateValueWarningAtInBraces({
  103.         $this->obj->clearWarnings();
  104.         $test '{john@doe}';
  105.         $this->obj->_validateValue($test'');
  106.         $this->assertEquals('WARNING_AT_IN_BRACES'$this->obj->warnings[0]['warning']);
  107.     }
  108.     public function test_validateValueWarningEscapedDoubleQuoteInsideDoubleQuotes({
  109.         $this->obj->clearWarnings();
  110.         $test '"john\"doe"';
  111.         $this->obj->_validateValue($test'');
  112.         $this->assertEquals('WARNING_ESCAPED_DOUBLE_QUOTE_INSIDE_DOUBLE_QUOTES'$this->obj->warnings[0]['warning']);
  113.     }
  114.     public function test_validateValueWarningUnbalancedAmountOfBracesOpen({
  115.         $this->obj->clearWarnings();
  116.         $test '{john{doe}';
  117.         $this->obj->_validateValue($test'');
  118.         $this->assertEquals('WARNING_UNBALANCED_AMOUNT_OF_BRACES'$this->obj->warnings[0]['warning']);
  119.     }
  120.     public function test_validateValueWarningUnbalancedAmountOfBracesClosed({
  121.         $this->obj->clearWarnings();
  122.         $test '{john}doe}';
  123.         $this->obj->_validateValue($test'');
  124.         $this->assertEquals('WARNING_UNBALANCED_AMOUNT_OF_BRACES'$this->obj->warnings[0]['warning']);
  125.     }
  126.  
  127.     public function test_generateWarning({
  128.         $this->obj->clearWarnings();
  129.         $this->obj->_generateWarning('type''entry');
  130.         $ret $this->obj->hasWarning();
  131.         $this->obj->clearWarnings();
  132.         $this->assertTrue($ret);
  133.     }
  134.  
  135.     public function testHasWarning()
  136.     {
  137.         $this->obj->clearWarnings();
  138.         $this->assertFalse($this->obj->hasWarning());
  139.     }
  140.  
  141.     public function testAmount()
  142.     {
  143.         $teststring "@Article {art1,author = {John Doe and Jane Doe}}@Article { art2,author = {John Doe and Jane Doe}}";
  144.         $this->obj->content = $teststring;
  145.         $this->obj->parse();
  146.         $this->assertEquals(2$this->obj->amount());
  147.     }
  148.  
  149.     public function testGetStatistic()
  150.     {
  151.         $teststring "@Article {art1,author = {John Doe and Jane Doe}}@Article { art2,author = {John Doe and Jane Doe}}";
  152.         $this->obj->content = $teststring;
  153.         $this->obj->parse();
  154.         $shouldbe            = array();
  155.         $shouldbe['article'= 2;
  156.         $this->assertEquals($shouldbe$this->obj->getStatistic());
  157.     }
  158.  
  159.     function testSingleParse()
  160.     {
  161.         $teststring="@Article { ppm_jon:1991,
  162. author = {John Doe and Jane Doe}
  163. }";
  164.         $this->obj->content=$teststring;
  165.         $this->obj->parse();
  166.         $this->assertEquals(1,$this->obj->amount());
  167.     }
  168.  
  169.     function testMultiParse()
  170.     {
  171.         $teststring "@Article { art1,
  172. author = {John Doe and Jane Doe}
  173. }
  174. @Article { art2,
  175. author = {John Doe and Jane Doe}
  176. }";
  177.         $this->obj->content = $teststring;
  178.         $this->obj->parse();
  179.         $this->assertEquals(2,$this->obj->amount());
  180.     }
  181.  
  182.     function testParse()
  183.     {
  184.         $teststring "@Article { art1,
  185. title = {Titel1},
  186. author = {John Doe and Jane Doe}
  187. }";
  188.         $shouldbe = array();
  189.         $shouldbe[0]['type''article';
  190.         $shouldbe[0]['cite''art1';
  191.         $shouldbe[0]['title''Titel1';
  192.         $shouldbe[0]['author'][0]['first''John';
  193.         $shouldbe[0]['author'][0]['von']   '';
  194.         $shouldbe[0]['author'][0]['last']  'Doe';
  195.         $shouldbe[0]['author'][0]['jr']    '';
  196.         $shouldbe[0]['author'][1]['first''Jane';
  197.         $shouldbe[0]['author'][1]['von']   '';
  198.         $shouldbe[0]['author'][1]['last']  'Doe';
  199.         $shouldbe[0]['author'][1]['jr']    '';
  200.         $this->obj->content = $teststring;
  201.         $this->obj->parse();
  202.         $this->assertEquals($shouldbe,$this->obj->data);
  203.     }
  204.  
  205.     function testBibTex()
  206.     {
  207.         $testarray = array();
  208.         $testarray[0]['type''Article';
  209.         $testarray[0]['cite''art1';
  210.         $testarray[0]['title''Titel1';
  211.         $testarray[0]['author'][0]['first''John';
  212.         $testarray[0]['author'][0]['von']   '';
  213.         $testarray[0]['author'][0]['last']  'Doe';
  214.         $testarray[0]['author'][0]['jr']    '';
  215.         $testarray[0]['author'][1]['first''Jane';
  216.         $testarray[0]['author'][1]['von']   '';
  217.         $testarray[0]['author'][1]['last']  'Doe';
  218.         $testarray[0]['author'][1]['jr']    '';
  219.         $shouldbe "@article { art1,\n\ttitle = {Titel1},\n\tauthor = {Doe, , John and Doe, , Jane}\n}";
  220.         $this->obj->data = $testarray;
  221.         $this->assertEquals(trim($shouldbe),trim($this->obj->bibTex()));
  222.     }
  223.  
  224.     function testAddEntry()
  225.     {
  226.         $addarray = array();
  227.         $addarray['type''Article';
  228.         $addarray['cite''art2';
  229.         $addarray['title''Titel2';
  230.         $addarray['author'][0'John Doe';
  231.         $addarray['author'][1'Jane Doe';
  232.         $teststring "@Article { art1,
  233. title = {Titel1},
  234. author = {John Doe and Jane Doe}
  235. }";
  236.         $this->obj->content = $teststring;
  237.         $this->obj->parse();
  238.         $this->obj->addEntry($addarray);
  239.         $this->assertEquals(2,$this->obj->amount());
  240.     }
  241.  
  242.     function testEntryOverMoreLines()
  243.     {
  244.         //Entry found at http://en.wikipedia.org/wiki/BibTeX
  245.         $teststring "@Book{abramowitz+stegun,
  246.   author =       \"Milton Abramowitz and Irene A. Stegun\",
  247.   title =        \"Handbook of Mathematical Functions with
  248.                   Formulas, Graphs, and Mathematical Tables\",
  249.   publisher =    \"Dover\",
  250.   year =         1964,
  251.   address =      \"New York\",
  252.   edition =      \"ninth Dover printing, tenth GPO printing\",
  253.   isbn =         \"0-486-61272-4\"
  254. }";
  255.         $shouldbe = array();
  256.         $shouldbe[0]['type']  'book';
  257.         $shouldbe[0]['cite']  'abramowitz+stegun';
  258.         $shouldbe[0]['title'"Handbook of Mathematical Functions with
  259.                   Formulas, Graphs, and Mathematical Tables";
  260.         $shouldbe[0]['author'][0]['first''Milton';
  261.         $shouldbe[0]['author'][0]['von']   '';
  262.         $shouldbe[0]['author'][0]['last']  'Abramowitz';
  263.         $shouldbe[0]['author'][0]['jr']    '';
  264.         $shouldbe[0]['author'][1]['first''Irene A.';
  265.         $shouldbe[0]['author'][1]['von']   '';
  266.         $shouldbe[0]['author'][1]['last']  'Stegun';
  267.         $shouldbe[0]['author'][1]['jr']    '';
  268.         $shouldbe[0]['publisher''Dover';
  269.         $shouldbe[0]['year']      '1964';
  270.         $shouldbe[0]['address']   'New York';
  271.         $shouldbe[0]['edition']   'ninth Dover printing, tenth GPO printing';
  272.         $shouldbe[0]['isbn']      '0-486-61272-4';
  273.         $this->obj->content = $teststring;
  274.         $this->obj->parse();
  275.         $this->assertEquals($shouldbe$this->obj->data);
  276.     }
  277.  
  278.     function testParsingComment()
  279.     {
  280.         $teststring "@Article { art1,
  281. title = {Titel1},
  282. author = {John Doe and Jane Doe}
  283. }
  284. Here is a comment
  285. @Article { art2,
  286. title = {Titel2},
  287. author = {John Doe and Jane Doe}
  288. }";
  289.         $shouldbe = array();
  290.         $shouldbe[0]['type''article';
  291.         $shouldbe[0]['cite''art1';
  292.         $shouldbe[0]['title''Titel1';
  293.         $shouldbe[0]['author'][0]['first''John';
  294.         $shouldbe[0]['author'][0]['von']   '';
  295.         $shouldbe[0]['author'][0]['last']  'Doe';
  296.         $shouldbe[0]['author'][0]['jr']    '';
  297.         $shouldbe[0]['author'][1]['first''Jane';
  298.         $shouldbe[0]['author'][1]['von']   '';
  299.         $shouldbe[0]['author'][1]['last']  'Doe';
  300.         $shouldbe[0]['author'][1]['jr']    '';
  301.         $shouldbe[1]['type''article';
  302.         $shouldbe[1]['cite''art2';
  303.         $shouldbe[1]['title''Titel2';
  304.         $shouldbe[1]['author'][0]['first''John';
  305.         $shouldbe[1]['author'][0]['von']   '';
  306.         $shouldbe[1]['author'][0]['last']  'Doe';
  307.         $shouldbe[1]['author'][0]['jr']    '';
  308.         $shouldbe[1]['author'][1]['first''Jane';
  309.         $shouldbe[1]['author'][1]['von']   '';
  310.         $shouldbe[1]['author'][1]['last']  'Doe';
  311.         $shouldbe[1]['author'][1]['jr']    '';
  312.         $this->obj->content = $teststring;
  313.         $this->obj->parse();
  314.         $this->assertTrue($this->obj->data == $shouldbe);
  315.     }
  316.     /*
  317.      function testWrongBraces1() {
  318.      $teststring = "@Article { art1,
  319.      title = {Tit}el1},
  320.      author = {John Doe and Jane Doe}
  321.      }";
  322.      $this->obj->content = $teststring;
  323.      $this->assertTrue(PEAR::isError($this->obj->parse()));
  324.      }
  325.  
  326.      function testWrongBraces2() {
  327.      $teststring = "@Article { art1,
  328.      title = {Titel1},
  329.      author = {John Doe and }Jane }Doe}
  330.      }";
  331.      $this->obj->content = $teststring;
  332.      $this->assertTrue(PEAR::isError($this->obj->parse()));
  333.      }
  334.     */
  335.     function testWrongBraces3({
  336.         $teststring "@Article { art1,
  337. title = {Titel1},
  338. author = {John Doe and {Jane Doe}
  339. }";
  340.         $this->obj->content = $teststring;
  341.         $this->assertTrue(PEAR::isError($this->obj->parse()));
  342.     }
  343.  
  344.     function testWarningAtInBraces({
  345.         $teststring "@Article { art1,
  346. title = {Titel1},
  347. author = {John Doe and @Jane Doe}
  348. }";
  349.         $this->obj->content = $teststring;
  350.         $this->obj->parse();
  351.         $this->assertTrue('WARNING_AT_IN_BRACES'==$this->obj->warnings[0]['warning']);
  352.     }
  353.     function testWarningEscapedDoubleQuote({
  354.         $teststring "@Article { art1,
  355. title = {Titel1},
  356. author = \"John Doe and \\\"Jane Doe\"
  357. }";
  358.         $this->obj->content = $teststring;
  359.         $this->obj->parse();
  360.         $this->assertTrue('WARNING_ESCAPED_DOUBLE_QUOTE_INSIDE_DOUBLE_QUOTES'==$this->obj->warnings[0]['warning']);
  361.     }
  362.     /*
  363.      function testWarningAmountBraces() {
  364.      $teststring = "@Article { art1,
  365.      title = {Tit{el1},
  366.      author = {John Doe and }Jane Doe}
  367.      }";
  368.      $this->obj->content = $teststring;
  369.      $this->obj->parse();
  370.      $this->assertTrue('WARNING_UNBALANCED_AMOUNT_OF_BRACES'==$this->obj->warnings[0]['warning']);
  371.      }
  372.     */
  373.     function testWarningMultipleEntries({
  374.         $teststring "@Article { art1,
  375. title = {Titel1},
  376. author = {John Doe and Jane Doe}
  377. }
  378. @Article { art2,
  379. title = {Titel1},
  380. author = {John Doe and Jane Doe}
  381. }
  382. @Article { art1,
  383. title = {Titel1},
  384. author = {John Doe and Jane Doe}
  385. }
  386. @Article { art2,
  387. title = {Titel1},
  388. author = {John Doe and Jane Doe}
  389. }
  390. @Article { art3,
  391. title = {Titel1},
  392. author = {John Doe and Jane Doe}
  393. }";
  394.         $this->obj->content = $teststring;
  395.         $this->obj->parse();
  396.         $this->assertTrue('WARNING_MULTIPLE_ENTRIES'==$this->obj->warnings[0]['warning']);
  397.     }
  398.  
  399.     /* This testing suite is needed to get the Authors correct.
  400.      for more information: http://artis.imag.fr/%7EXavier.Decoret/resources/xdkbibtex/bibtex_summary.html
  401.      The names of the functions are build as follows:
  402.      "test": Of course it is a unit test
  403.      "Author": Function testing the authors
  404.      "First": There are three different ways writing an author this is the first one
  405.      "Simple": Description of the tes
  406.     */
  407.     function testAuthorFirstSimple({
  408.         $test     "AA BB";
  409.         $shouldbe = array();
  410.         $shouldbe[0]['first''AA';
  411.         $shouldbe[0]['von']   '';
  412.         $shouldbe[0]['last']  'BB';
  413.         $shouldbe[0]['jr']    '';
  414.         $this->assertEquals($shouldbe$this->obj->_extractAuthors($test));
  415.     }
  416.     
  417.     function testAuthorFirstLastCannotBeEmpty({
  418.         $test     "AA";
  419.         $shouldbe = array();
  420.         $shouldbe[0]['first''';
  421.         $shouldbe[0]['von']   '';
  422.         $shouldbe[0]['last']  'AA';
  423.         $shouldbe[0]['jr']    '';
  424.         $this->assertEquals($shouldbe$this->obj->_extractAuthors($test));
  425.     }
  426.     
  427.     function testAuthorFirstSimpleLowerCase({
  428.         $test     "AA bb";
  429.         $shouldbe = array();
  430.         $shouldbe[0]['first''AA';
  431.         $shouldbe[0]['von']   '';
  432.         $shouldbe[0]['last']  'bb';
  433.         $shouldbe[0]['jr']    '';
  434.         $this->assertEquals($shouldbe$this->obj->_extractAuthors($test));
  435.     }
  436.     
  437.     function testAuthorFirstLastCannotBeEmptyLowerCase({
  438.         $test     "aa";
  439.         $shouldbe = array();
  440.         $shouldbe[0]['first''';
  441.         $shouldbe[0]['von']   '';
  442.         $shouldbe[0]['last']  'aa';
  443.         $shouldbe[0]['jr']    '';
  444.         $this->assertEquals($shouldbe$this->obj->_extractAuthors($test));
  445.     }
  446.     
  447.     function testAuthorFirstSimpleVon({
  448.         $test     "AA bb CC";
  449.         $shouldbe = array();
  450.         $shouldbe[0]['first''AA';
  451.         $shouldbe[0]['von']   'bb';
  452.         $shouldbe[0]['last']  'CC';
  453.         $shouldbe[0]['jr']    '';
  454.         $this->assertEquals($shouldbe$this->obj->_extractAuthors($test));
  455.     }
  456.     function testAuthorFirstSimpleVonInnerUppercase({
  457.         $test     "AA bb CC dd EE";
  458.         $shouldbe = array();
  459.         $shouldbe[0]['first''AA';
  460.         $shouldbe[0]['von']   'bb CC dd';
  461.         $shouldbe[0]['last']  'EE';
  462.         $shouldbe[0]['jr']    '';
  463.         $this->assertEquals($shouldbe$this->obj->_extractAuthors($test));
  464.     }
  465.     function testAuthorFirstDigitsArecaselessUppercase({
  466.         $test     "AA 1B cc dd";
  467.         $shouldbe = array();
  468.         $shouldbe[0]['first''AA 1B';
  469.         $shouldbe[0]['von']   'cc';
  470.         $shouldbe[0]['last']  'dd';
  471.         $shouldbe[0]['jr']    '';
  472.         $this->assertEquals($shouldbe$this->obj->_extractAuthors($test));
  473.     }
  474.     function testAuthorFirstDigitsArecaselessLowercase({
  475.         $test     "AA 1b cc dd";
  476.         $shouldbe = array();
  477.         $shouldbe[0]['first''AA';
  478.         $shouldbe[0]['von']   '1b cc';
  479.         $shouldbe[0]['last']  'dd';
  480.         $shouldbe[0]['jr']    '';
  481.         $this->assertEquals($shouldbe$this->obj->_extractAuthors($test));
  482.     }
  483.     function testAuthorFirstPseudoLettersAreCaselessLowerInsideUpperOutside({
  484.         $test     "AA {b}B cc dd";
  485.         $shouldbe = array();
  486.         $shouldbe[0]['first''AA {b}B';
  487.         $shouldbe[0]['von']   'cc';
  488.         $shouldbe[0]['last']  'dd';
  489.         $shouldbe[0]['jr']    '';
  490.         $this->assertEquals($shouldbe$this->obj->_extractAuthors($test));
  491.     }
  492.     function testAuthorFirstPseudoLettersAreCaselessLowerInsideLowerOutside({
  493.         $test     "AA {b}b cc dd";
  494.         $shouldbe = array();
  495.         $shouldbe[0]['first''AA';
  496.         $shouldbe[0]['von']   '{b}b cc';
  497.         $shouldbe[0]['last']  'dd';
  498.         $shouldbe[0]['jr']    '';
  499.         $this->assertEquals($shouldbe$this->obj->_extractAuthors($test));
  500.     }
  501.     function testAuthorFirstPseudoLettersAreCaselessUpperInsideUpperOutside({
  502.         $test     "AA {B}B cc dd";
  503.         $shouldbe = array();
  504.         $shouldbe[0]['first''AA {B}B';
  505.         $shouldbe[0]['von']   'cc';
  506.         $shouldbe[0]['last']  'dd';
  507.         $shouldbe[0]['jr']    '';
  508.         $this->assertEquals($shouldbe$this->obj->_extractAuthors($test));
  509.     }
  510.     function testAuthorFirstPseudoLettersAreCaselessUpperInsideLowerOutside({
  511.         $test     "AA {B}b cc dd";
  512.         $shouldbe = array();
  513.         $shouldbe[0]['first''AA';
  514.         $shouldbe[0]['von']   '{B}b cc';
  515.         $shouldbe[0]['last']  'dd';
  516.         $shouldbe[0]['jr']    '';
  517.         $this->assertEquals($shouldbe$this->obj->_extractAuthors($test));
  518.     }
  519.     function testAuthorFirstNonLettersAreCaselessUpperCase({
  520.         $test     "AA \BB{b} cc dd";
  521.         $shouldbe = array();
  522.         $shouldbe[0]['first''AA \BB{b}';
  523.         $shouldbe[0]['von']   'cc';
  524.         $shouldbe[0]['last']  'dd';
  525.         $shouldbe[0]['jr']    '';
  526.         $this->assertEquals($shouldbe$this->obj->_extractAuthors($test));
  527.     }
  528.     function testAuthorFirstNonLettersAreCaselessLowerCase({
  529.         $test     "AA \bb{b} cc dd";
  530.         $shouldbe = array();
  531.         $shouldbe[0]['first''AA';
  532.         $shouldbe[0]['von']   '\bb{b} cc';
  533.         $shouldbe[0]['last']  'dd';
  534.         $shouldbe[0]['jr']    '';
  535.         $this->assertEquals($shouldbe$this->obj->_extractAuthors($test));
  536.     }
  537.     function testAuthorFirstGroupingCaselessOne({
  538.         $test     "AA {bb} cc DD";
  539.         $shouldbe = array();
  540.         $shouldbe[0]['first''AA {bb}';
  541.         $shouldbe[0]['von']   'cc';
  542.         $shouldbe[0]['last']  'DD';
  543.         $shouldbe[0]['jr']    '';
  544.         $this->assertEquals($shouldbe$this->obj->_extractAuthors($test));
  545.     }
  546.     function testAuthorFirstGroupingCaselessTwo({
  547.         $test     "AA bb {cc} DD";
  548.         $shouldbe = array();
  549.         $shouldbe[0]['first''AA';
  550.         $shouldbe[0]['von']   'bb';
  551.         $shouldbe[0]['last']  '{cc} DD';
  552.         $shouldbe[0]['jr']    '';
  553.         $this->assertEquals($shouldbe$this->obj->_extractAuthors($test));
  554.     }
  555.     function testAuthorFirstGroupingCaselessThree({
  556.         $test     "AA {bb} CC";
  557.         $shouldbe = array();
  558.         $shouldbe[0]['first''AA {bb}';
  559.         $shouldbe[0]['von']   '';
  560.         $shouldbe[0]['last']  'CC';
  561.         $shouldbe[0]['jr']    '';
  562.         $this->assertEquals($shouldbe$this->obj->_extractAuthors($test));
  563.     }
  564.     function testAuthorSecondAndThirdSimpleCaseFirstUppercase({
  565.         $test     "bb CC, AA";
  566.         $shouldbe = array();
  567.         $shouldbe[0]['first''AA';
  568.         $shouldbe[0]['von']   'bb';
  569.         $shouldbe[0]['last']  'CC';
  570.         $shouldbe[0]['jr']    '';
  571.         $this->assertEquals($shouldbe$this->obj->_extractAuthors($test));
  572.     }
  573.     function testAuthorSecondAndThirdSimpleCaseFirstLowercase({
  574.         $test     "bb CC, aa";
  575.         $shouldbe = array();
  576.         $shouldbe[0]['first''aa';
  577.         $shouldbe[0]['von']   'bb';
  578.         $shouldbe[0]['last']  'CC';
  579.         $shouldbe[0]['jr']    '';
  580.         $this->assertEquals($shouldbe$this->obj->_extractAuthors($test));
  581.     }
  582.     function testAuthorSecondAndThirdSimpleVon({
  583.         $test     "bb CC dd EE, AA";
  584.         $shouldbe = array();
  585.         $shouldbe[0]['first''AA';
  586.         $shouldbe[0]['von']   'bb CC dd';
  587.         $shouldbe[0]['last']  'EE';
  588.         $shouldbe[0]['jr']    '';
  589.         $this->assertEquals($shouldbe$this->obj->_extractAuthors($test));
  590.     }
  591.     function testAuthorSecondAndThirdLastPartCoannotBeEmpty({
  592.         $test     "bb, AA";
  593.         $shouldbe = array();
  594.         $shouldbe[0]['first''AA';
  595.         $shouldbe[0]['von']   '';
  596.         $shouldbe[0]['last']  'bb';
  597.         $shouldbe[0]['jr']    '';
  598.         $this->assertEquals($shouldbe$this->obj->_extractAuthors($test));
  599.     }
  600.     function testAuthorSecondAndThirdFirstCanBeEmptyAfterComma({
  601.         $test     "BB,";
  602.         $shouldbe = array();
  603.         $shouldbe[0]['first''';
  604.         $shouldbe[0]['von']   '';
  605.         $shouldbe[0]['last']  'BB';
  606.         $shouldbe[0]['jr']    '';
  607.         $this->assertEquals($shouldbe$this->obj->_extractAuthors($test));
  608.     }
  609.     function testAuthorSecondAndThirdSimpleJrUppercase({
  610.         $test     "bb CC,XX, AA";
  611.         $shouldbe = array();
  612.         $shouldbe[0]['first''AA';
  613.         $shouldbe[0]['von']   'bb';
  614.         $shouldbe[0]['last']  'CC';
  615.         $shouldbe[0]['jr']    'XX';
  616.         $this->assertEquals($shouldbe$this->obj->_extractAuthors($test));
  617.     }
  618.     function testAuthorSecondAndThirdSimpleJrLowercase({
  619.         $test     "bb CC,xx, AA";
  620.         $shouldbe = array();
  621.         $shouldbe[0]['first''AA';
  622.         $shouldbe[0]['von']   'bb';
  623.         $shouldbe[0]['last']  'CC';
  624.         $shouldbe[0]['jr']    'xx';
  625.         $this->assertEquals($shouldbe$this->obj->_extractAuthors($test));
  626.     }
  627.     function testAuthorSecondAndThirdJrCanBeEmptyBetweenCommas({
  628.         $test     "BB,, AA";
  629.         $shouldbe = array();
  630.         $shouldbe[0]['first''AA';
  631.         $shouldbe[0]['von']   '';
  632.         $shouldbe[0]['last']  'BB';
  633.         $shouldbe[0]['jr']    '';
  634.         $this->assertEquals($shouldbe$this->obj->_extractAuthors($test));
  635.     }
  636.     /*Testing the case determination needed for the authors*/
  637.     function testCaseUpperSimple({
  638.         $test 'AA';
  639.         $this->assertEquals(1$this->obj->_determineCase($test));
  640.     }
  641.     function testCaseLowerSimple({
  642.         $test 'aa';
  643.         $this->assertEquals(0$this->obj->_determineCase($test));
  644.     }
  645.     function testCaseCaselessSimple({
  646.         $test '{a}';
  647.         $this->assertEquals(-1$this->obj->_determineCase($test));
  648.     }
  649.     function testCaseUpperComplexBrace({
  650.         $test '{A}A';
  651.         $this->assertEquals(1$this->obj->_determineCase($test));
  652.     }
  653.     function testCaseLowerComplexBrace({
  654.         $test '{a}a';
  655.         $this->assertEquals(0$this->obj->_determineCase($test));
  656.     }
  657.     function testCaseUpperComplexNumber({
  658.         $test '1A';
  659.         $this->assertEquals(1$this->obj->_determineCase($test));
  660.     }
  661.     function testCaseLowerComplexNumber({
  662.         $test '1a';
  663.         $this->assertEquals(0$this->obj->_determineCase($test));
  664.     }
  665.     function testCaseUpperComplexWhitespace({
  666.         $test ' A';
  667.         $this->assertEquals(1$this->obj->_determineCase($test));
  668.     }
  669.     function testCaseLowerComplexWhitespace({
  670.         $test ' a';
  671.         $this->assertEquals(0$this->obj->_determineCase($test));
  672.     }
  673.     function testCaseErrorEmptyString({
  674.         $test '';
  675.         $this->assertTrue(PEAR::isError($this->obj->_determineCase($test)));
  676.     }
  677.     function testCaseErrorNonString({
  678.         $test = 2;
  679.         $this->assertTrue(PEAR::isError($this->obj->_determineCase($test)));
  680.     }
  681. }
  682.  
  683. // Call Structures_BibTexTest::main() if this source file is executed directly.
  684. if (PHPUnit2_MAIN_METHOD == "BibTexTest::main"{
  685.     BibTexTest::main();
  686.  }
  687. ?>

Documentation generated on Mon, 11 Mar 2019 14:42:38 -0400 by phpDocumentor 1.4.4. PEAR Logo Copyright © PHP Group 2004.