コード例 #1
0
ファイル: MemoryManagerTest.php プロジェクト: ravids/zf2
 public function testNotEnoughSpaceThrowException()
 {
     $memoryManager = new Memory\MemoryManager($this->_cache);
     $memoryManager->setMinSize(128);
     $memoryManager->setMemoryLimit(1024);
     $memObjects = array();
     for ($count = 0; $count < 8; $count++) {
         $memObject = $memoryManager->create(str_repeat((string) ($count % 10), 128));
         $memObjects[] = $memObject;
     }
     $this->setExpectedException('Zend\\Memory\\Exception\\RuntimeException');
     $memoryManager->create('a');
 }
コード例 #2
0
 /**
  * tests the processing of data
  */
 public function testProcessing()
 {
     $memoryManager = new Memory\MemoryManager($this->_cache);
     $memoryManager->setMinSize(256);
     $memoryManager->setMemoryLimit(1024 * 32);
     $memObjects = array();
     for ($count = 0; $count < 64; $count++) {
         $memObject = $memoryManager->create(str_repeat((string) ($count % 10), 1024));
         $memObjects[] = $memObject;
     }
     for ($count = 0; $count < 64; $count += 2) {
         if (version_compare(PHP_VERSION, '5.2') < 0) {
             $value = $memObjects[$count]->getRef();
             $this->assertEquals($value[16], (string) ($count % 10));
         } else {
             $this->assertEquals($memObjects[$count]->value[16], (string) ($count % 10));
         }
     }
     for ($count = 63; $count > 0; $count -= 2) {
         if (version_compare(PHP_VERSION, '5.2') < 0) {
             $value =& $memObjects[$count]->getRef();
             $value[16] = '_';
         } else {
             $memObjects[$count]->value[16] = '_';
         }
     }
     for ($count = 1; $count < 64; $count += 2) {
         if (version_compare(PHP_VERSION, '5.2') < 0) {
             $value = $memObjects[$count]->getRef();
             $this->assertEquals($value[16], '_');
         } else {
             $this->assertEquals($memObjects[$count]->value[16], '_');
         }
     }
 }