meta_generator_test.php 3.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126
  1. <?php
  2. /**
  3. * ezcDocumentOdtMetaGeneratorTest.
  4. *
  5. * Licensed to the Apache Software Foundation (ASF) under one
  6. * or more contributor license agreements. See the NOTICE file
  7. * distributed with this work for additional information
  8. * regarding copyright ownership. The ASF licenses this file
  9. * to you under the Apache License, Version 2.0 (the
  10. * "License"); you may not use this file except in compliance
  11. * with the License. You may obtain a copy of the License at
  12. *
  13. * http://www.apache.org/licenses/LICENSE-2.0
  14. *
  15. * Unless required by applicable law or agreed to in writing,
  16. * software distributed under the License is distributed on an
  17. * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
  18. * KIND, either express or implied. See the License for the
  19. * specific language governing permissions and limitations
  20. * under the License.
  21. *
  22. * @package Document
  23. * @version //autogen//
  24. * @subpackage Tests
  25. * @license http://www.apache.org/licenses/LICENSE-2.0 Apache License, Version 2.0
  26. */
  27. /**
  28. * Test suite for class.
  29. *
  30. * @package Document
  31. * @subpackage Tests
  32. */
  33. class ezcDocumentOdtMetaGeneratorTest extends ezcTestCase
  34. {
  35. protected $domElement;
  36. protected $generator;
  37. public static function suite()
  38. {
  39. return new PHPUnit_Framework_TestSuite( __CLASS__ );
  40. }
  41. protected function setup()
  42. {
  43. $dom = new DOMDocument();
  44. $this->domElement = $dom->appendChild(
  45. $dom->createElementNS(
  46. ezcDocumentOdt::NS_ODT_OFFICE,
  47. 'office:meta'
  48. )
  49. );
  50. $this->generator = new ezcDocumentOdtMetaGenerator();
  51. }
  52. public function testGenerateGenerator()
  53. {
  54. $this->generator->generateMetaData( $this->domElement );
  55. $generatorTags = $this->domElement->getElementsByTagnameNS(
  56. ezcDocumentOdt::NS_ODT_META,
  57. 'generator'
  58. );
  59. $this->assertEquals(
  60. 1,
  61. $generatorTags->length
  62. );
  63. $this->assertEquals(
  64. 'eZComponents/Document-dev',
  65. $generatorTags->item( 0 )->nodeValue
  66. );
  67. }
  68. public function testGenerateMetaDate()
  69. {
  70. $this->generator->generateMetaData( $this->domElement );
  71. $dateTags = $this->domElement->getElementsByTagnameNS(
  72. ezcDocumentOdt::NS_ODT_META,
  73. 'creation-date'
  74. );
  75. $this->assertEquals(
  76. 1,
  77. $dateTags->length
  78. );
  79. $actDate = new DateTime( $dateTags->item( 0 )->nodeValue );
  80. $curDate = new DateTime();
  81. $this->assertEquals(
  82. $curDate->format( 'Ymd' ),
  83. $actDate->format( 'Ymd' )
  84. );
  85. }
  86. public function testGenerateDcDate()
  87. {
  88. $this->generator->generateMetaData( $this->domElement );
  89. $dateTags = $this->domElement->getElementsByTagnameNS(
  90. ezcDocumentOdt::NS_DC,
  91. 'date'
  92. );
  93. $this->assertEquals(
  94. 1,
  95. $dateTags->length
  96. );
  97. $actDate = new DateTime( $dateTags->item( 0 )->nodeValue );
  98. $curDate = new DateTime();
  99. $this->assertEquals(
  100. $curDate->format( 'Ymd' ),
  101. $actDate->format( 'Ymd' )
  102. );
  103. }
  104. }
  105. ?>