ILIAS  Release_5_0_x_branch Revision 61816
 All Data Structures Namespaces Files Functions Variables Groups Pages
BibTexTest Class Reference

Test class for Structures_BibTex. More...

+ Inheritance diagram for BibTexTest:
+ Collaboration diagram for BibTexTest:

Public Member Functions

 testLoadFileFileExists ()
 testLoadFileFileDoesNotExists ()
 test_parseEntry ()
 test_checkEqualSignTrue ()
 test_checkEqualSignFalse ()
 testClearWarnings ()
 test_validateValueWarningAtInBraces ()
 test_validateValueWarningEscapedDoubleQuoteInsideDoubleQuotes ()
 test_validateValueWarningUnbalancedAmountOfBracesOpen ()
 test_validateValueWarningUnbalancedAmountOfBracesClosed ()
 test_generateWarning ()
 testHasWarning ()
 testAmount ()
 testGetStatistic ()
 testSingleParse ()
 testMultiParse ()
 testParse ()
 testBibTex ()
 testAddEntry ()
 testEntryOverMoreLines ()
 testParsingComment ()
 testWrongBraces3 ()
 testWarningAtInBraces ()
 testWarningEscapedDoubleQuote ()
 testWarningMultipleEntries ()
 testAuthorFirstSimple ()
 testAuthorFirstLastCannotBeEmpty ()
 testAuthorFirstSimpleLowerCase ()
 testAuthorFirstLastCannotBeEmptyLowerCase ()
 testAuthorFirstSimpleVon ()
 testAuthorFirstSimpleVonInnerUppercase ()
 testAuthorFirstDigitsArecaselessUppercase ()
 testAuthorFirstDigitsArecaselessLowercase ()
 testAuthorFirstPseudoLettersAreCaselessLowerInsideUpperOutside ()
 testAuthorFirstPseudoLettersAreCaselessLowerInsideLowerOutside ()
 testAuthorFirstPseudoLettersAreCaselessUpperInsideUpperOutside ()
 testAuthorFirstPseudoLettersAreCaselessUpperInsideLowerOutside ()
 testAuthorFirstNonLettersAreCaselessUpperCase ()
 testAuthorFirstNonLettersAreCaselessLowerCase ()
 testAuthorFirstGroupingCaselessOne ()
 testAuthorFirstGroupingCaselessTwo ()
 testAuthorFirstGroupingCaselessThree ()
 testAuthorSecondAndThirdSimpleCaseFirstUppercase ()
 testAuthorSecondAndThirdSimpleCaseFirstLowercase ()
 testAuthorSecondAndThirdSimpleVon ()
 testAuthorSecondAndThirdLastPartCoannotBeEmpty ()
 testAuthorSecondAndThirdFirstCanBeEmptyAfterComma ()
 testAuthorSecondAndThirdSimpleJrUppercase ()
 testAuthorSecondAndThirdSimpleJrLowercase ()
 testAuthorSecondAndThirdJrCanBeEmptyBetweenCommas ()
 testCaseUpperSimple ()
 testCaseLowerSimple ()
 testCaseCaselessSimple ()
 testCaseUpperComplexBrace ()
 testCaseLowerComplexBrace ()
 testCaseUpperComplexNumber ()
 testCaseLowerComplexNumber ()
 testCaseUpperComplexWhitespace ()
 testCaseLowerComplexWhitespace ()
 testCaseErrorEmptyString ()
 testCaseErrorNonString ()
 testAllowedTypeTrue ()
 testAllowedTypeFalse ()
 testAllowedTypeWarning ()
 testMissingLastBraceParsing ()
 testMissingLastBraceParsing2 ()
 testMissingLastBraceWarning ()
 testNewlineInAuthorField ()
 testNotRemoveCurlyBraces ()
 testRemoveCurlyBraces ()
 testRemoveCurlyBraces2 ()
 testRemoveCurlyBracesWithoutBraces ()
 testRtfExport ()
 testHtmlExport ()
 testFormatAuthor ()
 testExtractAuthorWhitespace ()
 testExtractAuthorTilde ()
 testNotExtractAuthors ()
 testExtractAuthors ()
 testNotExtractAuthorsBibtexExport ()
 testNotExtractAuthorsRtfExport ()
 testNotExtractAuthorsHtmlExport ()

Static Public Member Functions

static main ()
 Runs the test methods of this class.

Data Fields

 $obj

Protected Member Functions

 setUp ()
 Sets up the fixture, for example, open a network connection.
 tearDown ()
 Tears down the fixture, for example, close a network connection.

Detailed Description

Test class for Structures_BibTex.

Generated by PHPUnit_Util_Skeleton on 2006-06-06 at 22:13:11.

Definition at line 20 of file BibTexTest.php.

Member Function Documentation

static BibTexTest::main ( )
static

Runs the test methods of this class.

public

Definition at line 31 of file BibTexTest.php.

References $result, and $suite.

{
require_once "PHPUnit/TextUI/TestRunner.php";
$suite = new PHPUnit_Framework_TestSuite("Structures_BibTexTest");
$result = PHPUnit_TextUI_TestRunner::run($suite);
}
BibTexTest::setUp ( )
protected

Sets up the fixture, for example, open a network connection.

This method is called before a test is executed.

protected

Definition at line 44 of file BibTexTest.php.

{
$this->obj = new Structures_BibTex();
}
BibTexTest::tearDown ( )
protected

Tears down the fixture, for example, close a network connection.

This method is called after a test is executed.

protected

Definition at line 55 of file BibTexTest.php.

{
unset($this->obj);
}
BibTexTest::test_checkEqualSignFalse ( )

Definition at line 93 of file BibTexTest.php.

References $test.

{
$test = "={=}";
$this->assertFalse($this->obj->_checkEqualSign($test, 2));
}
BibTexTest::test_checkEqualSignTrue ( )

