Projet

Général

Profil

Révision 5d12d676

Ajouté par Assos Assos il y a environ 6 ans

Weekly update of contrib modules

Voir les différences:

drupal7/sites/all/modules/views/tests/views_ui.test
9 9
 * Views UI wizard tests.
10 10
 */
11 11
class ViewsUIWizardHelper extends DrupalWebTestCase {
12

  
13
  /**
14
   *
15
   */
12 16
  function setUp() {
13 17
    // Enable views_ui.
14 18
    parent::setUp('views_ui');
......
17 21
    $views_admin = $this->drupalCreateUser(array('administer views', 'administer blocks', 'bypass node access', 'access user profiles', 'view revisions'));
18 22
    $this->drupalLogin($views_admin);
19 23
  }
24

  
20 25
}
21 26

  
22 27
/**
23 28
 * Tests creating views with the wizard and viewing them on the listing page.
24 29
 */
25 30
class ViewsUIWizardBasicTestCase extends ViewsUIWizardHelper {
31

  
32
  /**
33
   *
34
   */
26 35
  public static function getInfo() {
27 36
    return array(
28 37
      'name' => 'Views UI wizard basic functionality',
......
31 40
    );
32 41
  }
33 42

  
43
  /**
44
   *
45
   */
34 46
  function testViewsWizardAndListing() {
35 47
    // Check if we can access the main views admin page.
36 48
    $this->drupalGet('admin/structure/views');
......
46 58
    $this->assertText(t('Your view was saved. You may edit it from the list below.'));
47 59
    $this->assertText($view1['human_name']);
48 60
    $this->assertText($view1['description']);
49
    foreach(array('delete', 'clone', 'edit') as $operation) {
61
    foreach (array('delete', 'clone', 'edit') as $operation) {
50 62
      $this->assertLinkByHref(url('admin/structure/views/view/' . $view1['name'] . '/' . $operation));
51 63
    }
52 64

  
......
146 158
    // Make sure the listing page doesn't show disabled default views.
147 159
    $this->assertNoText('tracker', t('Default tracker view does not show on the listing page.'));
148 160
  }
161

  
149 162
}
150 163

  
151 164
/**
152 165
 * Tests enabling, disabling, and reverting default views via the listing page.
153 166
 */
154 167
class ViewsUIWizardDefaultViewsTestCase extends ViewsUIWizardHelper {
168

  
169
  /**
170
   *
171
   */
155 172
  public static function getInfo() {
156 173
    return array(
157 174
      'name' => 'Views UI default views functionality',
......
168 185
    // the listing page).
169 186
    $edit_href = 'admin/structure/views/view/frontpage/edit';
170 187
    $this->drupalGet('admin/structure/views');
171
    // TODO: Disabled default views do now appear on the front page. Test this
188
    // @todo Disabled default views do now appear on the front page. Test this
172 189
    // behavior with templates instead.
173 190
    // $this->assertNoLinkByHref($edit_href);
174

  
175 191
    // Enable the front page view, and make sure it is now visible on the main
176 192
    // listing page.
177 193
    $this->drupalGet('admin/structure/views/templates');
......
205 221
    // Now disable the view, and make sure it stops appearing on the main view
206 222
    // listing page but instead goes back to displaying on the disabled views
207 223
    // listing page.
208
    // TODO: Test this behavior with templates instead.
224
    // @todo Test this behavior with templates instead.
209 225
    $this->drupalGet('admin/structure/views');
210 226
    $this->clickViewsOperationLink(t('Disable'), '/frontpage/');
211 227
    // $this->assertUrl('admin/structure/views');
......
225 241
   * various views listing pages, and they might have tokens in them. So we
226 242
   * need special code to find the correct one to click.
227 243
   *
228
   * @param $label
244
   * @param string $label
229 245
   *   Text between the anchor tags of the desired link.
230
   * @param $unique_href_part
246
   * @param string $unique_href_part
231 247
   *   A unique string that is expected to occur within the href of the desired
232 248
   *   link. For example, if the link URL is expected to look like
233 249
   *   "admin/structure/views/view/frontpage/...", then "/frontpage/" could be
234 250
   *   passed as the expected unique string.
235 251
   *
236
   * @return
252
   * @return string
237 253
   *   The page content that results from clicking on the link, or FALSE on
238 254
   *   failure. Failure also results in a failed assertion.
239 255
   */
......
254 270
      return FALSE;
255 271
    }
256 272
  }
273

  
257 274
}
258 275

  
259 276
/**
260 277
 * Tests the ability of the views wizard to create views filtered by taxonomy.
261 278
 */
262 279
class ViewsUIWizardTaggedWithTestCase extends ViewsUIWizardHelper {
280

  
281
  /**
282
   *
283
   */
263 284
  protected $node_type_with_tags;
285

  
286
  /**
287
   *
288
   */
264 289
  protected $node_type_without_tags;
290

  
291
  /**
292
   *
293
   */
265 294
  protected $tag_vocabulary;
295

  
296
  /**
297
   *
298
   */
266 299
  protected $tag_field;
300

  
301
  /**
302
   *
303
   */
267 304
  protected $tag_instance;
268 305

  
306
  /**
307
   *
308
   */
269 309
  public static function getInfo() {
270 310
    return array(
271 311
      'name' => 'Views UI wizard taxonomy functionality',
......
274 314
    );
275 315
  }
276 316

  
317
  /**
318
   * {@inheritdoc}
319
   */
277 320
  function setUp() {
278 321
    parent::setUp();
279 322

  
......
392 435
  }
393 436

  
394 437
  /**
395
   * Tests that the "tagged with" form element only shows for node types that support it.
438
   * Test the "tagged with" form element only shows for node types that support it.
396 439
   */
397 440
  function testTaggedWithByNodeType() {
398 441
    // The tagging field is associated with one of our node types only. So the
......
422 465
    $this->drupalPost(NULL, $view, t('Update "of type" choice'));
423 466
    $this->assertFieldByXpath($tags_xpath);
424 467
  }
468

  
425 469
}
426 470

  
427 471
/**
428 472
 * Tests the ability of the views wizard to create views with sorts.
429 473
 */
430 474
class ViewsUIWizardSortingTestCase extends ViewsUIWizardHelper {
475

  
476
  /**
477
   *
478
   */
431 479
  public static function getInfo() {
432 480
    return array(
433 481
      'name' => 'Views UI wizard sorting functionality',
......
492 540
    $pos1 = strpos($content, $node1->title);
493 541
    $this->assertTrue($pos3 < $pos2 && $pos2 < $pos1, t('The nodes appear in the expected order in a view that sorts by newest first.'));
494 542
  }
543

  
495 544
}
496 545

  
497 546
/**
498
 * Tests the ability of the views wizard to specify the number of items per page.
547
 * Tests the ability of the wizard to specify the number of items per page.
499 548
 */
500 549
class ViewsUIWizardItemsPerPageTestCase extends ViewsUIWizardHelper {
550

  
551
  /**
552
   *
553
   */
501 554
  public static function getInfo() {
502 555
    return array(
503 556
      'name' => 'Views UI wizard items per page functionality',
......
577 630
    $pos3 = strpos($content, $node3->title);
578 631
    $this->assertTrue($pos5 < $pos4 && $pos4 < $pos3, t('The nodes appear in the expected order in the block display.'));
579 632
  }
633

  
580 634
}
581 635

  
582 636
/**
583 637
 * Tests the ability of the views wizard to put views in a menu.
584 638
 */
585 639
class ViewsUIWizardMenuTestCase extends ViewsUIWizardHelper {
640

  
641
  /**
642
   *
643
   */
586 644
  public static function getInfo() {
587 645
    return array(
588 646
      'name' => 'Views UI wizard menu functionality',
......
625 683
    }
626 684
    $this->assertTrue($found, t('Found a link to %path in the main menu', array('%path' => $view['page[path]'])));
627 685
  }
686

  
628 687
}
629 688

  
630 689
/**
631
 * Tests the ability of the views wizard to create views with a jump menu style plugin.
690
 * Tests the ability of the  wizard to create views with a jump menu style.
632 691
 */
633 692
class ViewsUIWizardJumpMenuTestCase extends ViewsUIWizardHelper {
693

  
694
  /**
695
   *
696
   */
634 697
  public static function getInfo() {
635 698
    return array(
636 699
      'name' => 'Views UI wizard jump menu functionality',
......
683 746

  
684 747
      // Submit the jump menu form, and check that we are redirected to the
685 748
      // expected URL.
686

  
687 749
      $edit = array();
688 750
      $edit['jump'] = url($path, $options);
689 751

  
......
786 848
    node_save($node);
787 849
    return 'node/' . $node->nid . '/revisions/' . $node->vid . '/view';
788 850
  }
851

  
789 852
}
790 853

  
791 854
/**
792 855
 * Tests that displays can be correctly overridden via the user interface.
793 856
 */
794 857
class ViewsUIWizardOverrideDisplaysTestCase extends ViewsUIWizardHelper {
858

  
859
  /**
860
   *
861
   */
795 862
  public static function getInfo() {
796 863
    return array(
797 864
      'name' => 'Views UI overridden displays',
......
948 1015
   * Tests that the revert to all displays select-option works as expected.
949 1016
   */
950 1017
  function testRevertAllDisplays() {
951
    // Create a basic view with a page, block.
952
    // Because there is both a title on page and block we expect the title on
953
    // the block be overriden.
1018
    // Create a basic view with a page, block. Because there is both a title on
1019
    // page and block we expect the title on the block be overriden.
954 1020
    $view['human_name'] = $this->randomName(16);
955 1021
    $view['name'] = strtolower($this->randomName(16));
956 1022
    $view['page[create]'] = 1;
......
970 1036
    $this->drupalPost("admin/structure/views/view/{$view['name']}/edit/block", array(), t('Save'));
971 1037
    $this->assertText($view['page[title]']);
972 1038
  }
1039

  
973 1040
}

Formats disponibles : Unified diff