暫無描述

SettingsTest.php 1.9KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768
  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\Settings
  22. *
  23. * @coversDefaultClass \PhpOffice\PhpWord\Writer\Word2007\Part\Settings
  24. */
  25. class SettingsTest 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. * Test document protection
  36. */
  37. public function testDocumentProtection()
  38. {
  39. $phpWord = new PhpWord();
  40. $phpWord->getProtection()->setEditing('forms');
  41. $doc = TestHelperDOCX::getDocument($phpWord);
  42. $file = 'word/settings.xml';
  43. $path = '/w:settings/w:documentProtection';
  44. $this->assertTrue($doc->elementExists($path, $file));
  45. }
  46. /**
  47. * Test compatibility
  48. */
  49. public function testCompatibility()
  50. {
  51. $phpWord = new PhpWord();
  52. $phpWord->getCompatibility()->setOoxmlVersion(15);
  53. $doc = TestHelperDOCX::getDocument($phpWord);
  54. $file = 'word/settings.xml';
  55. $path = '/w:settings/w:compat/w:compatSetting';
  56. $this->assertTrue($doc->elementExists($path, $file));
  57. }
  58. }