/[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.9, Tue Sep 8 17:48:00 2009 UTC revision 1.10, Tue Sep 8 19:21:42 2009 UTC
# Line 1  Line 1 
1  <?php  <?php
2  // $Id: pbs.test,v 1.8 2009/09/08 17:46:20 bjaspan Exp $  // $Id: pbs.test,v 1.9 2009/09/08 17:48:00 bjaspan Exp $
3    
4  class PbsTestCase extends DrupalWebTestCase {  class PbsTestCase extends DrupalWebTestCase {
5    function getInfo() {    function getInfo() {
# Line 55  class PbsTestCase extends DrupalWebTestC Line 55  class PbsTestCase extends DrupalWebTestC
55        $entity = field_test_create_stub_entity($id, $id, $bundle);        $entity = field_test_create_stub_entity($id, $id, $bundle);
56        foreach ($this->fields as $field_name => $field) {        foreach ($this->fields as $field_name => $field) {
57          $values = array();          $values = array();
58          $max = ($field['cardinality'] == FIELD_CARDINALITY_UNLIMITED) ? 3/*TODO*/ : $field['cardinality'];          $max = ($field['cardinality'] == FIELD_CARDINALITY_UNLIMITED) ? 17 : $field['cardinality'];
59          for ($delta = 0; $delta < $max; ++$delta) {          for ($delta = 0; $delta < $max; ++$delta) {
60            $values[$delta]['value'] = mt_rand(0, 127);            $values[$delta]['value'] = mt_rand(0, 127);
61          }          }
# Line 293  class PbsTestCase extends DrupalWebTestC Line 293  class PbsTestCase extends DrupalWebTestC
293        $this->assertEqual($entity->card_1, array(), "Entity revision $vid is deleted.");        $this->assertEqual($entity->card_1, array(), "Entity revision $vid is deleted.");
294      }      }
295    }    }
296    
297      function testTranslatableFields() {
298        $entity = field_test_create_stub_entity(12, 0, 'test_bundle');
299        $entity->card_1 = array(
300          'l1' => array(0 => array('value' => 1)),
301          'l2' => array(0 => array('value' => 2)),
302        );
303        $entity->card_4 = array(
304          'l1' => array(
305            0 => array('value' => 1),
306          ),
307          'l3' => array(
308            0 => array('value' => 3),
309            1 => array('value' => 3),
310            2 => array('value' => 3),
311          ),
312          'l4' => array(
313            0 => array('value' => 4),
314            1 => array('value' => 4),
315            2 => array('value' => 4),
316            3 => array('value' => 4),
317          ),
318        );
319        field_attach_insert($this->entity_type, $entity);
320    
321        $stub = field_test_create_stub_entity(12, 0, 'test_bundle');
322        $skip = array();
323        pbs_field_attach_pre_load($this->entity_type, array($stub->ftid => $stub), FIELD_LOAD_CURRENT, $skip);
324        foreach (array('card_1', 'card_4') as $field_name) {
325          $this->assertEqual(count($entity->{$field_name}), count($stub->{$field_name}), "Field $field_name loaded the correct number of languages.");
326          foreach ($entity->{$field_name} as $language => $items) {
327            $this->assertEqual($items, $stub->{$field_name}[$language], "Field $field_name, language $language data loaded properly.");
328          }
329        }
330      }
331  }  }

Legend:
Removed from v.1.9  
changed lines
  Added in v.1.10

  ViewVC Help
Powered by ViewVC 1.1.2