eZ components PHP Cross Reference Developer Tools

Source: /TreeDatabaseTiein/tests/db_parent_child_tree.php - 81 lines - 2148 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  
  14  /**
  15   * @package TreeDatabaseTiein
  16   * @subpackage Tests
  17   */
  18  class ezcTreeDbParentChildTest extends ezcDbTreeTest
  19  {
  20      private $tempDir;
  21  
  22      protected $tables  = array( 'parent_child', 'data', 'datam' );
  23      protected $schemaName = 'parent_child.dba';
  24  
  25      public function insertData()
  26      {
  27          // insert test data
  28          $data = array(
  29              // child -> parent
  30              1 => 'null',
  31              2 => 1,
  32              3 => 1,
  33              4 => 1,
  34              6 => 4,
  35              7 => 6,
  36              8 => 6,
  37              5 => 1,
  38              9 => 5
  39          );
  40          foreach( $data as $childId => $parentId )
  41          {
  42              $this->dbh->exec( "INSERT INTO parent_child(id, parent_id) VALUES( $childId, $parentId )" );
  43          }
  44  
  45          // add data
  46          for ( $i = 1; $i <= 8; $i++ )
  47          {
  48              $this->dbh->exec( "INSERT INTO data(id, data) values ( $i, 'Node $i' )" );
  49          }
  50      }
  51  
  52      protected function setUpEmptyTestTree( $dataTable = 'data', $dataField = 'data', $indexTableSuffix = '' )
  53      {
  54          $store = new ezcTreeDbExternalTableDataStore( $this->dbh, $dataTable, 'id', $dataField );
  55          $tree = ezcTreeDbParentChild::create(
  56              $this->dbh,
  57              'parent_child' . $indexTableSuffix,
  58              $store
  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 ezcTreeDbParentChild(
  68              $this->dbh,
  69              'parent_child' . $indexTableSuffix,
  70              $store
  71          );
  72          return $tree;
  73      }
  74  
  75      public static function suite()
  76      {
  77           return new PHPUnit_Framework_TestSuite( "ezcTreeDbParentChildTest" );
  78      }
  79  }
  80  
  81  ?>

title

Description

title

Description

title

Description

title

title

Body