Пример #1
0
 private function getCacheDom()
 {
     if ($this->cacheDom === NULL) {
         $this->cacheDom = new fDOMDocument();
         $cacheFile = $this->config->getLogfilePath();
         if (file_exists($cacheFile)) {
             $this->cacheDom->load($cacheFile);
             $sha1 = $this->cacheDom->documentElement->getAttribute('sha1');
             $cwd = getcwd();
             chdir($this->config->getSourceDirectory());
             exec($this->config->getGitBinary() . ' diff --name-only ' . $sha1, $files, $rc);
             foreach ($files as $file) {
                 $fields = array('path' => dirname($file), 'file' => basename($file));
                 $query = $this->cacheDom->prepareQuery('//*[@path = :path and @file = :file]', $fields);
                 $node = $this->cacheDom->queryOne($query);
                 if (!$node) {
                     continue;
                 }
                 $node->parentNode->removeChild($node);
             }
             chdir($cwd);
         } else {
             $this->cacheDom->loadXML('<?xml version="1.0" ?><gitlog xmlns="' . self::GITNS . '" />');
             $this->cacheDom->documentElement->setAttribute('sha1', $this->commitSha1);
         }
     }
     return $this->cacheDom;
 }
Пример #2
0
 public function testPrepareQueryReturnsValidXPathString()
 {
     $values = array('key' => 'the "value" of \'values\'');
     $xpath = '//some[@value = :key]';
     $result = $this->dom->prepareQuery($xpath, $values);
     $this->assertEquals('//some[@value = concat("the ",\'"\',"value",\'"\'," of \'values\'")]', $result);
 }