NumericTest.php 1.7 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071
  1. <?php
  2. /**
  3. * @package Zend_Pdf
  4. * @subpackage UnitTests
  5. */
  6. /**
  7. * Zend_Pdf_Element_Numeric
  8. */
  9. require_once 'Zend/Pdf/Element/Numeric.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_NumericTest extends PHPUnit_Framework_TestCase
  19. {
  20. public function testPDFNumeric()
  21. {
  22. $intObj = new Zend_Pdf_Element_Numeric(100);
  23. $this->assertTrue($intObj instanceof Zend_Pdf_Element_Numeric);
  24. }
  25. public function testPDFNumericBadArgument()
  26. {
  27. try {
  28. $intObj = new Zend_Pdf_Element_Numeric('some input');
  29. } catch (Zend_Pdf_Exception $e) {
  30. $this->assertRegExp('/must be numeric/i', $e->getMessage());
  31. return;
  32. }
  33. $this->fail('Expected Zend_Pdf_Exception to be thrown');
  34. }
  35. public function testGetType()
  36. {
  37. $intObj = new Zend_Pdf_Element_Numeric(100);
  38. $this->assertEquals($intObj->getType(), Zend_Pdf_Element::TYPE_NUMERIC);
  39. }
  40. public function testToString()
  41. {
  42. $intObj = new Zend_Pdf_Element_Numeric(100);
  43. $this->assertEquals($intObj->toString(), '100');
  44. }
  45. public function testToStringFloat1()
  46. {
  47. $intObj = new Zend_Pdf_Element_Numeric(100.426);
  48. $this->assertEquals($intObj->toString(), '100.426');
  49. }
  50. public function testToStringFloat2()
  51. {
  52. $intObj = new Zend_Pdf_Element_Numeric(100.42633);
  53. $this->assertEquals($intObj->toString(), '100.42633');
  54. }
  55. public function testToStringFloat3()
  56. {
  57. $intObj = new Zend_Pdf_Element_Numeric(-100.426);
  58. $this->assertEquals($intObj->toString(), '-100.426');
  59. }
  60. }