Projet

Général

Profil

Révision 30d5b9c5

Ajouté par Mathieu Schiano Di Schiabica il y a environ 8 ans

Update to 7.42

Voir les différences:

drupal7/modules/node/node.test
457 457
  }
458 458

  
459 459
  function setUp() {
460
    parent::setUp();
460
    parent::setUp(array('taxonomy', 'node'));
461 461

  
462 462
    $web_user = $this->drupalCreateUser(array('edit own page content', 'create page content'));
463 463
    $this->drupalLogin($web_user);
464

  
465
    // Add a vocabulary so we can test different view modes.
466
    $vocabulary = (object) array(
467
      'name' => $this->randomName(),
468
      'description' => $this->randomName(),
469
      'machine_name' => drupal_strtolower($this->randomName()),
470
      'help' => '',
471
      'nodes' => array('page' => 'page'),
472
    );
473
    taxonomy_vocabulary_save($vocabulary);
474

  
475
    $this->vocabulary = $vocabulary;
476

  
477
    // Add a term to the vocabulary.
478
    $term = (object) array(
479
      'name' => $this->randomName(),
480
      'description' => $this->randomName(),
481
      // Use the first available text format.
482
      'format' => db_query_range('SELECT format FROM {filter_format}', 0, 1)->fetchField(),
483
      'vid' => $this->vocabulary->vid,
484
      'vocabulary_machine_name' => $vocabulary->machine_name,
485
    );
486
    taxonomy_term_save($term);
487

  
488
    $this->term = $term;
489

  
490
    // Set up a field and instance.
491
    $this->field_name = drupal_strtolower($this->randomName());
492
    $this->field = array(
493
      'field_name' => $this->field_name,
494
      'type' => 'taxonomy_term_reference',
495
      'settings' => array(
496
        'allowed_values' => array(
497
          array(
498
            'vocabulary' => $this->vocabulary->machine_name,
499
            'parent' => '0',
500
          ),
501
        ),
502
      )
503
    );
504

  
505
    field_create_field($this->field);
506
    $this->instance = array(
507
      'field_name' => $this->field_name,
508
      'entity_type' => 'node',
509
      'bundle' => 'page',
510
      'widget' => array(
511
        'type' => 'options_select',
512
      ),
513
      // Hide on full display but render on teaser.
514
      'display' => array(
515
        'default' => array(
516
          'type' => 'hidden',
517
        ),
518
        'teaser' => array(
519
          'type' => 'taxonomy_term_reference_link',
520
        ),
521
      ),
522
    );
523
    field_create_instance($this->instance);
464 524
  }
465 525

  
466 526
  /**
......
470 530
    $langcode = LANGUAGE_NONE;
471 531
    $title_key = "title";
472 532
    $body_key = "body[$langcode][0][value]";
533
    $term_key = "{$this->field_name}[$langcode]";
473 534

  
474 535
    // Fill in node creation form and preview node.
475 536
    $edit = array();
476 537
    $edit[$title_key] = $this->randomName(8);
477 538
    $edit[$body_key] = $this->randomName(16);
539
    $edit[$term_key] = $this->term->tid;
478 540
    $this->drupalPost('node/add/page', $edit, t('Preview'));
479 541

  
480
    // Check that the preview is displaying the title and body.
542
    // Check that the preview is displaying the title, body, and term.
481 543
    $this->assertTitle(t('Preview | Drupal'), 'Basic page title is preview.');
482 544
    $this->assertText($edit[$title_key], 'Title displayed.');
483 545
    $this->assertText($edit[$body_key], 'Body displayed.');
546
    $this->assertText($this->term->name, 'Term displayed.');
484 547

  
485
    // Check that the title and body fields are displayed with the correct values.
548
    // Check that the title, body, and term fields are displayed with the
549
    // correct values.
486 550
    $this->assertFieldByName($title_key, $edit[$title_key], 'Title field displayed.');
487 551
    $this->assertFieldByName($body_key, $edit[$body_key], 'Body field displayed.');
552
    $this->assertFieldByName($term_key, $edit[$term_key], 'Term field displayed.');
488 553
  }
489 554

  
490 555
  /**
......
494 559
    $langcode = LANGUAGE_NONE;
495 560
    $title_key = "title";
496 561
    $body_key = "body[$langcode][0][value]";
562
    $term_key = "{$this->field_name}[$langcode]";
497 563
    // Force revision on "Basic page" content.
498 564
    variable_set('node_options_page', array('status', 'revision'));
499 565

  
......
501 567
    $edit = array();
502 568
    $edit[$title_key] = $this->randomName(8);
503 569
    $edit[$body_key] = $this->randomName(16);
570
    $edit[$term_key] = $this->term->tid;
504 571
    $edit['log'] = $this->randomName(32);
505 572
    $this->drupalPost('node/add/page', $edit, t('Preview'));
506 573

  
507
    // Check that the preview is displaying the title and body.
574
    // Check that the preview is displaying the title, body, and term.
508 575
    $this->assertTitle(t('Preview | Drupal'), 'Basic page title is preview.');
509 576
    $this->assertText($edit[$title_key], 'Title displayed.');
510 577
    $this->assertText($edit[$body_key], 'Body displayed.');
578
    $this->assertText($this->term->name, 'Term displayed.');
511 579

  
512
    // Check that the title and body fields are displayed with the correct values.
580
    // Check that the title, body, and term fields are displayed with the
581
    // correct values.
513 582
    $this->assertFieldByName($title_key, $edit[$title_key], 'Title field displayed.');
514 583
    $this->assertFieldByName($body_key, $edit[$body_key], 'Body field displayed.');
584
    $this->assertFieldByName($term_key, $edit[$term_key], 'Term field displayed.');
515 585

  
516 586
    // Check that the log field has the correct value.
517 587
    $this->assertFieldByName('log', $edit['log'], 'Log field displayed.');

Formats disponibles : Unified diff