Projet

Général

Profil

Révision b4adf10d

Ajouté par Assos Assos il y a plus de 9 ans

Udpate to 7.33

Voir les différences:

drupal7/modules/simpletest/drupal_web_test_case.php
143 143
    );
144 144

  
145 145
    // Store assertion for display after the test has completed.
146
    try {
147
      $connection = Database::getConnection('default', 'simpletest_original_default');
148
    }
149
    catch (DatabaseConnectionNotDefinedException $e) {
150
      // If the test was not set up, the simpletest_original_default
151
      // connection does not exist.
152
      $connection = Database::getConnection('default', 'default');
153
    }
154
    $connection
146
    self::getDatabaseConnection()
155 147
      ->insert('simpletest')
156 148
      ->fields($assertion)
157 149
      ->execute();
......
166 158
    }
167 159
  }
168 160

  
161
  /**
162
   * Returns the database connection to the site running Simpletest.
163
   *
164
   * @return DatabaseConnection
165
   *   The database connection to use for inserting assertions.
166
   */
167
  public static function getDatabaseConnection() {
168
    try {
169
      $connection = Database::getConnection('default', 'simpletest_original_default');
170
    }
171
    catch (DatabaseConnectionNotDefinedException $e) {
172
      // If the test was not set up, the simpletest_original_default
173
      // connection does not exist.
174
      $connection = Database::getConnection('default', 'default');
175
    }
176

  
177
    return $connection;
178
  }
179

  
169 180
  /**
170 181
   * Store an assertion from outside the testing context.
171 182
   *
......
205 216
      'file' => $caller['file'],
206 217
    );
207 218

  
208
    return db_insert('simpletest')
219
    return self::getDatabaseConnection()
220
      ->insert('simpletest')
209 221
      ->fields($assertion)
210 222
      ->execute();
211 223
  }
......
221 233
   * @see DrupalTestCase::insertAssert()
222 234
   */
223 235
  public static function deleteAssert($message_id) {
224
    return (bool) db_delete('simpletest')
236
    return (bool) self::getDatabaseConnection()
237
      ->delete('simpletest')
225 238
      ->condition('message_id', $message_id)
226 239
      ->execute();
227 240
  }
......
435 448
  }
436 449

  
437 450
  /**
438
   * Logs verbose message in a text file.
451
   * Logs a verbose message in a text file.
439 452
   *
440
   * The a link to the vebose message will be placed in the test results via
441
   * as a passing assertion with the text '[verbose message]'.
453
   * The link to the verbose message will be placed in the test results as a
454
   * passing assertion with the text '[verbose message]'.
442 455
   *
443 456
   * @param $message
444 457
   *   The verbose message to be stored.
......
2288 2301
            break;
2289 2302
          case 'restripe':
2290 2303
            break;
2304
          case 'add_css':
2305
            break;
2291 2306
        }
2292 2307
      }
2293 2308
      $content = $dom->saveHTML();
......
2682 2697
   *
2683 2698
   * Will click the first link found with this link text by default, or a later
2684 2699
   * one if an index is given. Match is case sensitive with normalized space.
2685
   * The label is translated label. There is an assert for successful click.
2700
   * The label is translated label.
2701
   *
2702
   * If the link is discovered and clicked, the test passes. Fail otherwise.
2686 2703
   *
2687 2704
   * @param $label
2688 2705
   *   Text between the anchor tags.
2689 2706
   * @param $index
2690 2707
   *   Link position counting from zero.
2691 2708
   * @return
2692
   *   Page on success, or FALSE on failure.
2709
   *   Page contents on success, or FALSE on failure.
2693 2710
   */
2694 2711
  protected function clickLink($label, $index = 0) {
2695 2712
    $url_before = $this->getUrl();
2696 2713
    $urls = $this->xpath('//a[normalize-space(text())=:label]', array(':label' => $label));
2697

  
2698 2714
    if (isset($urls[$index])) {
2699 2715
      $url_target = $this->getAbsoluteUrl($urls[$index]['href']);
2700
    }
2701

  
2702
    $this->assertTrue(isset($urls[$index]), t('Clicked link %label (@url_target) from @url_before', array('%label' => $label, '@url_target' => $url_target, '@url_before' => $url_before)), t('Browser'));
2703

  
2704
    if (isset($url_target)) {
2716
      $this->pass(t('Clicked link %label (@url_target) from @url_before', array('%label' => $label, '@url_target' => $url_target, '@url_before' => $url_before)), 'Browser');
2705 2717
      return $this->drupalGet($url_target);
2706 2718
    }
2719
    $this->fail(t('Link %label does not exist on @url_before', array('%label' => $label, '@url_before' => $url_before)), 'Browser');
2707 2720
    return FALSE;
2708 2721
  }
2709 2722

  

Formats disponibles : Unified diff