LockedTest.php 2.8 KB

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