Definition at line 87 of file BibTexTest.php.

References $test.

{
$test = "={=}";
$this->assertTrue($this->obj->_checkEqualSign($test, 0));
}
BibTexTest::test_generateWarning ( )

Definition at line 145 of file BibTexTest.php.

References $ret.

{
$this->obj->clearWarnings();
$this->obj->_generateWarning('type', 'entry');
$ret = $this->obj->hasWarning();
$this->obj->clearWarnings();
$this->assertTrue($ret);
}
BibTexTest::test_parseEntry ( )
Todo:
Implement test_parseEntry().

Definition at line 76 of file BibTexTest.php.

References $test.

{
//Remember here that there is no closing brace!
$test = "@foo{bar,john=doe";
$shouldbe = array();
$shouldbe['john'] = 'doe';
$shouldbe['cite'] = 'bar';
$shouldbe['entryType'] = 'foo';
$this->assertEquals($shouldbe, $this->obj->_parseEntry($test));
}
BibTexTest::test_validateValueWarningAtInBraces ( )

Definition at line 113 of file BibTexTest.php.

References $test.

{
$this->obj->clearWarnings();
$test = '{john@doe}';
$this->obj->_validateValue($test, '');
$this->assertEquals('WARNING_AT_IN_BRACES', $this->obj->warnings[0]['warning']);
}
BibTexTest::test_validateValueWarningEscapedDoubleQuoteInsideDoubleQuotes ( )

Definition at line 121 of file BibTexTest.php.

References $test.

{
$this->obj->clearWarnings();
$test = '"john\"doe"';
$this->obj->_validateValue($test, '');
$this->assertEquals('WARNING_ESCAPED_DOUBLE_QUOTE_INSIDE_DOUBLE_QUOTES', $this->obj->warnings[0]['warning']);
}
BibTexTest::test_validateValueWarningUnbalancedAmountOfBracesClosed ( )

Definition at line 137 of file BibTexTest.php.

References $test.

{
$this->obj->clearWarnings();
$test = '{john}doe}';
$this->obj->_validateValue($test, '');
$this->assertEquals('WARNING_UNBALANCED_AMOUNT_OF_BRACES', $this->obj->warnings[0]['warning']);
}
BibTexTest::test_validateValueWarningUnbalancedAmountOfBracesOpen ( )

Definition at line 129 of file BibTexTest.php.

References $test.

{
$this->obj->clearWarnings();
$test = '{john{doe}';
$this->obj->_validateValue($test, '');
$this->assertEquals('WARNING_UNBALANCED_AMOUNT_OF_BRACES', $this->obj->warnings[0]['warning']);
}
BibTexTest::testAddEntry ( )

Definition at line 243 of file BibTexTest.php.

References $addarray.

{
$addarray = array();
$addarray['type'] = 'Article';
$addarray['cite'] = 'art2';
$addarray['title'] = 'Titel2';
$addarray['author'][0] = 'John Doe';
$addarray['author'][1] = 'Jane Doe';
$teststring = "@Article { art1,
title = {Titel1},
author = {John Doe and Jane Doe}
}";
$this->obj->content = $teststring;
$this->obj->parse();
$this->obj->addEntry($addarray);
$this->assertEquals(2, $this->obj->amount());
}
BibTexTest::testAllowedTypeFalse ( )

Definition at line 781 of file BibTexTest.php.

References $test.

{
$test = 'foo';
$this->assertFalse($this->obj->_checkAllowedEntryType($test));
}
BibTexTest::testAllowedTypeTrue ( )

Definition at line 775 of file BibTexTest.php.

References $test.

{
$test = 'article';
$this->assertTrue($this->obj->_checkAllowedEntryType($test));
}
BibTexTest::testAllowedTypeWarning ( )

Definition at line 787 of file BibTexTest.php.

References $test.

{
$this->obj->clearWarnings();
$test = "@Foo { art1,
title = {Titel1},
author = {John Doe and Jane Doe}
}";
$this->obj->content = $test;
$this->obj->setOption('validate', true);
$this->obj->parse();
$this->assertEquals('WARNING_NOT_ALLOWED_ENTRY_TYPE', $this->obj->warnings[0]['warning']);
}
BibTexTest::testAmount ( )

Definition at line 160 of file BibTexTest.php.

{
$teststring = "@Article {art1,author = {John Doe and Jane Doe}}@Article { art2,author = {John Doe and Jane Doe}}";
$this->obj->content = $teststring;
$this->obj->parse();
$this->assertEquals(2, $this->obj->amount());
}
BibTexTest::testAuthorFirstDigitsArecaselessLowercase ( )

Definition at line 510 of file BibTexTest.php.

References $test.

{
$test = "AA 1b cc dd";
$shouldbe = array();
$shouldbe[0]['first'] = 'AA';
$shouldbe[0]['von'] = '1b cc';
$shouldbe[0]['last'] = 'dd';
$shouldbe[0]['jr'] = '';
$this->assertEquals($shouldbe, $this->obj->_extractAuthors($test));
}
BibTexTest::testAuthorFirstDigitsArecaselessUppercase ( )

Definition at line 499 of file BibTexTest.php.

References $test.

{
$test = "AA 1B cc dd";
$shouldbe = array();
$shouldbe[0]['first'] = 'AA 1B';
$shouldbe[0]['von'] = 'cc';
$shouldbe[0]['last'] = 'dd';
$shouldbe[0]['jr'] = '';
$this->assertEquals($shouldbe, $this->obj->_extractAuthors($test));
}
BibTexTest::testAuthorFirstGroupingCaselessOne ( )

Definition at line 587 of file BibTexTest.php.

References $test.

