Mercurial > hg > isophonics-drupal-site
comparison core/modules/taxonomy/tests/src/Functional/LegacyTest.php @ 0:4c8ae668cc8c
Initial import (non-working)
author | Chris Cannam |
---|---|
date | Wed, 29 Nov 2017 16:09:58 +0000 |
parents | |
children |
comparison
equal
deleted
inserted
replaced
-1:000000000000 | 0:4c8ae668cc8c |
---|---|
1 <?php | |
2 | |
3 namespace Drupal\Tests\taxonomy\Functional; | |
4 | |
5 use Drupal\Core\Datetime\DrupalDateTime; | |
6 use Drupal\Core\Field\FieldStorageDefinitionInterface; | |
7 use Drupal\taxonomy\Entity\Vocabulary; | |
8 | |
9 /** | |
10 * Posts an article with a taxonomy term and a date prior to 1970. | |
11 * | |
12 * @group taxonomy | |
13 */ | |
14 class LegacyTest extends TaxonomyTestBase { | |
15 | |
16 /** | |
17 * Modules to enable. | |
18 * | |
19 * @var array | |
20 */ | |
21 public static $modules = ['node', 'datetime']; | |
22 | |
23 protected function setUp() { | |
24 parent::setUp(); | |
25 | |
26 // Create a tags vocabulary for the 'article' content type. | |
27 $vocabulary = Vocabulary::create([ | |
28 'name' => 'Tags', | |
29 'vid' => 'tags', | |
30 ]); | |
31 $vocabulary->save(); | |
32 $field_name = 'field_' . $vocabulary->id(); | |
33 | |
34 $handler_settings = [ | |
35 'target_bundles' => [ | |
36 $vocabulary->id() => $vocabulary->id(), | |
37 ], | |
38 'auto_create' => TRUE, | |
39 ]; | |
40 $this->createEntityReferenceField('node', 'article', $field_name, 'Tags', 'taxonomy_term', 'default', $handler_settings, FieldStorageDefinitionInterface::CARDINALITY_UNLIMITED); | |
41 | |
42 entity_get_form_display('node', 'article', 'default') | |
43 ->setComponent($field_name, [ | |
44 'type' => 'entity_reference_autocomplete_tags', | |
45 ]) | |
46 ->save(); | |
47 | |
48 $this->drupalLogin($this->drupalCreateUser(['administer taxonomy', 'administer nodes', 'bypass node access'])); | |
49 } | |
50 | |
51 /** | |
52 * Test taxonomy functionality with nodes prior to 1970. | |
53 */ | |
54 public function testTaxonomyLegacyNode() { | |
55 // Posts an article with a taxonomy term and a date prior to 1970. | |
56 $date = new DrupalDateTime('1969-01-01 00:00:00'); | |
57 $edit = []; | |
58 $edit['title[0][value]'] = $this->randomMachineName(); | |
59 $edit['created[0][value][date]'] = $date->format('Y-m-d'); | |
60 $edit['created[0][value][time]'] = $date->format('H:i:s'); | |
61 $edit['body[0][value]'] = $this->randomMachineName(); | |
62 $edit['field_tags[target_id]'] = $this->randomMachineName(); | |
63 $this->drupalPostForm('node/add/article', $edit, t('Save')); | |
64 // Checks that the node has been saved. | |
65 $node = $this->drupalGetNodeByTitle($edit['title[0][value]']); | |
66 $this->assertEqual($node->getCreatedTime(), $date->getTimestamp(), 'Legacy node was saved with the right date.'); | |
67 } | |
68 | |
69 } |