Based in large part on the example at http://www.php.net/manual/en/function.stream-wrapper-register.php
Example #1
0
function glob($pattern, $flags = 0)
{
    Stream::register();
    if (preg_match('~\\.sql$~', $pattern)) {
        $content = trim(file_get_contents('zend.view://test-updater'));
        if (empty($content)) {
            return false;
        }
        return array('zend.view://test-updater');
    }
    $scriptPath = GC_APPLICATION_PATH . '/tests/library/Gc/Core/_files/test.php';
    if (file_exists($scriptPath) and in_array($pattern, array(GC_APPLICATION_PATH . '/data/update/*', '999/*.php'))) {
        $content = file_get_contents($scriptPath);
        if ($pattern == GC_APPLICATION_PATH . '/data/update/*') {
            if (empty($content)) {
                return array('0');
            }
            return array(999);
        } else {
            if (empty($content)) {
                return array();
            }
            return array($scriptPath);
        }
    }
    return array('9999.999.999');
}
Example #2
0
 /**
  * Test
  *
  * @return void
  */
 public function testUpdateDatabaseWithSqlError()
 {
     Stream::register();
     file_put_contents('zend.view://test-updater', 'SELECT something FROM core_config_data');
     $this->object->load('git');
     $configuration = Registry::get('Application')->getServiceManager()->get('Config');
     $this->assertFalse($this->object->updateDatabase($configuration, GlobalAdapterFeature::getStaticAdapter()));
 }