{
$test = "AA {bb} cc DD";
$shouldbe = array();
$shouldbe[0]['first'] = 'AA {bb}';
$shouldbe[0]['von'] = 'cc';
$shouldbe[0]['last'] = 'DD';
$shouldbe[0]['jr'] = '';
$this->assertEquals($shouldbe, $this->obj->_extractAuthors($test));
}
BibTexTest::testAuthorFirstGroupingCaselessThree ( )

Definition at line 609 of file BibTexTest.php.

References $test.

{
$test = "AA {bb} CC";
$shouldbe = array();
$shouldbe[0]['first'] = 'AA {bb}';
$shouldbe[0]['von'] = '';
$shouldbe[0]['last'] = 'CC';
$shouldbe[0]['jr'] = '';
$this->assertEquals($shouldbe, $this->obj->_extractAuthors($test));
}
BibTexTest::testAuthorFirstGroupingCaselessTwo ( )

Definition at line 598 of file BibTexTest.php.

References $test.

{
$test = "AA bb {cc} DD";
$shouldbe = array();
$shouldbe[0]['first'] = 'AA';
$shouldbe[0]['von'] = 'bb';
$shouldbe[0]['last'] = '{cc} DD';
$shouldbe[0]['jr'] = '';
$this->assertEquals($shouldbe, $this->obj->_extractAuthors($test));
}
BibTexTest::testAuthorFirstLastCannotBeEmpty ( )

Definition at line 444 of file BibTexTest.php.

References $test.

{
$test = "AA";
$shouldbe = array();
$shouldbe[0]['first'] = '';
$shouldbe[0]['von'] = '';
$shouldbe[0]['last'] = 'AA';
$shouldbe[0]['jr'] = '';
$this->assertEquals($shouldbe, $this->obj->_extractAuthors($test));
}
BibTexTest::testAuthorFirstLastCannotBeEmptyLowerCase ( )

Definition at line 466 of file BibTexTest.php.

References $test.

{
$test = "aa";
$shouldbe = array();
$shouldbe[0]['first'] = '';
$shouldbe[0]['von'] = '';
$shouldbe[0]['last'] = 'aa';
$shouldbe[0]['jr'] = '';
$this->assertEquals($shouldbe, $this->obj->_extractAuthors($test));
}
BibTexTest::testAuthorFirstNonLettersAreCaselessLowerCase ( )

Definition at line 576 of file BibTexTest.php.

References $test.

{
$test = "AA \bb{b} cc dd";
$shouldbe = array();
$shouldbe[0]['first'] = 'AA';
$shouldbe[0]['von'] = '\bb{b} cc';
$shouldbe[0]['last'] = 'dd';
$shouldbe[0]['jr'] = '';
$this->assertEquals($shouldbe, $this->obj->_extractAuthors($test));
}
BibTexTest::testAuthorFirstNonLettersAreCaselessUpperCase ( )

Definition at line 565 of file BibTexTest.php.

References $test.

{
$test = "AA \BB{b} cc dd";
$shouldbe = array();
$shouldbe[0]['first'] = 'AA \BB{b}';
$shouldbe[0]['von'] = 'cc';
$shouldbe[0]['last'] = 'dd';
$shouldbe[0]['jr'] = '';
$this->assertEquals($shouldbe, $this->obj->_extractAuthors($test));
}
BibTexTest::testAuthorFirstPseudoLettersAreCaselessLowerInsideLowerOutside ( )

Definition at line 532 of file BibTexTest.php.

References $test.

{
$test = "AA {b}b cc dd";
$shouldbe = array();
$shouldbe[0]['first'] = 'AA';
$shouldbe[0]['von'] = '{b}b cc';
$shouldbe[0]['last'] = 'dd';
$shouldbe[0]['jr'] = '';
$this->assertEquals($shouldbe, $this->obj->_extractAuthors($test));
}
BibTexTest::testAuthorFirstPseudoLettersAreCaselessLowerInsideUpperOutside ( )

Definition at line 521 of file BibTexTest.php.

References $test.

{
$test = "AA {b}B cc dd";
$shouldbe = array();
$shouldbe[0]['first'] = 'AA {b}B';
$shouldbe[0]['von'] = 'cc';
$shouldbe[0]['last'] = 'dd';
$shouldbe[0]['jr'] = '';
$this->assertEquals($shouldbe, $this->obj->_extractAuthors($test));
}
BibTexTest::testAuthorFirstPseudoLettersAreCaselessUpperInsideLowerOutside ( )

Definition at line 554 of file BibTexTest.php.

References $test.

{
$test = "AA {B}b cc dd";
$shouldbe = array();
$shouldbe[0]['first'] = 'AA';
$shouldbe[0]['von'] = '{B}b cc';
$shouldbe[0]['last'] = 'dd';
$shouldbe[0]['jr'] = '';
$this->assertEquals($shouldbe, $this->obj->_extractAuthors($test));
}
BibTexTest::testAuthorFirstPseudoLettersAreCaselessUpperInsideUpperOutside ( )

Definition at line 543 of file BibTexTest.php.

References $test.

{
$test = "AA {B}B cc dd";
$shouldbe = array();
$shouldbe[0]['first'] = 'AA {B}B';
$shouldbe[0]['von'] = 'cc';
$shouldbe[0]['last'] = 'dd';
$shouldbe[0]['jr'] = '';
$this->assertEquals($shouldbe, $this->obj->_extractAuthors($test));
}
BibTexTest::testAuthorFirstSimple ( )

Definition at line 433 of file BibTexTest.php.

References $test.

{
$test = "AA BB";
$shouldbe = array();
$shouldbe[0]['first'] = 'AA';
$shouldbe[0]['von'] = '';
$shouldbe[0]['last'] = 'BB';
$shouldbe[0]['jr'] = '';
$this->assertEquals($shouldbe, $this->obj->_extractAuthors($test));
}
BibTexTest::testAuthorFirstSimpleLowerCase ( )

