LockedTest.php 2.8 KB

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