PageRenderTime 39ms CodeModel.GetById 18ms RepoModel.GetById 0ms app.codeStats 0ms

/tests/PhpWord/Tests/Element/FootnoteTest.php

https://github.com/cyrillkalita/PHPWord
PHP | 119 lines | 58 code | 17 blank | 44 comment | 0 complexity | 0d09e317190d656288f7a8d98b2bf78e MD5 | raw file
Possible License(s): GPL-3.0, LGPL-3.0
  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\Element;
  18. use PhpOffice\PhpWord\Element\Footnote;
  19. /**
  20. * Test class for PhpOffice\PhpWord\Element\Footnote
  21. *
  22. * @runTestsInSeparateProcesses
  23. */
  24. class FootnoteTest extends \PHPUnit_Framework_TestCase
  25. {
  26. /**
  27. * New instance without parameter
  28. */
  29. public function testConstruct()
  30. {
  31. $oFootnote = new Footnote();
  32. $this->assertInstanceOf('PhpOffice\\PhpWord\\Element\\Footnote', $oFootnote);
  33. $this->assertCount(0, $oFootnote->getElements());
  34. $this->assertEquals($oFootnote->getParagraphStyle(), null);
  35. }
  36. /**
  37. * New instance with string parameter
  38. */
  39. public function testConstructString()
  40. {
  41. $oFootnote = new Footnote('pStyle');
  42. $this->assertEquals($oFootnote->getParagraphStyle(), 'pStyle');
  43. }
  44. /**
  45. * New instance with array parameter
  46. */
  47. public function testConstructArray()
  48. {
  49. $oFootnote = new Footnote(array('spacing' => 100));
  50. $this->assertInstanceOf(
  51. 'PhpOffice\\PhpWord\\Style\\Paragraph',
  52. $oFootnote->getParagraphStyle()
  53. );
  54. }
  55. /**
  56. * Add text element
  57. */
  58. public function testAddText()
  59. {
  60. $oFootnote = new Footnote();
  61. $element = $oFootnote->addText('text');
  62. $this->assertCount(1, $oFootnote->getElements());
  63. $this->assertInstanceOf('PhpOffice\\PhpWord\\Element\\Text', $element);
  64. }
  65. /**
  66. * Add text break element
  67. */
  68. public function testAddTextBreak()
  69. {
  70. $oFootnote = new Footnote();
  71. $oFootnote->addTextBreak(2);
  72. $this->assertCount(2, $oFootnote->getElements());
  73. }
  74. /**
  75. * Add link element
  76. */
  77. public function testAddLink()
  78. {
  79. $oFootnote = new Footnote();
  80. $element = $oFootnote->addLink('http://www.google.fr');
  81. $this->assertCount(1, $oFootnote->getElements());
  82. $this->assertInstanceOf('PhpOffice\\PhpWord\\Element\\Link', $element);
  83. }
  84. /**
  85. * Set/get reference Id
  86. */
  87. public function testReferenceId()
  88. {
  89. $oFootnote = new Footnote();
  90. $iVal = rand(1, 1000);
  91. $oFootnote->setRelationId($iVal);
  92. $this->assertEquals($oFootnote->getRelationId(), $iVal);
  93. }
  94. /**
  95. * Get elements
  96. */
  97. public function testGetElements()
  98. {
  99. $oFootnote = new Footnote();
  100. $this->assertInternalType('array', $oFootnote->getElements());
  101. }
  102. }