Definition at line 455 of file BibTexTest.php.

References $test.

{
$test = "AA bb";
$shouldbe = array();
$shouldbe[0]['first'] = 'AA';
$shouldbe[0]['von'] = '';
$shouldbe[0]['last'] = 'bb';
$shouldbe[0]['jr'] = '';
$this->assertEquals($shouldbe, $this->obj->_extractAuthors($test));
}
BibTexTest::testAuthorFirstSimpleVon ( )

Definition at line 477 of file BibTexTest.php.

References $test.

{
$test = "AA bb CC";
$shouldbe = array();
$shouldbe[0]['first'] = 'AA';
$shouldbe[0]['von'] = 'bb';
$shouldbe[0]['last'] = 'CC';
$shouldbe[0]['jr'] = '';
$this->assertEquals($shouldbe, $this->obj->_extractAuthors($test));
}
BibTexTest::testAuthorFirstSimpleVonInnerUppercase ( )

Definition at line 488 of file BibTexTest.php.

References $test.

{
$test = "AA bb CC dd EE";
$shouldbe = array();
$shouldbe[0]['first'] = 'AA';
$shouldbe[0]['von'] = 'bb CC dd';
$shouldbe[0]['last'] = 'EE';
$shouldbe[0]['jr'] = '';
$this->assertEquals($shouldbe, $this->obj->_extractAuthors($test));
}
BibTexTest::testAuthorSecondAndThirdFirstCanBeEmptyAfterComma ( )

Definition at line 664 of file BibTexTest.php.

References $test.

{
$test = "BB,";
$shouldbe = array();
$shouldbe[0]['first'] = '';
$shouldbe[0]['von'] = '';
$shouldbe[0]['last'] = 'BB';
$shouldbe[0]['jr'] = '';
$this->assertEquals($shouldbe, $this->obj->_extractAuthors($test));
}
BibTexTest::testAuthorSecondAndThirdJrCanBeEmptyBetweenCommas ( )

Definition at line 697 of file BibTexTest.php.

References $test.

{
$test = "BB,, AA";
$shouldbe = array();
$shouldbe[0]['first'] = 'AA';
$shouldbe[0]['von'] = '';
$shouldbe[0]['last'] = 'BB';
$shouldbe[0]['jr'] = '';
$this->assertEquals($shouldbe, $this->obj->_extractAuthors($test));
}
BibTexTest::testAuthorSecondAndThirdLastPartCoannotBeEmpty ( )

Definition at line 653 of file BibTexTest.php.

References $test.

{
$test = "bb, AA";
$shouldbe = array();
$shouldbe[0]['first'] = 'AA';
$shouldbe[0]['von'] = '';
$shouldbe[0]['last'] = 'bb';
$shouldbe[0]['jr'] = '';
$this->assertEquals($shouldbe, $this->obj->_extractAuthors($test));
}
BibTexTest::testAuthorSecondAndThirdSimpleCaseFirstLowercase ( )

Definition at line 631 of file BibTexTest.php.

References $test.

{
$test = "bb CC, aa";
$shouldbe = array();
$shouldbe[0]['first'] = 'aa';
$shouldbe[0]['von'] = 'bb';
$shouldbe[0]['last'] = 'CC';
$shouldbe[0]['jr'] = '';
$this->assertEquals($shouldbe, $this->obj->_extractAuthors($test));
}
BibTexTest::testAuthorSecondAndThirdSimpleCaseFirstUppercase ( )

Definition at line 620 of file BibTexTest.php.

References $test.

{
$test = "bb CC, AA";
$shouldbe = array();
$shouldbe[0]['first'] = 'AA';
$shouldbe[0]['von'] = 'bb';
$shouldbe[0]['last'] = 'CC';
$shouldbe[0]['jr'] = '';
$this->assertEquals($shouldbe, $this->obj->_extractAuthors($test));
}
BibTexTest::testAuthorSecondAndThirdSimpleJrLowercase ( )

Definition at line 686 of file BibTexTest.php.

References $test.

{
$test = "bb CC,xx, AA";
$shouldbe = array();
$shouldbe[0]['first'] = 'AA';
$shouldbe[0]['von'] = 'bb';
$shouldbe[0]['last'] = 'CC';
$shouldbe[0]['jr'] = 'xx';
$this->assertEquals($shouldbe, $this->obj->_extractAuthors($test));
}
BibTexTest::testAuthorSecondAndThirdSimpleJrUppercase ( )

Definition at line 675 of file BibTexTest.php.

References $test.

{
$test = "bb CC,XX, AA";
$shouldbe = array();
$shouldbe[0]['first'] = 'AA';
$shouldbe[0]['von'] = 'bb';
$shouldbe[0]['last'] = 'CC';
$shouldbe[0]['jr'] = 'XX';
$this->assertEquals($shouldbe, $this->obj->_extractAuthors($test));
}
BibTexTest::testAuthorSecondAndThirdSimpleVon ( )

Definition at line 642 of file BibTexTest.php.

References $test.

{
$test = "bb CC dd EE, AA";
$shouldbe = array();
$shouldbe[0]['first'] = 'AA';
$shouldbe[0]['von'] = 'bb CC dd';
$shouldbe[0]['last'] = 'EE';
$shouldbe[0]['jr'] = '';
$this->assertEquals($shouldbe, $this->obj->_extractAuthors($test));
}
BibTexTest::testBibTex ( )

Definition at line 224 of file BibTexTest.php.

