ZF-8222: format class name for class checks
[zend.git] / tests / Zend / Memory / ValueTest.php
blobdd3ddff5be60e9d3d75e4386e50b152c8b2fc9d9
1 <?php
2 /**
3 * Zend Framework
5 * LICENSE
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.
15 * @category Zend
16 * @package Zend_Memory
17 * @subpackage UnitTests
18 * @copyright Copyright (c) 2005-2010 Zend Technologies USA Inc. (http://www.zend.com)
19 * @license http://framework.zend.com/license/new-bsd New BSD License
20 * @version $Id$
23 /**
24 * Test helper
26 require_once dirname(__FILE__) . '/../../TestHelper.php';
28 /** Zend_Memory */
29 require_once 'Zend/Memory.php';
31 /**
32 * @category Zend
33 * @package Zend_Memory
34 * @subpackage UnitTests
35 * @copyright Copyright (c) 2005-2010 Zend Technologies USA Inc. (http://www.zend.com)
36 * @license http://framework.zend.com/license/new-bsd New BSD License
38 class Zend_Memory_Container_Movable_Dummy extends Zend_Memory_Container_Movable
40 /**
41 * Dummy object constructor
43 public function __construct()
45 // Do nothing
48 /**
49 * Dummy value update callback method
51 public function processUpdate()
53 // Do nothing
58 /**
59 * @category Zend
60 * @package Zend_Memory
61 * @subpackage UnitTests
62 * @copyright Copyright (c) 2005-2010 Zend Technologies USA Inc. (http://www.zend.com)
63 * @license http://framework.zend.com/license/new-bsd New BSD License
64 * @group Zend_Memory
66 class Zend_Memory_ValueTest extends PHPUnit_Framework_TestCase
68 /**
69 * tests the Value object creation
71 public function testCreation()
73 $valueObject = new Zend_Memory_Value('data data data ...', new Zend_Memory_Container_Movable_Dummy());
74 $this->assertTrue($valueObject instanceof Zend_Memory_Value);
75 $this->assertEquals($valueObject->getRef(), 'data data data ...');
79 /**
80 * tests the value reference retrieval
82 public function testGetRef()
84 $valueObject = new Zend_Memory_Value('0123456789', new Zend_Memory_Container_Movable_Dummy());
85 $valueRef = &$valueObject->getRef();
86 $valueRef[3] = '_';
88 $this->assertEquals($valueObject->getRef(), '012_456789');
92 /**
93 * tests the __toString() functionality
95 public function testToString()
97 $valueObject = new Zend_Memory_Value('0123456789', new Zend_Memory_Container_Movable_Dummy());
98 $this->assertEquals($valueObject->__toString(), '0123456789');
100 if (version_compare(PHP_VERSION, '5.2') < 0) {
101 // Skip following tests for PHP versions before 5.2
102 return;
105 $this->assertEquals(strlen($valueObject), 10);
106 $this->assertEquals((string)$valueObject, '0123456789');
110 * tests the access through ArrayAccess methods
112 public function testArrayAccess()
114 if (version_compare(PHP_VERSION, '5.2') < 0) {
115 // Skip following tests for PHP versions before 5.2
116 return;
119 $valueObject = new Zend_Memory_Value('0123456789', new Zend_Memory_Container_Movable_Dummy());
120 $this->assertEquals($valueObject[8], '8');
122 $valueObject[2] = '_';
123 $this->assertEquals((string)$valueObject, '01_3456789');
126 $error_level = error_reporting();
127 error_reporting($error_level & ~E_NOTICE);
128 $valueObject[10] = '_';
129 $this->assertEquals((string)$valueObject, '01_3456789_');
130 error_reporting($error_level);