renderer_footer_part_tests.php 4.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167
  1. <?php
  2. /**
  3. * ezcDocumentPdfDriverTcpdfTests
  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. require_once 'base.php';
  28. /**
  29. * Test suite for class.
  30. *
  31. * @package Document
  32. * @subpackage Tests
  33. */
  34. class ezcDocumentPdfRendererFooterPartTests extends ezcDocumentPdfTestCase
  35. {
  36. protected $renderer;
  37. protected $docbook;
  38. public static function suite()
  39. {
  40. return new PHPUnit_Framework_TestSuite( __CLASS__ );
  41. }
  42. public function setUp()
  43. {
  44. parent::setUp();
  45. $style = new ezcDocumentPcssStyleInferencer();
  46. $style->appendStyleDirectives( array(
  47. new ezcDocumentPcssLayoutDirective(
  48. array( 'article' ),
  49. array(
  50. 'font-family' => 'serif',
  51. 'text-columns' => '2',
  52. 'font-size' => '10pt',
  53. 'line-height' => '1',
  54. )
  55. ),
  56. new ezcDocumentPcssLayoutDirective(
  57. array( 'title' ),
  58. array(
  59. 'font-family' => 'sans-serif',
  60. 'text-columns' => '2',
  61. )
  62. ),
  63. new ezcDocumentPcssLayoutDirective(
  64. array( 'page' ),
  65. array(
  66. 'page-size' => 'A5',
  67. )
  68. ),
  69. ) );
  70. $this->docbook = new ezcDocumentDocbook();
  71. $this->docbook->loadFile( dirname( __FILE__ ) . '/../files/pdf/long_text.xml' );
  72. $this->renderer = new ezcDocumentPdfMainRenderer(
  73. new ezcDocumentPdfSvgDriver(),
  74. $style
  75. );
  76. }
  77. public function testRenderDefaultFooter()
  78. {
  79. $this->renderer->registerPdfPart(
  80. new ezcDocumentPdfFooterPdfPart()
  81. );
  82. $pdf = $this->renderer->render(
  83. $this->docbook,
  84. new ezcDocumentPdfDefaultHyphenator()
  85. );
  86. file_put_contents(
  87. $this->tempDir . ( $fileName = __CLASS__ . '_' . __FUNCTION__ . '.svg' ),
  88. $pdf
  89. );
  90. $this->assertXmlFileEqualsXmlFile(
  91. $this->basePath . 'renderer/' . $fileName,
  92. $this->tempDir . $fileName
  93. );
  94. }
  95. public function testRenderHeader()
  96. {
  97. $this->renderer->registerPdfPart(
  98. new ezcDocumentPdfFooterPdfPart( new ezcDocumentPdfFooterOptions( array(
  99. 'footer' => false,
  100. ) ) )
  101. );
  102. $pdf = $this->renderer->render(
  103. $this->docbook,
  104. new ezcDocumentPdfDefaultHyphenator()
  105. );
  106. file_put_contents(
  107. $this->tempDir . ( $fileName = __CLASS__ . '_' . __FUNCTION__ . '.svg' ),
  108. $pdf
  109. );
  110. $this->assertXmlFileEqualsXmlFile(
  111. $this->basePath . 'renderer/' . $fileName,
  112. $this->tempDir . $fileName
  113. );
  114. }
  115. public function testRenderHeaderAndFooter()
  116. {
  117. $this->renderer->registerPdfPart(
  118. new ezcDocumentPdfFooterPdfPart( new ezcDocumentPdfFooterOptions( array(
  119. 'showDocumentTitle' => false,
  120. 'showDocumentAuthor' => false,
  121. 'pageNumberOffset' => 7,
  122. 'height' => '10mm',
  123. ) ) )
  124. );
  125. $this->renderer->registerPdfPart(
  126. new ezcDocumentPdfHeaderPdfPart( new ezcDocumentPdfFooterOptions( array(
  127. 'showPageNumber' => false,
  128. 'height' => '10mm',
  129. ) ) )
  130. );
  131. $pdf = $this->renderer->render(
  132. $this->docbook,
  133. new ezcDocumentPdfDefaultHyphenator()
  134. );
  135. file_put_contents(
  136. $this->tempDir . ( $fileName = __CLASS__ . '_' . __FUNCTION__ . '.svg' ),
  137. $pdf
  138. );
  139. $this->assertXmlFileEqualsXmlFile(
  140. $this->basePath . 'renderer/' . $fileName,
  141. $this->tempDir . $fileName
  142. );
  143. }
  144. }
  145. ?>