BinaryTest.php 1.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657
  1. <?php
  2. /**
  3. * @package Zend_Pdf
  4. * @subpackage UnitTests
  5. */
  6. /**
  7. * Zend_Pdf_Element_String_Binary
  8. */
  9. require_once 'Zend/Pdf/Element/String/Binary.php';
  10. /**
  11. * PHPUnit Test Case
  12. */
  13. require_once 'PHPUnit/Framework/TestCase.php';
  14. /**
  15. * @package Zend_Pdf
  16. * @subpackage UnitTests
  17. */
  18. class Zend_Pdf_Element_String_BinaryTest extends PHPUnit_Framework_TestCase
  19. {
  20. public function testPDFBinaryString()
  21. {
  22. $stringObj = new Zend_Pdf_Element_String_Binary('some text');
  23. $this->assertTrue($stringObj instanceof Zend_Pdf_Element_String_Binary);
  24. }
  25. public function testGetType()
  26. {
  27. $stringObj = new Zend_Pdf_Element_String_Binary('some text');
  28. $this->assertEquals($stringObj->getType(), Zend_Pdf_Element::TYPE_STRING);
  29. }
  30. public function testToString()
  31. {
  32. $stringObj = new Zend_Pdf_Element_String_Binary("\x00\x01\x02\x03\x04\x05\x06\x07\x22\xFF\xF3");
  33. $this->assertEquals($stringObj->toString(), '<000102030405060722FFF3>');
  34. }
  35. public function testEscape()
  36. {
  37. $this->assertEquals(Zend_Pdf_Element_String_Binary::escape("\n\r\t\x08\x0C()\\"), '0A0D09080C28295C');
  38. }
  39. public function testUnescape1()
  40. {
  41. $this->assertEquals(Zend_Pdf_Element_String_Binary::unescape('01020304FF20'), "\x01\x02\x03\x04\xFF ");
  42. }
  43. public function testUnescape2()
  44. {
  45. $this->assertEquals(Zend_Pdf_Element_String_Binary::unescape('01020304FF2'), "\x01\x02\x03\x04\xFF ");
  46. }
  47. }