cacert-testmgr/external/ZendFramework-1.9.5/tests/Zend/Pdf/Element/ObjectTest.php
Markus Warg 8398c9048d initially import ZendFramework-1.9.5 into repository
code was modified slightly, so the code differs from the original downloadable 1.9.5 version
2010-03-31 10:12:32 +02:00

149 lines
5.1 KiB
PHP

<?php
/**
* Zend Framework
*
* LICENSE
*
* This source file is subject to the new BSD license that is bundled
* with this package in the file LICENSE.txt.
* It is also available through the world-wide-web at this URL:
* http://framework.zend.com/license/new-bsd
* If you did not receive a copy of the license and are unable to
* obtain it through the world-wide-web, please send an email
* to license@zend.com so we can send you a copy immediately.
*
* @category Zend
* @package Zend_Pdf
* @subpackage UnitTests
* @copyright Copyright (c) 2005-2009 Zend Technologies USA Inc. (http://www.zend.com)
* @license http://framework.zend.com/license/new-bsd New BSD License
* @version $Id: ObjectTest.php 17363 2009-08-03 07:40:18Z bkarwin $
*/
/** Zend_Pdf_Element_Object */
require_once 'Zend/Pdf/Element/Object.php';
/** Zend_Pdf_Element_Numeric */
require_once 'Zend/Pdf/Element/Numeric.php';
/** PHPUnit Test Case */
require_once 'PHPUnit/Framework/TestCase.php';
/**
* @category Zend
* @package Zend_Pdf
* @subpackage UnitTests
* @copyright Copyright (c) 2005-2009 Zend Technologies USA Inc. (http://www.zend.com)
* @license http://framework.zend.com/license/new-bsd New BSD License
* @group Zend_Pdf
*/
class Zend_Pdf_Element_ObjectTest extends PHPUnit_Framework_TestCase
{
public function testPDFObject()
{
$intObj = new Zend_Pdf_Element_Numeric(100);
$obj = new Zend_Pdf_Element_Object($intObj, 1, 0, new Zend_Pdf_ElementFactory(1));
$this->assertTrue($obj instanceof Zend_Pdf_Element_Object);
}
public function testPDFObjectBadObjectType1()
{
$intObj = new Zend_Pdf_Element_Numeric(100);
$obj1 = new Zend_Pdf_Element_Object($intObj, 1, 0, new Zend_Pdf_ElementFactory(1));
try {
$obj2 = new Zend_Pdf_Element_Object($obj1, 1, 0, new Zend_Pdf_ElementFactory(1));
} catch (Zend_Pdf_Exception $e) {
$this->assertRegExp('/must not be an instance of Zend_Pdf_Element_Object/i', $e->getMessage());
return;
}
$this->fail('Expected Zend_Pdf_Exception to be thrown');
}
public function testPDFObjectBadGenNumber1()
{
try {
$intObj = new Zend_Pdf_Element_Numeric(100);
$obj = new Zend_Pdf_Element_Object($intObj, 1, -1, new Zend_Pdf_ElementFactory(1));
} catch (Zend_Pdf_Exception $e) {
$this->assertRegExp('/non-negative integer/i', $e->getMessage());
return;
}
$this->fail('Expected Zend_Pdf_Exception to be thrown');
}
public function testPDFObjectBadGenNumber2()
{
try {
$intObj = new Zend_Pdf_Element_Numeric(100);
$obj = new Zend_Pdf_Element_Object($intObj, 1, 1.2, new Zend_Pdf_ElementFactory(1));
} catch (Zend_Pdf_Exception $e) {
$this->assertRegExp('/non-negative integer/i', $e->getMessage());
return;
}
$this->fail('Expected Zend_Pdf_Exception to be thrown');
}
public function testPDFObjectBadObjectNumber1()
{
try {
$intObj = new Zend_Pdf_Element_Numeric(100);
$obj = new Zend_Pdf_Element_Object($intObj, 0, 0, new Zend_Pdf_ElementFactory(1));
} catch (Zend_Pdf_Exception $e) {
$this->assertRegExp('/positive integer/i', $e->getMessage());
return;
}
$this->fail('Expected Zend_Pdf_Exception to be thrown');
}
public function testPDFObjectBadObjectNumber2()
{
try {
$intObj = new Zend_Pdf_Element_Numeric(100);
$obj = new Zend_Pdf_Element_Object($intObj, -1, 0, new Zend_Pdf_ElementFactory(1));
} catch (Zend_Pdf_Exception $e) {
$this->assertRegExp('/positive integer/i', $e->getMessage());
return;
}
$this->fail('Expected Zend_Pdf_Exception to be thrown');
}
public function testPDFObjectBadObjectNumber3()
{
try {
$intObj = new Zend_Pdf_Element_Numeric(100);
$obj = new Zend_Pdf_Element_Object($intObj, 1.2, 0, new Zend_Pdf_ElementFactory(1));
} catch (Zend_Pdf_Exception $e) {
$this->assertRegExp('/positive integer/i', $e->getMessage());
return;
}
$this->fail('Expected Zend_Pdf_Exception to be thrown');
}
public function testGetType()
{
$intObj = new Zend_Pdf_Element_Numeric(100);
$obj = new Zend_Pdf_Element_Object($intObj, 1, 0, new Zend_Pdf_ElementFactory(1));
$this->assertEquals($obj->getType(), $intObj->getType());
}
public function testToString()
{
$intObj = new Zend_Pdf_Element_Numeric(100);
$obj = new Zend_Pdf_Element_Object($intObj, 55, 3, new Zend_Pdf_ElementFactory(1));
$this->assertEquals($obj->toString(), '55 3 R');
}
public function testDump()
{
$factory = new Zend_Pdf_ElementFactory(1);
$intObj = new Zend_Pdf_Element_Numeric(100);
$obj = new Zend_Pdf_Element_Object($intObj, 55, 3, $factory);
$this->assertEquals($obj->dump($factory), "55 3 obj \n100\nendobj\n");
}
}