StreamTest.php 3.0 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394
  1. <?php
  2. /**
  3. * Zend Framework
  4. *
  5. * LICENSE
  6. *
  7. * This source file is subject to the new BSD license that is bundled
  8. * with this package in the file LICENSE.txt.
  9. * It is also available through the world-wide-web at this URL:
  10. * http://framework.zend.com/license/new-bsd
  11. * If you did not receive a copy of the license and are unable to
  12. * obtain it through the world-wide-web, please send an email
  13. * to license@zend.com so we can send you a copy immediately.
  14. *
  15. * @category Zend
  16. * @package Zend_Pdf
  17. * @subpackage UnitTests
  18. * @copyright Copyright (c) 2005-2009 Zend Technologies USA Inc. (http://www.zend.com)
  19. * @license http://framework.zend.com/license/new-bsd New BSD License
  20. * @version $Id$
  21. */
  22. /**
  23. * Zend_Pdf_Element_Stream
  24. */
  25. require_once 'Zend/Pdf/Element/Stream.php';
  26. /**
  27. * PHPUnit Test Case
  28. */
  29. require_once 'PHPUnit/Framework/TestCase.php';
  30. /**
  31. * @category Zend
  32. * @package Zend_Pdf
  33. * @subpackage UnitTests
  34. * @copyright Copyright (c) 2005-2009 Zend Technologies USA Inc. (http://www.zend.com)
  35. * @license http://framework.zend.com/license/new-bsd New BSD License
  36. * @group Zend_Pdf
  37. */
  38. class Zend_Pdf_Element_StreamTest extends PHPUnit_Framework_TestCase
  39. {
  40. public function testPDFStream()
  41. {
  42. $streamObj = new Zend_Pdf_Element_Stream('some text');
  43. $this->assertTrue($streamObj instanceof Zend_Pdf_Element_Stream);
  44. }
  45. public function testGetType()
  46. {
  47. $streamObj = new Zend_Pdf_Element_Stream('some text');
  48. $this->assertEquals($streamObj->getType(), Zend_Pdf_Element::TYPE_STREAM);
  49. }
  50. public function testValueAccess()
  51. {
  52. $streamObj = new Zend_Pdf_Element_Stream("some text (\x00\x01\x02)\n");
  53. $this->assertEquals($streamObj->value->getRef(), "some text (\x00\x01\x02)\n");
  54. $valueRef = &$streamObj->value->getRef();
  55. $valueRef = "another text (\x02\x03\x04)\n";
  56. $streamObj->value->touch();
  57. $this->assertEquals($streamObj->value->getRef(), "another text (\x02\x03\x04)\n");
  58. }
  59. public function testToString()
  60. {
  61. $streamObj = new Zend_Pdf_Element_Stream("some text (\x00\x01\x02)\n");
  62. $this->assertEquals($streamObj->toString(), "stream\nsome text (\x00\x01\x02)\n\nendstream");
  63. }
  64. public function testLength()
  65. {
  66. $streamObj = new Zend_Pdf_Element_Stream("some text (\x00\x01\x02)\n");
  67. $this->assertEquals($streamObj->length(), 16);
  68. }
  69. public function testClear()
  70. {
  71. $streamObj = new Zend_Pdf_Element_Stream("some text (\x00\x01\x02)\n");
  72. $streamObj->clear();
  73. $this->assertEquals($streamObj->length(), 0);
  74. $this->assertEquals($streamObj->toString(), "stream\n\nendstream");
  75. }
  76. public function testAppend()
  77. {
  78. $streamObj = new Zend_Pdf_Element_Stream("some text (\x00\x01\x02)\n");
  79. $streamObj->append("something\xAF");
  80. $this->assertEquals($streamObj->length(), 16 + 10);
  81. $this->assertEquals($streamObj->toString(), "stream\nsome text (\x00\x01\x02)\nsomething\xAF\nendstream");
  82. }
  83. }