No Description

FootnotesTest.php 1.9KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657
  1. <?php
  2. /**
  3. * This file is part of PHPWord - A pure PHP library for reading and writing
  4. * word processing documents.
  5. *
  6. * PHPWord is free software distributed under the terms of the GNU Lesser
  7. * General Public License version 3 as published by the Free Software Foundation.
  8. *
  9. * For the full copyright and license information, please read the LICENSE
  10. * file that was distributed with this source code. For the full list of
  11. * contributors, visit https://github.com/PHPOffice/PHPWord/contributors.
  12. *
  13. * @link https://github.com/PHPOffice/PHPWord
  14. * @copyright 2010-2014 PHPWord contributors
  15. * @license http://www.gnu.org/licenses/lgpl.txt LGPL version 3
  16. */
  17. namespace PhpOffice\PhpWord\Tests\Writer\Word2007\Part;
  18. use PhpOffice\PhpWord\PhpWord;
  19. use PhpOffice\PhpWord\Tests\TestHelperDOCX;
  20. /**
  21. * Test class for PhpOffice\PhpWord\Writer\Word2007\Part\Notes
  22. *
  23. * @runTestsInSeparateProcesses
  24. */
  25. class FootnotesTest extends \PHPUnit_Framework_TestCase
  26. {
  27. /**
  28. * Executed before each method of the class
  29. */
  30. public function tearDown()
  31. {
  32. TestHelperDOCX::clear();
  33. }
  34. /**
  35. * Write footnotes
  36. */
  37. public function testWriteFootnotes()
  38. {
  39. $phpWord = new PhpWord();
  40. $phpWord->addParagraphStyle('pStyle', array('align' => 'left'));
  41. $section = $phpWord->addSection();
  42. $section->addText('Text');
  43. $footnote1 = $section->addFootnote('pStyle');
  44. $footnote1->addText('Footnote');
  45. $footnote1->addTextBreak();
  46. $footnote1->addLink('http://google.com');
  47. $footnote2 = $section->addEndnote(array('align' => 'left'));
  48. $footnote2->addText('Endnote');
  49. $doc = TestHelperDOCX::getDocument($phpWord);
  50. $this->assertTrue($doc->elementExists("/w:document/w:body/w:p/w:r/w:footnoteReference"));
  51. $this->assertTrue($doc->elementExists("/w:document/w:body/w:p/w:r/w:endnoteReference"));
  52. }
  53. }