/[drupal]/contributions/modules/pbs/pbs.test
ViewVC logotype

Diff of /contributions/modules/pbs/pbs.test

Parent Directory Parent Directory | Revision Log Revision Log | View Revision Graph Revision Graph | View Patch Patch

revision 1.11, Tue Sep 8 21:39:42 2009 UTC revision 1.12, Fri Oct 16 02:33:00 2009 UTC
# Line 1  Line 1 
1  <?php  <?php
2  // $Id: pbs.test,v 1.10 2009/09/08 19:21:42 bjaspan Exp $  // $Id: pbs.test,v 1.11 2009/09/08 21:39:42 bjaspan Exp $
   
 class PbsTestCase extends DrupalWebTestCase {  
   function getInfo() {  
     return array(  
       'name'  => t('Per-bundle Storage tests'),  
       'description'  => t("Test Per-bundle Storage module."),  
       'group' => t('Field')  
     );  
   }  
   
   function setUp() {  
     parent::setUp('field_sql_storage', 'field', 'field_test', 'pbs');  
   
     $this->entity_type = 'test_entity';  
     $this->fields = array();  
     $this->instances = array();  
   
     $this->createFieldAndInstance('card_1', 1);  
     $this->createFieldAndInstance('card_4', 4);  
     $this->createFieldAndInstance('card_unlim', FIELD_CARDINALITY_UNLIMITED);  
   }  
3    
4    class PbsBaseTestCase extends DrupalWebTestCase {
5    function createFieldAndInstance($name, $cardinality, $bundle = 'test_bundle') {    function createFieldAndInstance($name, $cardinality, $bundle = 'test_bundle') {
6      $field = array('field_name' => $name, 'type' => 'test_field', 'cardinality' => $cardinality);      $field = array('field_name' => $name, 'type' => 'test_field', 'cardinality' => $cardinality);
7      $this->fields[$name] = field_create_field($field);      $this->fields[$name] = field_create_field($field);
# Line 85  class PbsTestCase extends DrupalWebTestC Line 65  class PbsTestCase extends DrupalWebTestC
65    
66      return $revisions;      return $revisions;
67    }    }
68    }
69    
70    class PbsInitializeTestCase extends PbsBaseTestCase {
71      function getInfo() {
72        return array(
73          'name'  => t('Per-bundle Storage initialization tests'),
74          'description'  => t("Test Per-bundle Storage module initialization from existing per-field storage tables."),
75          'group' => t('Field')
76        );
77      }
78    
79      function setUp() {
80        parent::setUp('field_test');
81    
82        $this->entity_type = 'test_entity';
83        $this->fields = array();
84        $this->instances = array();
85    
86        $this->createFieldAndInstance('card_1', 1);
87        $this->createFieldAndInstance('card_4', 4);
88        $this->createFieldAndInstance('card_unlim', FIELD_CARDINALITY_UNLIMITED);
89      }
90    }
91    
92    class PbsTestCase extends PbsBaseTestCase {
93      function getInfo() {
94        return array(
95          'name'  => t('Per-bundle Storage tests'),
96          'description'  => t("Test Per-bundle Storage module."),
97          'group' => t('Field')
98        );
99      }
100    
101      function setUp() {
102        parent::setUp('field_test', 'pbs');
103    
104        $this->entity_type = 'test_entity';
105        $this->fields = array();
106        $this->instances = array();
107    
108        $this->createFieldAndInstance('card_1', 1);
109        $this->createFieldAndInstance('card_4', 4);
110        $this->createFieldAndInstance('card_unlim', FIELD_CARDINALITY_UNLIMITED);
111      }
112    
113    function testFieldAttachInsert() {    function testFieldAttachInsert() {
114      // Create 5 entities.      // Create 5 entities.
# Line 114  class PbsTestCase extends DrupalWebTestC Line 138  class PbsTestCase extends DrupalWebTestC
138          }          }
139        }        }
140        else {        else {
141          $count = db_result(db_query('SELECT COUNT(*) FROM {'._field_sql_storage_tablename($field).'}'));          $count = db_query('SELECT COUNT(*) FROM {'._field_sql_storage_tablename($field).'}')->fetchField();
142          $this->assertEqual($count, 0, "No data written to per-field table for limited-cardinality field {$field_name}");          $this->assertEqual($count, 0, "No data written to per-field table for limited-cardinality field {$field_name}");
143        }        }
144      }      }
# Line 180  class PbsTestCase extends DrupalWebTestC Line 204  class PbsTestCase extends DrupalWebTestC
204      $entity2 = $this->createEntities(1, 'shared_test');      $entity2 = $this->createEntities(1, 'shared_test');
205    
206      // Verify that data from both entities is in the shared table      // Verify that data from both entities is in the shared table
207      $count = db_result(db_query('SELECT COUNT(*) FROM {'._field_sql_storage_tablename($this->fields['card_4']).'}'));      $count = db_query('SELECT COUNT(*) FROM {'._field_sql_storage_tablename($this->fields['card_4']).'}')->fetchField();
208      $this->assertEqual($count, 8, 'All values written to per-field table.');      $this->assertEqual($count, 8, 'All values written to per-field table.');
209    
210      // Verify that data from both entities is in the appropriate      // Verify that data from both entities is in the appropriate
211      // per-bundle table.      // per-bundle table.
212      $count = db_result(db_query('SELECT COUNT(*) FROM {'.pbs_tablename('test_bundle').'}'));      $count = db_query('SELECT COUNT(*) FROM {'.pbs_tablename('test_bundle').'}')->fetchField();
213      $this->assertEqual($count, 1, 'Values written to per-bundle table.');      $this->assertEqual($count, 1, 'Values written to per-bundle table.');
214      $count = db_result(db_query('SELECT COUNT(*) FROM {'.pbs_tablename('shared_test').'}'));      $count = db_query('SELECT COUNT(*) FROM {'.pbs_tablename('shared_test').'}')->fetchField();
215      $this->assertEqual($count, 1, 'Values written to per-bundle table.');      $this->assertEqual($count, 1, 'Values written to per-bundle table.');
216    }    }
217    

Legend:
Removed from v.1.11  
changed lines
  Added in v.1.12

  ViewVC Help
Powered by ViewVC 1.1.2