{
$testarray = array();
$testarray[0]['entryType'] = 'Article';
$testarray[0]['cite'] = 'art1';
$testarray[0]['title'] = 'Titel1';
$testarray[0]['author'][0]['first'] = 'John';
$testarray[0]['author'][0]['von'] = '';
$testarray[0]['author'][0]['last'] = 'Doe';
$testarray[0]['author'][0]['jr'] = '';
$testarray[0]['author'][1]['first'] = 'Jane';
$testarray[0]['author'][1]['von'] = '';
$testarray[0]['author'][1]['last'] = 'Doe';
$testarray[0]['author'][1]['jr'] = '';
$shouldbe = "@article { art1,\n\ttitle = {Titel1},\n\tauthor = {Doe, , John and Doe, , Jane}\n}";
$this->obj->data = $testarray;
$this->assertEquals(trim($shouldbe), trim($this->obj->bibTex()));
}
BibTexTest::testCaseCaselessSimple ( )

Definition at line 721 of file BibTexTest.php.

References $test.

{
$test = '{a}';
$this->assertEquals(- 1, $this->obj->_determineCase($test));
}
BibTexTest::testCaseErrorEmptyString ( )

Definition at line 763 of file BibTexTest.php.

References $test, and PEAR\isError().

{
$test = '';
$this->assertTrue(PEAR::isError($this->obj->_determineCase($test)));
}

+ Here is the call graph for this function:

BibTexTest::testCaseErrorNonString ( )

Definition at line 769 of file BibTexTest.php.

References $test, and PEAR\isError().

{
$test = 2;
$this->assertTrue(PEAR::isError($this->obj->_determineCase($test)));
}

+ Here is the call graph for this function:

BibTexTest::testCaseLowerComplexBrace ( )

Definition at line 733 of file BibTexTest.php.

References $test.

{
$test = '{a}a';
$this->assertEquals(0, $this->obj->_determineCase($test));
}
BibTexTest::testCaseLowerComplexNumber ( )

Definition at line 745 of file BibTexTest.php.

References $test.

{
$test = '1a';
$this->assertEquals(0, $this->obj->_determineCase($test));
}
BibTexTest::testCaseLowerComplexWhitespace ( )

Definition at line 757 of file BibTexTest.php.

References $test.

{
$test = ' a';
$this->assertEquals(0, $this->obj->_determineCase($test));
}
BibTexTest::testCaseLowerSimple ( )

Definition at line 715 of file BibTexTest.php.

References $test.

{
$test = 'aa';
$this->assertEquals(0, $this->obj->_determineCase($test));
}
BibTexTest::testCaseUpperComplexBrace ( )

Definition at line 727 of file BibTexTest.php.

References $test.

{
$test = '{A}A';
$this->assertEquals(1, $this->obj->_determineCase($test));
}
BibTexTest::testCaseUpperComplexNumber ( )

Definition at line 739 of file BibTexTest.php.

References $test.

{
$test = '1A';
$this->assertEquals(1, $this->obj->_determineCase($test));
}
BibTexTest::testCaseUpperComplexWhitespace ( )

Definition at line 751 of file BibTexTest.php.

References $test.

{
$test = ' A';
$this->assertEquals(1, $this->obj->_determineCase($test));
}
BibTexTest::testCaseUpperSimple ( )

Definition at line 709 of file BibTexTest.php.

References $test.

{
$test = 'AA';
$this->assertEquals(1, $this->obj->_determineCase($test));
}
BibTexTest::testClearWarnings ( )

Definition at line 99 of file BibTexTest.php.

{
$this->obj->clearWarnings();
$this->obj->_generateWarning('type', 'entry');
$this->obj->clearWarnings();
$this->assertFalse($this->obj->hasWarning());
}
BibTexTest::testEntryOverMoreLines ( )

Definition at line 261 of file BibTexTest.php.

{
//Entry found at http://en.wikipedia.org/wiki/BibTeX
$teststring = "@Book{abramowitz+stegun,
author = \"Milton Abramowitz and Irene A. Stegun\",
title = \"Handbook of Mathematical Functions with
Formulas, Graphs, and Mathematical Tables\",
publisher = \"Dover\",
year = 1964,
address = \"New York\",
edition = \"ninth Dover printing, tenth GPO printing\",
isbn = \"0-486-61272-4\"
}";
$shouldbe = array();
$shouldbe[0]['entryType'] = 'book';
$shouldbe[0]['cite'] = 'abramowitz+stegun';
$shouldbe[0]['title'] = "Handbook of Mathematical Functions with
Formulas, Graphs, and Mathematical Tables";
$shouldbe[0]['author'][0]['first'] = 'Milton';
$shouldbe[0]['author'][0]['von'] = '';
$shouldbe[0]['author'][0]['last'] = 'Abramowitz';
$shouldbe[0]['author'][0]['jr'] = '';
$shouldbe[0]['author'][1]['first'] = 'Irene A.';
$shouldbe[0]['author'][1]['von'] = '';
$shouldbe[0]['author'][1]['last'] = 'Stegun';
$shouldbe[0]['author'][1]['jr'] = '';
$shouldbe[0]['publisher'] = 'Dover';
$shouldbe[0]['year'] = '1964';
$shouldbe[0]['address'] = 'New York';
$shouldbe[0]['edition'] = 'ninth Dover printing, tenth GPO printing';
$shouldbe[0]['isbn'] = '0-486-61272-4';
$this->obj->content = $teststring;
$this->obj->parse();
$this->assertEquals($shouldbe, $this->obj->data);
}
BibTexTest::testExtractAuthors ( )

Definition at line 1099 of file BibTexTest.php.

References $test.

{
$this->obj->clearWarnings();
$test = '
@phdthesis{foo4,
author = {John Doe},
}
';
$shouldbe = array();
$shouldbe[0]['first'] = 'John';
$shouldbe[0]['von'] = '';
$shouldbe[0]['last'] = 'Doe';
$shouldbe[0]['jr'] = '';
$this->obj->content = $test;
$this->obj->setOption('extractAuthors', true);
$this->obj->parse();
$this->assertEquals($shouldbe, $this->obj->data[0]['author']);
}
BibTexTest::testExtractAuthorTilde ( )

