Projet

Général

Profil

Paste
Télécharger (20,7 ko) Statistiques
| Branche: | Révision:

root / drupal7 / sites / all / modules / feeds / tests / feeds_mapper_taxonomy.test @ ed9a13f1

1
<?php
2

    
3
/**
4
 * @file
5
 * Contains FeedsMapperTaxonomyTestCase.
6
 */
7

    
8
/**
9
 * Test case for taxonomy mapper mappers/taxonomy.inc.
10
 */
11
class FeedsMapperTaxonomyTestCase extends FeedsMapperTestCase {
12

    
13
  /**
14
   * {@inheritdoc}
15
   */
16
  public static function getInfo() {
17
    return array(
18
      'name' => 'Mapper: Taxonomy',
19
      'description' => 'Test Feeds Mapper support for Taxonomy.',
20
      'group' => 'Feeds',
21
    );
22
  }
23

    
24
  /**
25
   * {@inheritdoc}
26
   */
27
  public function setUp() {
28
    parent::setUp();
29

    
30
    // Add Tags vocabulary.
31
    $edit = array(
32
      'name' => 'Tags',
33
      'machine_name' => 'tags',
34
    );
35
    $this->drupalPost('admin/structure/taxonomy/add', $edit, 'Save');
36

    
37
    $edit = array(
38
      'name' => 'term1',
39
    );
40
    $this->drupalPost('admin/structure/taxonomy/tags/add', $edit, t('Save'));
41
    $this->assertText('Created new term term1.');
42

    
43
    // Create term reference field.
44
    $field = array(
45
      'field_name' => 'field_tags',
46
      'type' => 'taxonomy_term_reference',
47
      'cardinality' => FIELD_CARDINALITY_UNLIMITED,
48
      'settings' => array(
49
        'allowed_values' => array(
50
          array(
51
            'vocabulary' => 'tags',
52
            'parent' => 0,
53
          ),
54
        ),
55
      ),
56
    );
57
    field_create_field($field);
58

    
59
    // Add a term reference field to the "article" node bundle. Tests use this
60
    // content type as "feed item": tests imports nodes of this type.
61
    $this->article_tags = array(
62
      'field_name' => 'field_tags',
63
      'bundle' => 'article',
64
      'entity_type' => 'node',
65
      'widget' => array(
66
        'type' => 'options_select',
67
      ),
68
      'display' => array(
69
        'default' => array(
70
          'type' => 'taxonomy_term_reference_link',
71
        ),
72
      ),
73
    );
74
    field_create_instance($this->article_tags);
75

    
76
    // Add a term reference field to the "page" node bundle. Tests use this
77
    // content type as "feed node type": this type is used to attach importers
78
    // to.
79
    $this->page_tags = array(
80
      'field_name' => 'field_tags',
81
      'bundle' => 'page',
82
      'entity_type' => 'node',
83
      'widget' => array(
84
        'type' => 'options_select',
85
      ),
86
      'display' => array(
87
        'default' => array(
88
          'type' => 'taxonomy_term_reference_link',
89
        ),
90
      ),
91
    );
92
    field_create_instance($this->page_tags);
93

    
94
    // Create an importer configuration with basic mapping.
95
    $this->createImporterConfiguration('Syndication', 'syndication');
96
    $this->addMappings('syndication',
97
      array(
98
        0 => array(
99
          'source' => 'title',
100
          'target' => 'title',
101
        ),
102
        1 => array(
103
          'source' => 'description',
104
          'target' => 'body',
105
        ),
106
        2 => array(
107
          'source' => 'timestamp',
108
          'target' => 'created',
109
        ),
110
        3 => array(
111
          'source' => 'url',
112
          'target' => 'url',
113
          'unique' => TRUE,
114
        ),
115
        4 => array(
116
          'source' => 'guid',
117
          'target' => 'guid',
118
          'unique' => TRUE,
119
        ),
120
      )
121
    );
122
  }
123

    
124
  /**
125
   * Tests inheriting taxonomy from the feed node.
126
   */
127
  public function testInheritTaxonomy() {
128
    // Adjust importer settings.
129
    $this->setSettings('syndication', NULL, array('import_period' => FEEDS_SCHEDULE_NEVER));
130
    $this->setSettings('syndication', NULL, array('import_on_create' => FALSE));
131
    $this->assertText('Do not import on submission');
132

    
133
    // Map feed node's taxonomy to feed item node's taxonomy.
134
    $mappings = array(
135
      5 => array(
136
        'source' => 'parent:taxonomy:tags',
137
        'target' => 'field_tags',
138
      ),
139
    );
140
    $this->addMappings('syndication', $mappings);
141

    
142
    // Create feed node and add term term1.
143
    $langcode = LANGUAGE_NONE;
144
    $nid = $this->createFeedNode('syndication', NULL, 'Syndication');
145
    $term = taxonomy_get_term_by_name('term1');
146
    $term = reset($term);
147
    $edit = array(
148
      'field_tags' . '[' . $langcode . '][]' => $term->tid,
149
    );
150
    $this->drupalPost("node/$nid/edit", $edit, t('Save'));
151
    $this->assertTaxonomyTerm($term->name);
152

    
153
    // Import nodes.
154
    $this->drupalPost("node/$nid/import", array(), 'Import');
155
    $this->assertText('Created 10 nodes.');
156

    
157
    $count = db_query("SELECT COUNT(*) FROM {taxonomy_index}")->fetchField();
158

    
159
    // There should be one term for each node imported plus the term on the feed node.
160
    $this->assertEqual(11, $count, 'Found correct number of tags for all feed nodes and feed items.');
161
  }
162

    
163
  /**
164
   * Tests searching taxonomy terms by name.
165
   */
166
  public function testSearchByName() {
167
    $terms = array(
168
      'Drupal',
169
      'localization',
170
      'localization client',
171
      'localization server',
172
      'open atrium',
173
      'translation',
174
      'translation server',
175
      'Drupal planet',
176
    );
177

    
178
    $this->setSettings('syndication', 'FeedsNodeProcessor', array(
179
      'skip_hash_check' => TRUE,
180
      'update_existing' => 2,
181
    ));
182
    $mappings = array(
183
      5 => array(
184
        'source' => 'tags',
185
        'target' => 'field_tags',
186
        'term_search' => 0,
187
      ),
188
    );
189
    $this->addMappings('syndication', $mappings);
190
    $nid = $this->createFeedNode('syndication', NULL, 'Syndication');
191
    $this->assertText('Created 10 nodes.');
192
    // Check that terms we not auto-created.
193
    $this->drupalGet('node/2');
194
    foreach ($terms as $term) {
195
      $this->assertNoTaxonomyTerm($term);
196
    }
197
    $this->drupalGet('node/3');
198
    $this->assertNoTaxonomyTerm('Washington DC');
199

    
200
    // Change the mapping configuration.
201
    $this->removeMappings('syndication', $mappings);
202
    // Turn on autocreate.
203
    $mappings[5]['autocreate'] = TRUE;
204
    $this->addMappings('syndication', $mappings);
205
    $this->drupalPost('node/' . $nid . '/import', array(), t('Import'));
206
    $this->assertText('Updated 10 nodes.');
207

    
208
    $this->drupalGet('node/2');
209
    foreach ($terms as $term) {
210
      $this->assertTaxonomyTerm($term);
211
    }
212
    $this->drupalGet('node/3');
213
    $this->assertTaxonomyTerm('Washington DC');
214

    
215
    $names = db_query('SELECT name FROM {taxonomy_term_data}')->fetchCol();
216
    $this->assertEqual(count($names), 31, 'Found correct number of terms in the database.');
217

    
218
    // Run import again. This verifys that the terms we found by name.
219
    $this->drupalPost('node/' . $nid . '/import', array(), t('Import'));
220
    $this->assertText('Updated 10 nodes.');
221
    $names = db_query('SELECT name FROM {taxonomy_term_data}')->fetchCol();
222
    $this->assertEqual(count($names), 31, 'Found correct number of terms in the database.');
223
  }
224

    
225
  /**
226
   * Tests mapping to taxonomy terms by tid.
227
   */
228
  public function testSearchByID() {
229
    // Create 10 terms. The first one was created in setup.
230
    $terms = array(1);
231
    foreach (range(2, 10) as $i) {
232
      $term = (object) array(
233
        'name' => 'term' . $i,
234
        'vid' => 1,
235
      );
236
      taxonomy_term_save($term);
237
      $terms[] = $term->tid;
238
    }
239

    
240
    FeedsPlugin::loadMappers();
241

    
242
    $entity = new stdClass();
243
    $target = 'field_tags';
244
    $mapping = array(
245
      'term_search' => FEEDS_TAXONOMY_SEARCH_TERM_ID,
246
      'language' => LANGUAGE_NONE,
247
    );
248

    
249
    $source = FeedsSource::instance('tmp', 0);
250

    
251
    taxonomy_feeds_set_target($source, $entity, $target, $terms, $mapping);
252
    $this->assertEqual(count($entity->field_tags[LANGUAGE_NONE]), 10);
253

    
254
    // Test a second mapping with a bogus term id.
255
    taxonomy_feeds_set_target($source, $entity, $target, array(1234), $mapping);
256
    $this->assertEqual(count($entity->field_tags[LANGUAGE_NONE]), 10);
257
  }
258

    
259
  /**
260
   * Tests mapping to a taxonomy term's guid.
261
   */
262
  public function testSearchByGUID() {
263
    // Create 10 terms. The first one was created in setup.
264
    $tids = array(1);
265
    foreach (range(2, 10) as $i) {
266
      $term = (object) array(
267
        'name' => 'term' . $i,
268
        'vid' => 1,
269
      );
270
      taxonomy_term_save($term);
271
      $tids[] = $term->tid;
272
    }
273

    
274
    // Create a bunch of bogus imported terms.
275
    $guids = array();
276
    foreach ($tids as $tid) {
277
      $guid = 100 * $tid;
278
      $guids[] = $guid;
279
      $record = array(
280
        'entity_type' => 'taxonomy_term',
281
        'entity_id' => $tid,
282
        'id' => 'does_not_exist',
283
        'feed_nid' => 0,
284
        'imported' => REQUEST_TIME,
285
        'url' => '',
286
        'guid' => $guid,
287
      );
288
      drupal_write_record('feeds_item', $record);
289
    }
290

    
291
    FeedsPlugin::loadMappers();
292

    
293
    $entity = new stdClass();
294
    $target = 'field_tags';
295
    $mapping = array(
296
      'term_search' => FEEDS_TAXONOMY_SEARCH_TERM_GUID,
297
      'language' => LANGUAGE_NONE,
298
    );
299

    
300
    $source = FeedsSource::instance('tmp', 0);
301

    
302
    taxonomy_feeds_set_target($source, $entity, $target, $guids, $mapping);
303
    $this->assertEqual(count($entity->field_tags[LANGUAGE_NONE]), 10);
304
    foreach ($entity->field_tags[LANGUAGE_NONE] as $delta => $values) {
305
      $this->assertEqual($tids[$delta], $values['tid'], 'Correct term id foud.');
306
    }
307

    
308
    // Test a second mapping with a bogus term id.
309
    taxonomy_feeds_set_target($source, $entity, $target, array(1234), $mapping);
310
    $this->assertEqual(count($entity->field_tags[LANGUAGE_NONE]), 10);
311
    foreach ($entity->field_tags[LANGUAGE_NONE] as $delta => $values) {
312
      $this->assertEqual($tids[$delta], $values['tid'], 'Correct term id foud.');
313
    }
314
  }
315

    
316
  /**
317
   * Tests that only term references are added from allowed vocabularies.
318
   */
319
  public function testAllowedVocabularies() {
320
    // Create a second vocabulary.
321
    $vocabulary = new stdClass();
322
    $vocabulary->name = 'Foo';
323
    $vocabulary->machine_name = 'foo';
324
    taxonomy_vocabulary_save($vocabulary);
325

    
326
    // Add a term to this vocabulary.
327
    $term1 = new stdClass();
328
    $term1->name = 'Foo1';
329
    $term1->vid = $vocabulary->vid;
330
    taxonomy_term_save($term1);
331

    
332
    // Add a term to the tags vocabulary.
333
    $term2 = new stdClass();
334
    $term2->name = 'Bar1';
335
    $term2->vid = 1;
336
    taxonomy_term_save($term2);
337

    
338
    FeedsPlugin::loadMappers();
339

    
340
    $entity = new stdClass();
341
    $target = 'field_tags';
342
    $terms = array(
343
      'Foo1',
344
      'Bar1',
345
    );
346
    $mapping = array(
347
      'term_search' => FEEDS_TAXONOMY_SEARCH_TERM_NAME,
348
      'language' => LANGUAGE_NONE,
349
    );
350

    
351
    $source = FeedsSource::instance('tmp', 0);
352

    
353
    taxonomy_feeds_set_target($source, $entity, $target, $terms, $mapping);
354

    
355
    // Assert that only the term 'Bar1' was set.
356
    $this->assertEqual(count($entity->field_tags[LANGUAGE_NONE]), 1);
357
    $this->assertEqual($term2->tid, $entity->field_tags[LANGUAGE_NONE][0]['tid']);
358
  }
359

    
360
  /**
361
   * Tests how term caching works across multiple term reference fields.
362
   *
363
   * This specifically verifies that terms added to a vocabulary by one mapping
364
   * are available for use by other fields that are mapping to the same
365
   * vocabulary.
366
   *
367
   * @see https://www.drupal.org/project/feeds/issues/3091682
368
   */
369
  public function testAutoCreateUpdatesAllCaches() {
370
    // Create a second term reference field base.
371
    $field = array(
372
      'field_name' => 'field_tags2',
373
      'type' => 'taxonomy_term_reference',
374
      'cardinality' => FIELD_CARDINALITY_UNLIMITED,
375
      'settings' => array(
376
        'allowed_values' => array(
377
          array(
378
            'vocabulary' => 'tags',
379
            'parent' => 0,
380
          ),
381
        ),
382
      ),
383
    );
384
    field_create_field($field);
385

    
386
    // Add a second term reference field instance to to feed node bundle.
387
    $this->article_tags2 = array(
388
      'field_name' => 'field_tags2',
389
      'bundle' => 'article',
390
      'entity_type' => 'node',
391
      'widget' => array(
392
        'type' => 'options_select',
393
      ),
394
      'display' => array(
395
        'default' => array(
396
          'type' => 'taxonomy_term_reference_link',
397
        ),
398
      ),
399
    );
400
    field_create_instance($this->article_tags2);
401

    
402
    // Create a CSV importer configuration.
403
    $this->createImporterConfiguration('Node import from CSV', 'node');
404

    
405
    $this->setSettings('node', NULL, array(
406
      'content_type' => '',
407
    ));
408

    
409
    $this->setPlugin('node', 'FeedsFileFetcher');
410
    $this->setPlugin('node', 'FeedsCSVParser');
411

    
412
    $this->setSettings('node', 'FeedsNodeProcessor', array(
413
      'bundle' => 'article',
414
      'update_existing' => TRUE,
415
    ));
416

    
417
    $this->addMappings('node', array(
418
      0 => array(
419
        'source' => 'guid',
420
        'target' => 'guid',
421
        'unique' => TRUE,
422
      ),
423
      1 => array(
424
        'source' => 'title',
425
        'target' => 'title',
426
      ),
427
      2 => array(
428
        'source' => 'tag1',
429
        'target' => 'field_tags',
430
        'term_search' => FEEDS_TAXONOMY_SEARCH_TERM_NAME,
431
        'autocreate' => TRUE,
432
      ),
433
      3 => array(
434
        'source' => 'tag2',
435
        'target' => 'field_tags2',
436
        'term_search' => FEEDS_TAXONOMY_SEARCH_TERM_NAME,
437
        'autocreate' => TRUE,
438
      ),
439
    ));
440

    
441
    $this->importFile(
442
      'node',
443
      $this->absolutePath() . '/tests/feeds/taxonomy_multiple_tag_fields.csv');
444

    
445
    $this->assertText('Created 2 nodes');
446

    
447
    $term_names = array(
448
      'Alpha',
449
      'Beta',
450
      'Kiwi',
451
    );
452

    
453
    foreach ($term_names as $term_name) {
454
      $loaded_term = taxonomy_get_term_by_name($term_name);
455
      $terms[$term_name] = reset($loaded_term);
456
    }
457

    
458
    $expected_node_values = array(
459
      1 => array(
460
        'field_tags' => $terms['Alpha']->tid,
461
        'field_tags2' => $terms['Beta']->tid,
462
      ),
463
      2 => array(
464
        'field_tags' => $terms['Kiwi']->tid,
465
        'field_tags2' => $terms['Kiwi']->tid,
466
      ),
467
    );
468

    
469
    foreach ($expected_node_values as $nid => $node_values) {
470
      $this->drupalGet("node/{$nid}/edit");
471

    
472
      foreach ($node_values as $field_name => $field_value) {
473
        $this->assertFieldByName("{$field_name}[und][]", $field_value);
474
      }
475
    }
476
  }
477

    
478
  /**
479
   * Tests if terms can be mapped when term access modules are enabled.
480
   */
481
  public function testTermAccess() {
482
    FeedsPlugin::loadMappers();
483

    
484
    // Set acting user.
485
    // @see feeds_tests_query_term_access_alter()
486
    variable_set('feeds_tests_term_reference_allowed_user', $this->admin_user->uid);
487

    
488
    // Set to import using cron.
489
    $this->setSettings('syndication', NULL, array(
490
      'import_period' => 0,
491
      'import_on_create' => FALSE,
492
      'process_in_background' => TRUE,
493
    ));
494

    
495
    // Add target to taxonomy reference field.
496
    $this->addMappings('syndication', array(
497
      5 => array(
498
        'source' => 'tags',
499
        'target' => 'field_tags',
500
        'term_search' => FEEDS_TAXONOMY_SEARCH_TERM_NAME,
501
      ),
502
    ));
503

    
504
    // Create a few terms used in developmentseed.rss2.
505
    $term1 = new stdClass();
506
    $term1->name = 'Drupal';
507
    $term1->vid = 1;
508
    taxonomy_term_save($term1);
509
    $term2 = new stdClass();
510
    $term2->name = 'translation';
511
    $term2->vid = 1;
512
    taxonomy_term_save($term2);
513

    
514
    // Create feed node and initiate import.
515
    $nid = $this->createFeedNode('syndication', NULL, 'Syndication');
516

    
517
    // Log out to ensure cron is ran as anonymous user.
518
    $this->drupalLogout();
519
    // Run cron to run the import and assert 11 created nodes in total.
520
    $this->cronRun();
521
    $node_count = db_select('node')
522
      ->fields('node', array('nid'))
523
      ->countQuery()
524
      ->execute()
525
      ->fetchField();
526
    $this->assertEqual(11, $node_count, format_string('There are @expected nodes (actual: @actual).', array(
527
      '@expected' => 11,
528
      '@actual' => $node_count,
529
    )));
530

    
531
    // Assert that node 2 got two terms assigned.
532
    $node = node_load(2);
533
    $this->assertEqual($term1->tid, $node->field_tags[LANGUAGE_NONE][0]['tid']);
534
    $this->assertEqual($term2->tid, $node->field_tags[LANGUAGE_NONE][1]['tid']);
535
  }
536

    
537
  /**
538
   * Tests importing empty values.
539
   */
540
  public function testBlankSourceValues() {
541
    // Create a CSV importer configuration.
542
    $this->createImporterConfiguration('Node import from CSV', 'node');
543
    $this->setPlugin('node', 'FeedsFileFetcher');
544
    $this->setPlugin('node', 'FeedsCSVParser');
545
    $this->setSettings('node', 'FeedsNodeProcessor', array('bundle' => 'article'));
546
    $this->setSettings('node', NULL, array('content_type' => ''));
547
    $this->addMappings('node', array(
548
      0 => array(
549
        'source' => 'title',
550
        'target' => 'title',
551
      ),
552
      1 => array(
553
        'source' => 'tags',
554
        'target' => 'field_tags',
555
        'term_search' => 0,
556
        'autocreate' => 1,
557
      ),
558
      2 => array(
559
        'source' => 'guid',
560
        'target' => 'guid',
561
        'unique' => TRUE,
562
      ),
563
    ));
564

    
565
    // Verify that there are 5 nodes total.
566
    $this->importFile('node', $this->absolutePath() . '/tests/feeds/taxonomy_empty_terms.csv');
567
    $this->assertText('Created 5 nodes');
568

    
569
    // Make sure only two terms were added.
570
    $names = db_query('SELECT name FROM {taxonomy_term_data}')->fetchCol();
571
    $this->assertEqual(count($names), 2, 'Found correct number of terms in the database.');
572

    
573
    // Make sure the correct terms were created.
574
    $terms = array(
575
      'term1',
576
      '0',
577
    );
578
    foreach ($terms as $term_name) {
579
      $this->assertTrue(in_array($term_name, $names), 'Correct term created');
580
    }
581
  }
582

    
583
  /**
584
   * Tests that there are no errors when trying to map to an invalid vocabulary.
585
   */
586
  public function testMissingVocabulary() {
587
    $this->addMappings('syndication', array(
588
      5 => array(
589
        'source' => 'tags',
590
        'target' => 'field_tags',
591
        'term_search' => 0,
592
        'autocreate' => TRUE,
593
      ),
594
    ));
595

    
596
    // Create an invalid configuration.
597
    db_delete('taxonomy_vocabulary')->execute();
598

    
599
    $this->createFeedNode('syndication', NULL, 'Syndication');
600
    $this->assertText('Created 10 nodes.');
601
  }
602

    
603
  /**
604
   * Tests if values are cleared out when an empty value or no value
605
   * is provided.
606
   */
607
  public function testClearOutValues() {
608
    // Create a CSV importer configuration.
609
    $this->createImporterConfiguration('Node import from CSV', 'node');
610
    $this->setSettings('node', NULL, array(
611
      'content_type' => '',
612
    ));
613
    $this->setPlugin('node', 'FeedsFileFetcher');
614
    $this->setPlugin('node', 'FeedsCSVParser');
615
    $this->setSettings('node', 'FeedsNodeProcessor', array(
616
      'bundle' => 'article',
617
      'update_existing' => 1,
618
    ));
619
    $this->addMappings('node', array(
620
      0 => array(
621
        'source' => 'title',
622
        'target' => 'title',
623
      ),
624
      1 => array(
625
        'source' => 'alpha',
626
        'target' => 'field_tags',
627
        'term_search' => 0,
628
        'autocreate' => 1,
629
      ),
630
      2 => array(
631
        'source' => 'guid',
632
        'target' => 'guid',
633
        'unique' => TRUE,
634
      ),
635
    ));
636

    
637
    $this->importFile('node', $this->absolutePath() . '/tests/feeds/content.csv');
638
    $this->assertText('Created 2 nodes');
639

    
640
    // Check the imported nodes.
641
    $terms1 = taxonomy_get_term_by_name('Lorem');
642
    $term1 = reset($terms1);
643
    $terms2 = taxonomy_get_term_by_name('Ut wisi');
644
    $term2 = reset($terms2);
645
    $taxonomy_values = array(
646
      1 => $term1->tid,
647
      2 => $term2->tid,
648
    );
649
    for ($i = 1; $i <= 2; $i++) {
650
      $this->drupalGet("node/$i/edit");
651
      $this->assertFieldByName('field_tags[und][]', $taxonomy_values[$i]);
652
    }
653

    
654
    // Import CSV file with empty values.
655
    $this->importFile('node', $this->absolutePath() . '/tests/feeds/content_empty.csv');
656
    $this->assertText('Updated 2 nodes');
657

    
658
    // Check if the taxonomy reference field was cleared out for node 1.
659
    $this->drupalGet('node/1/edit');
660
    $this->assertFieldByName('field_tags[und][]', '_none');
661
    $this->drupalGet('node/1');
662
    $this->assertNoText('field_tags');
663

    
664
    // Check if zero's didn't cleared out the taxonomy reference field for
665
    // node 2.
666
    $terms0 = taxonomy_get_term_by_name('0');
667
    $term0 = reset($terms0);
668
    $this->drupalGet('node/2/edit');
669
    $this->assertFieldByName('field_tags[und][]', $term0->tid);
670
    $this->drupalGet('node/2');
671
    $this->assertText('field_tags');
672

    
673
    // Re-import the first file again and check if the values returned.
674
    $this->importFile('node', $this->absolutePath() . '/tests/feeds/content.csv');
675
    $this->assertText('Updated 2 nodes');
676
    for ($i = 1; $i <= 2; $i++) {
677
      $this->drupalGet("node/$i/edit");
678
      $this->assertFieldByName('field_tags[und][]', $taxonomy_values[$i]);
679
    }
680

    
681
    // Import CSV file with non-existent values.
682
    $this->importFile('node', $this->absolutePath() . '/tests/feeds/content_non_existent.csv');
683
    $this->assertText('Updated 2 nodes');
684

    
685
    // Check if the taxonomy reference field was cleared out for node 1.
686
    $this->drupalGet('node/1/edit');
687
    $this->assertFieldByName('field_tags[und][]', '_none');
688
    $this->drupalGet('node/1');
689
    $this->assertNoText('field_tags');
690
  }
691

    
692
  /**
693
   * Finds node style taxonomy term markup in DOM.
694
   */
695
  public function assertTaxonomyTerm($term) {
696
    $term = check_plain($term);
697
    $this->assertPattern('/<a href="\/.*taxonomy\/term\/[0-9]+">' . $term . '<\/a>/', 'Found ' . $term);
698
  }
699

    
700
  /**
701
   * Asserts that the term does not exist on a node page.
702
   */
703
  public function assertNoTaxonomyTerm($term) {
704
    $term = check_plain($term);
705
    $this->assertNoPattern('/<a href="\/.*taxonomy\/term\/[0-9]+">' . $term . '<\/a>/', 'Did not find ' . $term);
706
  }
707

    
708
}