renderer_literallayout_tests.php 5.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151
  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 'renderer_text_box_base_tests.php';
  28. /**
  29. * Test suite for class.
  30. *
  31. * @package Document
  32. * @subpackage Tests
  33. */
  34. class ezcDocumentPdfLiterallayoutRendererTests extends ezcDocumentPdfTestCase
  35. {
  36. public static function suite()
  37. {
  38. return new PHPUnit_Framework_TestSuite( __CLASS__ );
  39. }
  40. public function setUp()
  41. {
  42. parent::setUp();
  43. $this->styles = new ezcDocumentPcssStyleInferencer();
  44. $this->styles->appendStyleDirectives( array(
  45. new ezcDocumentPcssLayoutDirective(
  46. array( 'page' ),
  47. array(
  48. 'page-size' => 'TEST',
  49. 'margin' => '0',
  50. 'padding' => '10',
  51. )
  52. ),
  53. new ezcDocumentPcssLayoutDirective(
  54. array( 'literallayout' ),
  55. array(
  56. 'font-size' => '6mm',
  57. )
  58. ),
  59. ) );
  60. }
  61. public function testRenderLiterallayout()
  62. {
  63. // Additional formatting
  64. $mock = $this->getMock( 'ezcTestDocumentPdfMockDriver', array(
  65. 'createPage',
  66. 'drawWord',
  67. ) );
  68. // Expectations
  69. $mock->expects( $this->at( 0 ) )->method( 'createPage' )->with(
  70. $this->equalTo( 100, 1. ), $this->equalTo( 100, 1. )
  71. );
  72. $mock->expects( $this->at( 1 ) )->method( 'drawWord' )->with(
  73. $this->equalTo( 12, 1. ), $this->equalTo( 18, 1. ), $this->equalTo( " " )
  74. );
  75. $mock->expects( $this->at( 2 ) )->method( 'drawWord' )->with(
  76. $this->equalTo( 24, 1. ), $this->equalTo( 18, 1. ), $this->equalTo( "public" )
  77. );
  78. $mock->expects( $this->at( 9 ) )->method( 'drawWord' )->with(
  79. $this->equalTo( 12, 1. ), $this->equalTo( 34.8, 1. ), $this->equalTo( " " )
  80. );
  81. $mock->expects( $this->at( 10 ) )->method( 'drawWord' )->with(
  82. $this->equalTo( 24, 1. ), $this->equalTo( 34.8, 1. ), $this->equalTo( "{" )
  83. );
  84. $mock->expects( $this->at( 11 ) )->method( 'drawWord' )->with(
  85. $this->equalTo( 12, 1. ), $this->equalTo( 43.2, 1. ), $this->equalTo( " " )
  86. );
  87. $docbook = new ezcDocumentDocbook();
  88. $docbook->loadFile( dirname( __FILE__ ) . '/../files/pdf/literallayout_short.xml' );
  89. $renderer = new ezcDocumentPdfMainRenderer( $mock, $this->styles );
  90. $pdf = $renderer->render(
  91. $docbook,
  92. new ezcDocumentPdfDefaultHyphenator()
  93. );
  94. }
  95. public function testRenderLiterallayoutWrapped()
  96. {
  97. // Additional formatting
  98. $mock = $this->getMock( 'ezcTestDocumentPdfMockDriver', array(
  99. 'createPage',
  100. 'drawWord',
  101. 'drawPolygon',
  102. 'drawPolyline',
  103. ) );
  104. // Expectations
  105. $mock->expects( $this->at( 0 ) )->method( 'createPage' )->with(
  106. $this->equalTo( 100, 1. ), $this->equalTo( 100, 1. )
  107. );
  108. $mock->expects( $this->at( 5 ) )->method( 'drawWord' )->with(
  109. $this->equalTo( 12, 1. ), $this->equalTo( 18, 1. ), $this->equalTo( "1" )
  110. );
  111. $mock->expects( $this->at( 13 ) )->method( 'drawWord' )->with(
  112. $this->equalTo( 12, 1. ), $this->equalTo( 85.2, 1. ), $this->equalTo( "9" )
  113. );
  114. $mock->expects( $this->at( 14 ) )->method( 'createPage' )->with(
  115. $this->equalTo( 100, 1. ), $this->equalTo( 100, 1. )
  116. );
  117. $mock->expects( $this->at( 27 ) )->method( 'createPage' )->with(
  118. $this->equalTo( 100, 1. ), $this->equalTo( 100, 1. )
  119. );
  120. $mock->expects( $this->at( 32 ) )->method( 'drawWord' )->with(
  121. $this->equalTo( 12, 1. ), $this->equalTo( 18, 1. ), $this->equalTo( "9" )
  122. );
  123. $mock->expects( $this->at( 33 ) )->method( 'drawWord' )->with(
  124. $this->equalTo( 12, 1. ), $this->equalTo( 26.4, 1. ), $this->equalTo( "0" )
  125. );
  126. $docbook = new ezcDocumentDocbook();
  127. $docbook->loadFile( dirname( __FILE__ ) . '/../files/pdf/literallayout_long.xml' );
  128. $renderer = new ezcDocumentPdfMainRenderer( $mock, $this->styles );
  129. $pdf = $renderer->render(
  130. $docbook,
  131. new ezcDocumentPdfDefaultHyphenator()
  132. );
  133. }
  134. }
  135. ?>