DocumentPropertiesTest.php 2.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475
  1. <?php
  2. /**
  3. * This file is part of PHPPresentation - A pure PHP library for reading and writing
  4. * presentations documents.
  5. *
  6. * PHPPresentation 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/PHPPresentation/contributors.
  12. *
  13. * @copyright 2009-2015 PHPPresentation contributors
  14. * @license http://www.gnu.org/licenses/lgpl.txt LGPL version 3
  15. * @link https://github.com/PHPOffice/PHPPresentation
  16. */
  17. namespace PhpOffice\PhpPresentation\Tests;
  18. use PhpOffice\PhpPresentation\DocumentProperties;
  19. /**
  20. * Test class for DocumentProperties
  21. *
  22. * @coversDefaultClass PhpOffice\PhpPresentation\DocumentProperties
  23. */
  24. class DocumentPropertiesTest extends \PHPUnit_Framework_TestCase
  25. {
  26. /**
  27. * Test get set value
  28. */
  29. public function testGetSet()
  30. {
  31. $object = new DocumentProperties();
  32. $properties = array(
  33. 'creator' => '',
  34. 'lastModifiedBy' => '',
  35. 'created' => '',
  36. 'modified' => '',
  37. 'title' => '',
  38. 'description' => '',
  39. 'subject' => '',
  40. 'keywords' => '',
  41. 'category' => '',
  42. 'company' => '',
  43. );
  44. foreach ($properties as $key => $val) {
  45. $get = "get{$key}";
  46. $set = "set{$key}";
  47. $object->$set($val);
  48. $this->assertEquals($val, $object->$get());
  49. }
  50. }
  51. /**
  52. * Test get set with null value
  53. */
  54. public function testGetSetNull()
  55. {
  56. $object = new DocumentProperties();
  57. $properties = array(
  58. 'created' => '',
  59. 'modified' => '',
  60. );
  61. $time = time();
  62. foreach (array_keys($properties) as $key) {
  63. $get = "get{$key}";
  64. $set = "set{$key}";
  65. $object->$set();
  66. $this->assertEquals($time, $object->$get());
  67. }
  68. }
  69. }