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/tracker/tracker.test
182 182
    $this->assertText('1 new', 'New comments are counted on the tracker listing pages.');
183 183
  }
184 184

  
185
  /**
186
   * Tests for ordering on a users tracker listing when comments are posted.
187
   */
188
  function testTrackerOrderingNewComments() {
189
    $this->drupalLogin($this->user);
190

  
191
    $node_one = $this->drupalCreateNode(array(
192
      'title' => $this->randomName(8),
193
    ));
194

  
195
    $node_two = $this->drupalCreateNode(array(
196
      'title' => $this->randomName(8),
197
    ));
198

  
199
    // Now get other_user to track these pieces of content.
200
    $this->drupalLogin($this->other_user);
201

  
202
    // Add a comment to the first page.
203
    $comment = array(
204
      'subject' => $this->randomName(),
205
      'comment_body[' . LANGUAGE_NONE . '][0][value]' => $this->randomName(20),
206
    );
207
    $this->drupalPost('comment/reply/' . $node_one->nid, $comment, t('Save'));
208

  
209
    // If the comment is posted in the same second as the last one then Drupal
210
    // can't tell the difference, so we wait one second here.
211
    sleep(1);
212

  
213
    // Add a comment to the second page.
214
    $comment = array(
215
      'subject' => $this->randomName(),
216
      'comment_body[' . LANGUAGE_NONE . '][0][value]' => $this->randomName(20),
217
    );
218
    $this->drupalPost('comment/reply/' . $node_two->nid, $comment, t('Save'));
219

  
220
    // We should at this point have in our tracker for other_user:
221
    // 1. node_two
222
    // 2. node_one
223
    // Because that's the reverse order of the posted comments.
224

  
225
    // Now we're going to post a comment to node_one which should jump it to the
226
    // top of the list.
227

  
228
    $this->drupalLogin($this->user);
229
    // If the comment is posted in the same second as the last one then Drupal
230
    // can't tell the difference, so we wait one second here.
231
    sleep(1);
232

  
233
    // Add a comment to the second page.
234
    $comment = array(
235
      'subject' => $this->randomName(),
236
      'comment_body[' . LANGUAGE_NONE . '][0][value]' => $this->randomName(20),
237
    );
238
    $this->drupalPost('comment/reply/' . $node_one->nid, $comment, t('Save'));
239

  
240
    // Switch back to the other_user and assert that the order has swapped.
241
    $this->drupalLogin($this->other_user);
242
    $this->drupalGet('user/' . $this->other_user->uid . '/track');
243
    // This is a cheeky way of asserting that the nodes are in the right order
244
    // on the tracker page.
245
    // It's almost certainly too brittle.
246
    $pattern = '/' . preg_quote($node_one->title) . '.+' . preg_quote($node_two->title) . '/s';
247
    $this->verbose($pattern);
248
    $this->assertPattern($pattern, 'Most recently commented on node appears at the top of tracker');
249
  }
250

  
185 251
  /**
186 252
   * Tests that existing nodes are indexed by cron.
187 253
   */

Formats disponibles : Unified diff