54 lines
1.8 KiB
PHP
Raw Normal View History

2014-03-14 04:26:50 +07:00
<?php
2014-03-27 23:55:06 +07:00
/**
* This file is part of PHPWord - A pure PHP library for reading and writing
* word processing documents.
*
* PHPWord is free software distributed under the terms of the GNU Lesser
* General Public License version 3 as published by the Free Software Foundation.
*
* For the full copyright and license information, please read the LICENSE
* file that was distributed with this source code. For the full list of
* contributors, visit https://github.com/PHPOffice/PHPWord/contributors.
2014-03-27 23:55:06 +07:00
*
* @see https://github.com/PHPOffice/PHPWord
2022-09-16 11:45:45 +02:00
*
2014-05-04 21:03:28 +04:00
* @license http://www.gnu.org/licenses/lgpl.txt LGPL version 3
2014-03-27 23:55:06 +07:00
*/
2022-09-16 14:09:17 +02:00
namespace PhpOffice\PhpWordTests\Writer\Word2007\Part;
2014-03-14 04:26:50 +07:00
use PhpOffice\PhpWord\PhpWord;
2015-10-10 19:22:19 +04:00
use PhpOffice\PhpWord\SimpleType\Jc;
2022-09-16 14:09:17 +02:00
use PhpOffice\PhpWordTests\TestHelperDOCX;
2014-03-14 04:26:50 +07:00
/**
* @coversNothing
2022-09-16 11:45:45 +02:00
*
2014-03-14 04:26:50 +07:00
* @runTestsInSeparateProcesses
*/
class FootnotesTest extends \PHPUnit\Framework\TestCase
2014-03-14 04:26:50 +07:00
{
2022-09-16 11:45:45 +02:00
protected function tearDown(): void
2014-03-14 04:26:50 +07:00
{
TestHelperDOCX::clear();
}
2022-09-16 11:45:45 +02:00
public function testWriteFootnotes(): void
2014-03-14 04:26:50 +07:00
{
$phpWord = new PhpWord();
2022-09-16 11:45:45 +02:00
$phpWord->addParagraphStyle('pStyle', ['alignment' => Jc::START]);
$section = $phpWord->addSection();
2016-06-04 20:06:37 +04:00
$section->addText('Text');
$footnote1 = $section->addFootnote('pStyle');
2016-06-04 20:06:37 +04:00
$footnote1->addText('Footnote');
2014-03-30 11:09:14 +07:00
$footnote1->addTextBreak();
$footnote1->addLink('https://github.com/PHPOffice/PHPWord');
2022-09-16 11:45:45 +02:00
$footnote2 = $section->addEndnote(['alignment' => Jc::START]);
2016-06-04 20:06:37 +04:00
$footnote2->addText('Endnote');
$doc = TestHelperDOCX::getDocument($phpWord);
2014-03-14 04:26:50 +07:00
2022-09-16 11:45:45 +02:00
self::assertTrue($doc->elementExists('/w:document/w:body/w:p/w:r/w:footnoteReference'));
self::assertTrue($doc->elementExists('/w:document/w:body/w:p/w:r/w:endnoteReference'));
2014-03-14 04:26:50 +07:00
}
}