コード例 #1
0
ファイル: BaseBench.php プロジェクト: phpcr/phpcr-benchmarks
 protected function getLoader()
 {
     if ($this->loader) {
         return $this->loader;
     }
     $this->loader = \ImplementationLoader::getInstance();
     return $this->loader;
 }
コード例 #2
0
 public static function setUpBeforeClass()
 {
     parent::setUpBeforeClass();
     self::$loader = \ImplementationLoader::getInstance();
     $session = self::$loader->getSession(self::$loader->getCredentials());
     if ($session->nodeExists('/node-a')) {
         $session->removeItem('/node-a');
     }
     if ($session->nodeExists('/node-b')) {
         $session->removeItem('/node-b');
     }
     $session->save();
     $a = $session->getNode('/')->addNode('node-a');
     $a->addNode('child-a')->setProperty('prop', 'aa');
     $a->addNode('child-b')->setProperty('prop', 'ab');
     $b = $session->getNode('/')->addNode('node-b');
     $b->addNode('child-a')->setProperty('prop', 'ba');
     $b->addNode('child-b')->setProperty('prop', 'bb');
     $session->save();
 }
コード例 #3
0
ファイル: Generic.php プロジェクト: nikophil/cmf-tests
 public function import($fixtureName, $workspace = null)
 {
     $fixture = $this->fixturePath . DIRECTORY_SEPARATOR . $fixtureName . '.xml';
     $this->setDataSet(new \PHPUnit_Extensions_Database_DataSet_XmlDataSet($fixture));
     if ($workspace) {
         $dataSet = $this->getDataSet();
         // TODO: ugly hack, since we only really ever load a 2nd fixture in combination with '10_Writing/copy.xml'
         $fixture = $this->fixturePath . DIRECTORY_SEPARATOR . '10_Writing/copy.xml';
         $this->setDataSet(new \PHPUnit_Extensions_Database_DataSet_XmlDataSet($fixture));
         $loader = \ImplementationLoader::getInstance();
         $workspaceName = $loader->getOtherWorkspaceName();
         $this->dataSet->getTable('phpcr_workspaces')->addRow(array('name' => $workspaceName));
         foreach (array('phpcr_nodes', 'phpcr_binarydata') as $tableName) {
             $table = $dataSet->getTable($tableName);
             $targetTable = $this->dataSet->getTable($tableName);
             for ($i = 0; $i < $table->getRowCount(); $i++) {
                 $row = $table->getRow($i);
                 $row['workspace_name'] = $workspaceName;
                 $targetTable->addRow($row);
             }
         }
     }
     $this->onSetUp();
 }
コード例 #4
0
 /**
  * we use this place to fetch a session and possibly load fixtures.
  *
  * this speeds up the tests considerably as fixture loading can be
  * quite expensive
  *
  * @param string $fixtures the fixtures name to import, defaults to
  *      general/base. if you want to load fixtures yourself, send false
  *
  * @see initProperties()
  */
 public static function setupBeforeClass($fixtures = 'general/base')
 {
     self::$loader = \ImplementationLoader::getInstance();
     $fqn = get_called_class();
     list($phpcr, $tests, $chapter, $case) = explode('\\', $fqn);
     $case = "{$chapter}\\{$case}";
     if (!self::$loader->getTestSupported($chapter, $case, null)) {
         throw new \PHPUnit_Framework_SkippedTestSuiteError('Test case not supported by this implementation');
     }
     self::$staticSharedFixture = array();
     date_default_timezone_set('Europe/Zurich');
     //TODO put this here?
     self::$staticSharedFixture['ie'] = self::$loader->getFixtureLoader();
     if ($fixtures) {
         self::$staticSharedFixture['ie']->import($fixtures);
     }
     // only load sessions once fixtures have been imported (relevant i.e. for jackalope-doctrine-dbal)
     self::$staticSharedFixture['session'] = self::$loader->getSession();
     self::$staticSharedFixture['additionalSession'] = self::$loader->getAdditionalSession();
 }