Definition at line 1073 of file BibTexTest.php.

References $test.

{
$test = 'John~Doe';
$shouldbe = array();
$shouldbe[0]['first'] = 'John';
$shouldbe[0]['von'] = '';
$shouldbe[0]['last'] = 'Doe';
$shouldbe[0]['jr'] = '';
$this->assertEquals($shouldbe, $this->obj->_extractAuthors($test));
}
BibTexTest::testExtractAuthorWhitespace ( )

Definition at line 1062 of file BibTexTest.php.

References $test.

{
$test = 'John Doe';
$shouldbe = array();
$shouldbe[0]['first'] = 'John';
$shouldbe[0]['von'] = '';
$shouldbe[0]['last'] = 'Doe';
$shouldbe[0]['jr'] = '';
$this->assertEquals($shouldbe, $this->obj->_extractAuthors($test));
}
BibTexTest::testFormatAuthor ( )

Definition at line 1038 of file BibTexTest.php.

References $test.

{
$test = '
@phdthesis{foo4,
author = {von Last, Jr ,First}
}
';
$shouldbe = 'von Last Jr First';
$this->obj->content = $test;
/*Setting formating option and saving old state*/
$oldhtmlstring = $this->obj->htmlstring;
$this->obj->htmlstring = 'AUTHORS';
$oldauthorstring = $this->obj->authorstring;
$this->obj->authorstring = 'VON LAST JR FIRST';
$this->obj->parse();
$html = $this->obj->html();
/*Dropping tags and trimming*/
$html = trim(strip_tags($html));
/*Resetting old state*/
$this->obj->htmlstring = $oldhtmlstring;
$this->obj->authorstring = $oldauthorstring;
$this->assertEquals($shouldbe, $html);
}
BibTexTest::testGetStatistic ( )

Definition at line 168 of file BibTexTest.php.

{
$teststring = "@Article {art1,author = {John Doe and Jane Doe}}@Article { art2,author = {John Doe and Jane Doe}}";
$this->obj->content = $teststring;
$this->obj->parse();
$shouldbe = array();
$shouldbe['article'] = 2;
$this->assertEquals($shouldbe, $this->obj->getStatistic());
}
BibTexTest::testHasWarning ( )

Definition at line 154 of file BibTexTest.php.

{
$this->obj->clearWarnings();
$this->assertFalse($this->obj->hasWarning());
}
BibTexTest::testHtmlExport ( )

Definition at line 1010 of file BibTexTest.php.

References $test.

{
$test = '
@phdthesis{foo4,
title = {title},
author = {author},
journal = {journal},
year = {year}
}
';
$shouldbe = '<p>
author title journal year
</p>
';
$this->obj->content = $test;
/*Setting formating option and saving old state*/
$oldhtmlstring = $this->obj->htmlstring;
$this->obj->htmlstring = 'AUTHORS TITLE JOURNAL YEAR';
$oldauthorstring = $this->obj->authorstring;
$this->obj->authorstring = 'LAST';
$this->obj->parse();
$html = $this->obj->html();
/*Resetting old state*/
$this->obj->htmlstring = $oldhtmlstring;
$this->obj->authorstring = $oldauthorstring;
$this->assertEquals($shouldbe, $html);
}
BibTexTest::testLoadFileFileDoesNotExists ( )

Definition at line 67 of file BibTexTest.php.

References $ret, and PEAR\isError().

{
$ret = $this->obj->loadFile((string)time());
$this->assertTrue(PEAR::isError($ret));
}

+ Here is the call graph for this function:

BibTexTest::testLoadFileFileExists ( )

Definition at line 60 of file BibTexTest.php.

References $ret.

{
$ret = $this->obj->loadFile("BibTexTest.php");
$this->content = ''; //Erasing the loaded content again because it is senseless
$this->assertTrue($ret);
}
BibTexTest::testMissingLastBraceParsing ( )

Definition at line 800 of file BibTexTest.php.

References $test.

