LockedTest.php 2.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105
  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_Memory
  17. * @subpackage UnitTests
  18. * @copyright Copyright (c) 2005-2008 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. * Test helper
  24. */
  25. require_once dirname(__FILE__) . '/../../TestHelper.php';
  26. /** Zend_Memory */
  27. require_once 'Zend/Memory.php';
  28. /**
  29. * @category Zend
  30. * @package Zend_Memory
  31. * @subpackage UnitTests
  32. * @copyright Copyright (c) 2005-2008 Zend Technologies USA Inc. (http://www.zend.com)
  33. * @license http://framework.zend.com/license/new-bsd New BSD License
  34. */
  35. class Zend_Memory_Container_LockedTest extends PHPUnit_Framework_TestCase
  36. {
  37. /**
  38. * tests the Movable memory container object creation
  39. */
  40. public function testCreation()
  41. {
  42. $memObject = new Zend_Memory_Container_Locked('0123456789');
  43. $this->assertTrue($memObject instanceof Zend_Memory_Container_Locked);
  44. }
  45. /**
  46. * tests the value access methods
  47. */
  48. public function testValueAccess()
  49. {
  50. $memObject = new Zend_Memory_Container_Locked('0123456789');
  51. // getRef() method
  52. $this->assertEquals($memObject->getRef(), '0123456789');
  53. $valueRef = &$memObject->getRef();
  54. $valueRef[3] = '_';
  55. $this->assertEquals($memObject->getRef(), '012_456789');
  56. // value property
  57. $this->assertEquals((string)$memObject->value, '012_456789');
  58. $memObject->value[7] = '_';
  59. $this->assertEquals((string)$memObject->value, '012_456_89');
  60. $memObject->value = 'another value';
  61. $this->assertEquals((string)$memObject->value, 'another value');
  62. }
  63. /**
  64. * tests lock()/unlock()/isLocked() functions
  65. */
  66. public function testLock()
  67. {
  68. $memObject = new Zend_Memory_Container_Locked('0123456789');
  69. // It's always locked
  70. $this->assertTrue((boolean)$memObject->isLocked());
  71. $memObject->lock();
  72. $this->assertTrue((boolean)$memObject->isLocked());
  73. $memObject->unlock();
  74. // It's always locked
  75. $this->assertTrue((boolean)$memObject->isLocked());
  76. }
  77. /**
  78. * tests the touch() method
  79. */
  80. public function testTouch()
  81. {
  82. $memObject = new Zend_Memory_Container_Locked('0123456789');
  83. $memObject->touch();
  84. // Nothing to check
  85. }
  86. }