eZ components PHP Cross Reference Developer Tools

Source: /TreeDatabaseTiein/tests/db_materialized_path_tree_diff_separator.php - 96 lines - 2890 bytes - Summary - Text - Print

   1  <?php
   2  /**
   3   * @copyright Copyright (C) 2005-2008 eZ systems as. All rights reserved.
   4   * @license http://ez.no/licenses/new_bsd New BSD License
   5   * @version 1.1.1
   6   * @filesource
   7   * @package TreeDatabaseTiein
   8   * @subpackage Tests
   9   */
  10  
  11  require_once  'Tree/tests/tree.php';
  12  require_once  'db_tree.php';
  13  require_once  'db_materialized_path_tree.php';
  14  
  15  /**
  16   * @package TreeDatabaseTiein
  17   * @subpackage Tests
  18   */
  19  class ezcTreeDbMaterializedPathTestWithDifferentSeparator extends ezcTreeDbMaterializedPathTest
  20  {
  21      private $tempDir;
  22  
  23      public function insertData()
  24      {
  25          // insert test data
  26          $data = array(
  27              // child -> parent
  28              1 => array( 'null', '@1' ),
  29              2 => array(      1, '@1@2' ),
  30              3 => array(      1, '@1@3' ),
  31              4 => array(      1, '@1@4' ),
  32              6 => array(      4, '@1@4@6' ),
  33              7 => array(      6, '@1@4@6@7' ),
  34              8 => array(      6, '@1@4@6@8' ),
  35              5 => array(      1, '@1@5' ),
  36              9 => array(      5, '@1@5@9' ),
  37          );
  38          foreach( $data as $childId => $details )
  39          {
  40              list( $parentId, $path ) = $details;
  41              $this->dbh->exec( "INSERT INTO materialized_path(id, parent_id, path) VALUES( $childId, $parentId, '$path' )" );
  42          }
  43  
  44          // add data
  45          for ( $i = 1; $i <= 8; $i++ )
  46          {
  47              $this->dbh->exec( "INSERT INTO data(id, data) values ( $i, 'Node $i' )" );
  48          }
  49      }
  50  
  51      protected function setUpEmptyTestTree( $dataTable = 'data', $dataField = 'data', $indexTableSuffix = '' )
  52      {
  53          $store = new ezcTreeDbExternalTableDataStore( $this->dbh, $dataTable, 'id', $dataField );
  54          $tree = ezcTreeDbMaterializedPath::create(
  55              $this->dbh,
  56              'materialized_path' . $indexTableSuffix,
  57              $store,
  58              '@'
  59          );
  60          $this->emptyTables();
  61          return $tree;
  62      }
  63  
  64      protected function setUpTestTree( $dataTable = 'data', $dataField = 'data', $indexTableSuffix = '' )
  65      {
  66          $store = new ezcTreeDbExternalTableDataStore( $this->dbh, $dataTable, 'id', $dataField );
  67          $tree = new ezcTreeDbMaterializedPath(
  68              $this->dbh,
  69              'materialized_path' . $indexTableSuffix,
  70              $store,
  71              '@'
  72          );
  73          return $tree;
  74      }
  75  
  76      public function testWithWrongSeparationChar()
  77      {
  78          $store = new ezcTreeDbExternalTableDataStore( $this->dbh, 'data', 'id', 'data' );
  79          $tree = new ezcTreeDbMaterializedPath(
  80              $this->dbh,
  81              'materialized_path',
  82              $store,
  83              '$'
  84          );
  85  
  86          $nodeList = $tree->fetchNodeById( 4 )->fetchSubtree();
  87          self::assertSame( 1, $nodeList->size );
  88      }
  89  
  90      public static function suite()
  91      {
  92           return new PHPUnit_Framework_TestSuite( "ezcTreeDbMaterializedPathTestWithDifferentSeparator" );
  93      }
  94  }
  95  
  96  ?>

title

Description

title

Description

title

Description

title

title

Body