{
$this->obj->clearWarnings();
$test = '
@phdthesis{foo1,
school = {school1},
title = {title1},
author = {author1},
year = {year1}
}
@phdthesis{foo2,
school = {school2},
title = {title2},
author = {author2},
year = {year2}
@phdthesis{foo3,
school = {school3},
title = {title3},
author = {author3},
year = {year3}
}
@phdthesis{foo4,
school = {school4},
title = {title4},
author = {author4},
year = {year4}
}
';
$this->obj->content = $test;
$this->obj->setOption('validate', true);
$this->obj->parse();
$this->assertEquals($this->obj->amount(), 4);
}
BibTexTest::testMissingLastBraceParsing2 ( )

Definition at line 835 of file BibTexTest.php.

References $test.

{
$this->obj->clearWarnings();
$test = '
@phdthesis{foo1,
school = {school1},
title = {title1},
author = {author1},
year = {year1}
';
$this->obj->content = $test;
$this->obj->setOption('validate', true);
$this->obj->parse();
$this->assertEquals($this->obj->amount(), 1);
}
BibTexTest::testMissingLastBraceWarning ( )

Definition at line 851 of file BibTexTest.php.

References $test.

{
$this->obj->clearWarnings();
$test = '
@phdthesis{foo1,
school = {school1},
title = {title1},
author = {author1},
year = {year1}
}
@phdthesis{foo2,
school = {school2},
title = {title2},
author = {author2},
year = {year2}
@phdthesis{foo3,
school = {school3},
title = {title3},
author = {author3},
year = {year3}
}
@phdthesis{foo4,
school = {school4},
title = {title4},
author = {author4},
year = {year4}
}
';
$this->obj->content = $test;
$this->obj->setOption('validate', true);
$this->obj->parse();
$this->assertEquals($this->obj->warnings[0]['warning'], 'WARNING_MISSING_END_BRACE');
}
BibTexTest::testMultiParse ( )

Definition at line 188 of file BibTexTest.php.

{
$teststring = "@Article { art1,
author = {John Doe and Jane Doe}
}
@Article { art2,
author = {John Doe and Jane Doe}
}";
$this->obj->content = $teststring;
$this->obj->parse();
$this->assertEquals(2, $this->obj->amount());
}
BibTexTest::testNewlineInAuthorField ( )

Definition at line 886 of file BibTexTest.php.

References $test.

{
$this->obj->clearWarnings();
$test = '
@phdthesis{foo1,
school = {school1},
title = {title1},
author = {author1 and
author2},
year = {year1}
}
';
$shouldbe = array(
array( 'first' => '', 'von' => '', 'last' => 'author1', 'jr' => '' ),
array( 'first' => '', 'von' => '', 'last' => 'author2', 'jr' => '' )
);
$this->obj->content = $test;
$this->obj->setOption('unwrap', false);
$this->obj->parse();
$this->assertEquals($shouldbe, $this->obj->data[0]['author']);
}
BibTexTest::testNotExtractAuthors ( )

Definition at line 1084 of file BibTexTest.php.

References $test.

{
$this->obj->clearWarnings();
$test = '
@phdthesis{foo4,
author = {John Doe},
}
';
$shouldbe = 'John Doe';
$this->obj->content = $test;
$this->obj->setOption('extractAuthors', false);
$this->obj->parse();
$this->assertEquals($shouldbe, $this->obj->data[0]['author']);
}
BibTexTest::testNotExtractAuthorsBibtexExport ( )

Definition at line 1118 of file BibTexTest.php.

References $test.

{
$this->obj->clearWarnings();
$test = "@phdthesis { foo4,\n\tauthor = {John Doe}\n}\n\n";
$this->obj->content = $test;
$this->obj->setOption('extractAuthors', false);
$this->obj->parse();
$this->assertEquals($test, $this->obj->bibTex());
}
BibTexTest::testNotExtractAuthorsHtmlExport ( )

Definition at line 1142 of file BibTexTest.php.

References $test.

{
$this->obj->clearWarnings();
$test = "@phdthesis { foo4,\n\tauthor = {John Doe}\n}\n\n";
$shouldbe = '<p>
John Doe, "<strong></strong>", <em></em>, <br />
</p>
';
$this->obj->content = $test;
$this->obj->setOption('extractAuthors', false);
$this->obj->parse();
$this->assertEquals($shouldbe, $this->obj->html());
}
BibTexTest::testNotExtractAuthorsRtfExport ( )

Definition at line 1128 of file BibTexTest.php.

References $test.

{
$this->obj->clearWarnings();
$test = "@phdthesis { foo4,\n\tauthor = {John Doe}\n}\n\n";
$shouldbe = '{\rtf
John Doe, "{\b }", {\i },
\par
}';
$this->obj->content = $test;
$this->obj->setOption('extractAuthors', false);
$this->obj->parse();
$this->assertEquals($shouldbe, $this->obj->rtf());
}
BibTexTest::testNotRemoveCurlyBraces ( )

Definition at line 908 of file BibTexTest.php.

References $test.

{
$this->obj->clearWarnings();
$test = '
@phdthesis{foo4,
school = {school4},
title = {Do {S}omething},
author = {author4},
year = {year4}
}
';
$shouldbe = 'Do {S}omething';
$this->obj->content = $test;
$this->obj->setOption('removeCurlyBraces', false);
$this->obj->parse();
//print_r($this->obj->data[0]['author']);
$this->assertEquals($shouldbe, $this->obj->data[0]['title']);
}
BibTexTest::testParse ( )

Definition at line 201 of file BibTexTest.php.

{
$teststring = "@Article { art1,
title = {Titel1},
author = {John Doe and Jane Doe}
}";
$shouldbe = array();
$shouldbe[0]['entryType'] = 'article';
$shouldbe[0]['cite'] = 'art1';
$shouldbe[0]['title'] = 'Titel1';
$shouldbe[0]['author'][0]['first'] = 'John';
$shouldbe[0]['author'][0]['von'] = '';
$shouldbe[0]['author'][0]['last'] = 'Doe';
$shouldbe[0]['author'][0]['jr'] = '';
$shouldbe[0]['author'][1]['first'] = 'Jane';
$shouldbe[0]['author'][1]['von'] = '';
$shouldbe[0]['author'][1]['last'] = 'Doe';
$shouldbe[0]['author'][1]['jr'] = '';
$this->obj->content = $teststring;
$this->obj->parse();
$this->assertEquals($shouldbe, $this->obj->data);
}
BibTexTest::testParsingComment ( )

Definition at line 297 of file BibTexTest.php.

{
$teststring = "@Article { art1,
title = {Titel1},
author = {John Doe and Jane Doe}
}
Here is a comment
@Article { art2,
title = {Titel2},
author = {John Doe and Jane Doe}
}";
$shouldbe = array();
$shouldbe[0]['entryType'] = 'article';
$shouldbe[0]['cite'] = 'art1';
$shouldbe[0]['title'] = 'Titel1';
$shouldbe[0]['author'][0]['first'] = 'John';
$shouldbe[0]['author'][0]['von'] = '';
$shouldbe[0]['author'][0]['last'] = 'Doe';
$shouldbe[0]['author'][0]['jr'] = '';
$shouldbe[0]['author'][1]['first'] = 'Jane';
$shouldbe[0]['author'][1]['von'] = '';
$shouldbe[0]['author'][1]['last'] = 'Doe';
$shouldbe[0]['author'][1]['jr'] = '';
$shouldbe[1]['entryType'] = 'article';
$shouldbe[1]['cite'] = 'art2';
$shouldbe[1]['title'] = 'Titel2';
$shouldbe[1]['author'][0]['first'] = 'John';
$shouldbe[1]['author'][0]['von'] = '';
$shouldbe[1]['author'][0]['last'] = 'Doe';
$shouldbe[1]['author'][0]['jr'] = '';
$shouldbe[1]['author'][1]['first'] = 'Jane';
$shouldbe[1]['author'][1]['von'] = '';
$shouldbe[1]['author'][1]['last'] = 'Doe';
$shouldbe[1]['author'][1]['jr'] = '';
$this->obj->content = $teststring;
$this->obj->parse();
$this->assertTrue($this->obj->data == $shouldbe);
}
BibTexTest::testRemoveCurlyBraces ( )

