コード例 #1
0
 /** {@inheritdoc} */
 protected function _loadDataSet($testName = null)
 {
     // Get current time from database as reference point for all operations.
     $this->_currentTimestamp = new \DateTime($this->getConnection()->createQueryTable('current', 'SELECT CURRENT_TIMESTAMP AS current')->getValue(0, 'current'), new \DateTimeZone('UTC'));
     $dataSet = parent::_loadDataSet($testName);
     $locks = $dataSet->getTable('locks');
     if ($locks) {
         // Replace offsets with timestamps (current - offset)
         $count = $locks->getRowCount();
         $replacement = new \PHPUnit_Extensions_Database_DataSet_ReplacementDataSet($dataSet);
         for ($i = 0; $i < $count; $i++) {
             $offset = $locks->getValue($i, 'since');
             $interval = new \DateInterval(sprintf('PT%dS', trim($offset, '#')));
             $since = clone $this->_currentTimestamp;
             $since->sub($interval);
             $replacement->addFullReplacement($offset, $since->format('Y-m-d H:i:s'));
         }
         return $replacement;
     } else {
         return $dataSet;
     }
 }