Definition at line 927 of file BibTexTest.php.

References $test.

{
$this->obj->clearWarnings();
$test = '
@phdthesis{foo4,
school = {school4},
title = {Do {S}omething},
author = {author4},
year = {year4}
}
';
$shouldbe = 'Do Something';
$this->obj->content = $test;
$this->obj->setOption('removeCurlyBraces', true);
$this->obj->parse();
//print_r($this->obj->data[0]['author']);
$this->assertEquals($shouldbe, $this->obj->data[0]['title']);
}
BibTexTest::testRemoveCurlyBraces2 ( )

Definition at line 946 of file BibTexTest.php.

References $test.

{
$this->obj->clearWarnings();
$test = '
@phdthesis{foo4,
school = {school4},
title = {Do {S}o{me\}th}ing},
author = {author4},
year = {year4}
}
';
$shouldbe = 'Do Some\}thing';
$this->obj->content = $test;
$this->obj->setOption('removeCurlyBraces', true);
$this->obj->parse();
$this->assertEquals($shouldbe, $this->obj->data[0]['title']);
}
BibTexTest::testRemoveCurlyBracesWithoutBraces ( )

Definition at line 964 of file BibTexTest.php.

References $test.

{
$this->obj->clearWarnings();
$test = '
@phdthesis{foo4,
school = {school4},
title = {Do Something},
author = {author4},
year = {year4}
}
';
$shouldbe = 'Do Something';
$this->obj->content = $test;
$this->obj->setOption('removeCurlyBraces', true);
$this->obj->parse();
$this->assertEquals($shouldbe, $this->obj->data[0]['title']);
}
BibTexTest::testRtfExport ( )

Definition at line 982 of file BibTexTest.php.

References $test.

{
$test = '
@phdthesis{foo4,
title = {title},
author = {author},
journal = {journal},
year = {year}
}
';
$shouldbe = '{\rtf
author title journal year
\par
}';
$this->obj->content = $test;
/*Setting formating option and saving old state*/
$oldrtfstring = $this->obj->rtfstring;
$this->obj->rtfstring = 'AUTHORS TITLE JOURNAL YEAR';
$oldauthorstring = $this->obj->authorstring;
$this->obj->authorstring = 'LAST';
$this->obj->parse();
$rtf = $this->obj->rtf();
/*Resetting old state*/
$this->obj->rtfstring = $oldrtfstring;
$this->obj->authorstring = $oldauthorstring;
$this->assertEquals($shouldbe, $rtf);
}
BibTexTest::testSingleParse ( )

Definition at line 178 of file BibTexTest.php.

{
$teststring = "@Article { ppm_jon:1991,
author = {John Doe and Jane Doe}
}";
$this->obj->content = $teststring;
$this->obj->parse();
$this->assertEquals(1, $this->obj->amount());
}
BibTexTest::testWarningAtInBraces ( )

Definition at line 365 of file BibTexTest.php.

{
$teststring = "@Article { art1,
title = {Titel1},
author = {John Doe and @Jane Doe}
}";
$this->obj->content = $teststring;
$this->obj->parse();
$this->assertTrue('WARNING_AT_IN_BRACES' == $this->obj->warnings[0]['warning']);
}
BibTexTest::testWarningEscapedDoubleQuote ( )

Definition at line 376 of file BibTexTest.php.

{
$teststring = "@Article { art1,
title = {Titel1},
author = \"John Doe and \\\"Jane Doe\"
}";
$this->obj->content = $teststring;
$this->obj->parse();
$this->assertTrue('WARNING_ESCAPED_DOUBLE_QUOTE_INSIDE_DOUBLE_QUOTES' == $this->obj->warnings[0]['warning']);
}
BibTexTest::testWarningMultipleEntries ( )

Definition at line 398 of file BibTexTest.php.

{
$teststring = "@Article { art1,
title = {Titel1},
author = {John Doe and Jane Doe}
}
@Article { art2,
title = {Titel1},
author = {John Doe and Jane Doe}
}
@Article { art1,
title = {Titel1},
author = {John Doe and Jane Doe}
}
@Article { art2,
title = {Titel1},
author = {John Doe and Jane Doe}
}
@Article { art3,
title = {Titel1},
author = {John Doe and Jane Doe}
}";
$this->obj->content = $teststring;
$this->obj->parse();
$this->assertTrue('WARNING_MULTIPLE_ENTRIES' == $this->obj->warnings[0]['warning']);
}
BibTexTest::testWrongBraces3 ( )

Definition at line 355 of file BibTexTest.php.

References PEAR\isError().

{
$teststring = "@Article { art1,
title = {Titel1},
author = {John {Doe and {Jane Doe}
}";
$this->obj->content = $teststring;
$this->assertTrue(PEAR::isError($this->obj->parse()));
}

+ Here is the call graph for this function:

Field Documentation

BibTexTest::$obj

Definition at line 22 of file BibTexTest.php.


The documentation for this class was generated from the following file: