diff --git a/core/modules/aggregator/lib/Drupal/aggregator/Entity/Feed.php b/core/modules/aggregator/lib/Drupal/aggregator/Entity/Feed.php index ff93c30..568cede 100644 --- a/core/modules/aggregator/lib/Drupal/aggregator/Entity/Feed.php +++ b/core/modules/aggregator/lib/Drupal/aggregator/Entity/Feed.php @@ -161,11 +161,13 @@ public static function baseFieldDefinitions(EntityTypeInterface $entity_type) { $fields['checked'] = FieldDefinition::create('timestamp') ->setLabel(t('Checked')) - ->setDescription(t('Last time feed was checked for new items, as Unix timestamp.')); + ->setDescription(t('Last time feed was checked for new items, as Unix timestamp.')) + ->setSetting('default_value', 0); $fields['queued'] = FieldDefinition::create('timestamp') ->setLabel(t('Queued')) - ->setDescription(t('Time when this feed was queued for refresh, 0 if not queued.')); + ->setDescription(t('Time when this feed was queued for refresh, 0 if not queued.')) + ->setSetting('default_value', 0); $fields['link'] = FieldDefinition::create('uri') ->setLabel(t('Link')) diff --git a/core/modules/aggregator/lib/Drupal/aggregator/Entity/Item.php b/core/modules/aggregator/lib/Drupal/aggregator/Entity/Item.php index f12ed40..804d42a 100644 --- a/core/modules/aggregator/lib/Drupal/aggregator/Entity/Item.php +++ b/core/modules/aggregator/lib/Drupal/aggregator/Entity/Item.php @@ -78,8 +78,7 @@ public static function baseFieldDefinitions(EntityTypeInterface $entity_type) { ->setLabel(t('Author')) ->setDescription(t('The author of the feed item.')); - // @todo Convert to a text field in https://drupal.org/node/2149845. - $fields['description'] = FieldDefinition::create('string') + $fields['description'] = FieldDefinition::create('string_long') ->setLabel(t('Description')) ->setDescription(t('The body of the feed item.')); @@ -88,7 +87,7 @@ public static function baseFieldDefinitions(EntityTypeInterface $entity_type) { ->setDescription(t('Posted date of the feed item, as a Unix timestamp.')); // @todo Convert to a real UUID field in https://drupal.org/node/2149851. - $fields['guid'] = FieldDefinition::create('string') + $fields['guid'] = FieldDefinition::create('string_long') ->setLabel(t('GUID')) ->setDescription(t('Unique identifier for the feed item.')); diff --git a/core/modules/field/lib/Drupal/field/Tests/FieldInfoTest.php b/core/modules/field/lib/Drupal/field/Tests/FieldInfoTest.php index a869865..5c9c32d 100644 --- a/core/modules/field/lib/Drupal/field/Tests/FieldInfoTest.php +++ b/core/modules/field/lib/Drupal/field/Tests/FieldInfoTest.php @@ -177,7 +177,6 @@ function testInstancePrepare() { function testInstanceDisabledEntityType() { // Disabling a module invokes user_modules_uninstalled() and calls // drupal_flush_all_caches(). Install the necessary schema to support this. - $this->installEntitySchema('user'); $this->installSchema('system', array('router')); // For this test the field type and the entity type must be exposed by diff --git a/core/modules/file/lib/Drupal/file/Tests/FileManagedUnitTestBase.php b/core/modules/file/lib/Drupal/file/Tests/FileManagedUnitTestBase.php index 56a2940..1930297 100644 --- a/core/modules/file/lib/Drupal/file/Tests/FileManagedUnitTestBase.php +++ b/core/modules/file/lib/Drupal/file/Tests/FileManagedUnitTestBase.php @@ -161,20 +161,19 @@ function assertSameFile(FileInterface $file1, FileInterface $file2) { * File entity. */ function createFile($filepath = NULL, $contents = NULL, $scheme = NULL) { - $file = new \stdClass(); - $file->uri = $this->createUri($filepath, $contents, $scheme); - $file->filename = drupal_basename($file->uri); - $file->filemime = 'text/plain'; - $file->uid = 1; - $file->created = REQUEST_TIME; - $file->changed = REQUEST_TIME; - $file->filesize = filesize($file->uri); - $file->status = 0; + // Don't count hook invocations caused by creating the file. + \Drupal::state()->set('file_test.count_hook_invocations', FALSE); + $file = entity_create('file', array( + 'uri' => $this->createUri($filepath, $contents, $scheme), + 'uid' => 1, + )); + $file->save(); // Write the record directly rather than using the API so we don't invoke // the hooks. - $this->assertNotIdentical(drupal_write_record('file_managed', $file), FALSE, 'The file was added to the database.', 'Create test file'); + $this->assertTrue($file->id() > 0, 'The file was added to the database.', 'Create test file'); - return entity_create('file', (array) $file); + \Drupal::state()->set('file_test.count_hook_invocations', TRUE); + return $file; } /** diff --git a/core/modules/file/tests/file_test/file_test.module b/core/modules/file/tests/file_test/file_test.module index e5a10a0..5fcd15f 100644 --- a/core/modules/file/tests/file_test/file_test.module +++ b/core/modules/file/tests/file_test/file_test.module @@ -108,9 +108,11 @@ function file_test_get_all_calls() { * @see file_test_reset() */ function _file_test_log_call($op, $args) { - $results = \Drupal::state()->get('file_test.results') ?: array(); - $results[$op][] = $args; - \Drupal::state()->set('file_test.results', $results); + if (\Drupal::state()->get('file_test.count_hook_invocations', TRUE)) { + $results = \Drupal::state()->get('file_test.results') ?: array(); + $results[$op][] = $args; + \Drupal::state()->set('file_test.results', $results); + } } /** diff --git a/core/modules/forum/forum.install b/core/modules/forum/forum.install index b281d5b..3cba341 100644 --- a/core/modules/forum/forum.install +++ b/core/modules/forum/forum.install @@ -82,7 +82,7 @@ function forum_install() { * Implements hook_entity_schema_installed(). */ function forum_entity_schema_installed(array $storages) { - if (isset($installed['taxonomy_term'])) { + if (isset($storages['taxonomy_term'])) { // Create a default forum so forum posts can be created. $storages['taxonomy_term']->create(array( 'name' => t('General discussion'), diff --git a/core/modules/hal/lib/Drupal/hal/Tests/EntityTest.php b/core/modules/hal/lib/Drupal/hal/Tests/EntityTest.php index 026f6df..15342ec 100644 --- a/core/modules/hal/lib/Drupal/hal/Tests/EntityTest.php +++ b/core/modules/hal/lib/Drupal/hal/Tests/EntityTest.php @@ -39,7 +39,6 @@ function setUp() { \Drupal::service('router.builder')->rebuild(); $this->installSchema('system', array('sequences')); $this->installEntitySchema('node'); - $this->installEntitySchema('user'); $this->installEntitySchema('taxonomy_term'); } diff --git a/core/modules/simpletest/lib/Drupal/simpletest/Tests/DrupalUnitTestBaseTest.php b/core/modules/simpletest/lib/Drupal/simpletest/Tests/DrupalUnitTestBaseTest.php index 40c16fd..e968c2f 100644 --- a/core/modules/simpletest/lib/Drupal/simpletest/Tests/DrupalUnitTestBaseTest.php +++ b/core/modules/simpletest/lib/Drupal/simpletest/Tests/DrupalUnitTestBaseTest.php @@ -109,7 +109,7 @@ function testEnableModulesInstall() { */ function testEnableModulesInstallContainer() { // Install Node module. - $this->enableModules(array('field', 'node')); + $this->enableModules(array('field', 'node', 'user')); $this->installEntitySchema('node'); // Perform an entity query against node. diff --git a/core/modules/system/lib/Drupal/system/Tests/Common/WriteRecordTest.php b/core/modules/system/lib/Drupal/system/Tests/Common/WriteRecordTest.php index ffe5fdb..da88eda 100644 --- a/core/modules/system/lib/Drupal/system/Tests/Common/WriteRecordTest.php +++ b/core/modules/system/lib/Drupal/system/Tests/Common/WriteRecordTest.php @@ -7,19 +7,20 @@ namespace Drupal\system\Tests\Common; +use Drupal\simpletest\DrupalUnitTestBase; use Drupal\simpletest\WebTestBase; /** * Tests writing of data records with drupal_write_record(). */ -class WriteRecordTest extends WebTestBase { +class WriteRecordTest extends DrupalUnitTestBase { /** * Modules to enable. * * @var array */ - public static $modules = array('database_test', 'node'); + public static $modules = array('database_test'); public static function getInfo() { return array( @@ -33,6 +34,8 @@ public static function getInfo() { * Tests the drupal_write_record() API function. */ function testDrupalWriteRecord() { + $this->installSchema('database_test', array('test', 'test_null', 'test_serialized', 'test_composite_primary')); + // Insert a record with no columns populated. $record = array(); $insert_result = drupal_write_record('test', $record); @@ -135,15 +138,14 @@ function testDrupalWriteRecord() { $this->assertTrue($update_result == SAVED_UPDATED, 'Correct value returned when a valid update is run without changing any values.'); // Insert an object record for a table with a multi-field primary key. - $node_access = new \stdClass(); - $node_access->nid = mt_rand(); - $node_access->gid = mt_rand(); - $node_access->realm = $this->randomName(); - $insert_result = drupal_write_record('node_access', $node_access); + $composite_primary = new \stdClass(); + $composite_primary->name = $this->randomName(); + $composite_primary->age = mt_rand(); + $insert_result = drupal_write_record('test_composite_primary', $composite_primary); $this->assertTrue($insert_result == SAVED_NEW, 'Correct value returned when a record is inserted with drupal_write_record() for a table with a multi-field primary key.'); // Update the record. - $update_result = drupal_write_record('node_access', $node_access, array('nid', 'gid', 'realm')); + $update_result = drupal_write_record('test_composite_primary', $composite_primary, array('name', 'job')); $this->assertTrue($update_result == SAVED_UPDATED, 'Correct value returned when a record is updated with drupal_write_record() for a table with a multi-field primary key.'); } diff --git a/core/modules/system/lib/Drupal/system/Tests/Entity/EntityFieldTest.php b/core/modules/system/lib/Drupal/system/Tests/Entity/EntityFieldTest.php index fa80432..36b3655 100644 --- a/core/modules/system/lib/Drupal/system/Tests/Entity/EntityFieldTest.php +++ b/core/modules/system/lib/Drupal/system/Tests/Entity/EntityFieldTest.php @@ -41,7 +41,6 @@ public static function getInfo() { public function setUp() { parent::setUp(); - $this->installSchema('node', array('node_access')); $this->installEntitySchema('node'); $this->installEntitySchema('entity_test_rev'); diff --git a/core/modules/system/lib/Drupal/system/Tests/Entity/FieldAccessTest.php b/core/modules/system/lib/Drupal/system/Tests/Entity/FieldAccessTest.php index 8ab706c..d72b297 100644 --- a/core/modules/system/lib/Drupal/system/Tests/Entity/FieldAccessTest.php +++ b/core/modules/system/lib/Drupal/system/Tests/Entity/FieldAccessTest.php @@ -46,6 +46,7 @@ protected function setUp() { // The users table is needed for creating dummy user accounts. $this->installEntitySchema('user'); // Register entity_test text field. + module_load_install('entity_test'); entity_test_install(); } diff --git a/core/modules/system/tests/modules/database_test/database_test.install b/core/modules/system/tests/modules/database_test/database_test.install index 866d453..7c74c1c 100644 --- a/core/modules/system/tests/modules/database_test/database_test.install +++ b/core/modules/system/tests/modules/database_test/database_test.install @@ -245,5 +245,34 @@ function database_test_schema() { ), ); + $schema['test_composite_primary'] = array( + 'description' => 'Basic test table with a composite primary key', + 'fields' => array( + 'name' => array( + 'description' => "A person's name", + 'type' => 'varchar', + 'length' => 50, + 'not null' => TRUE, + 'default' => '', + 'binary' => TRUE, + ), + 'age' => array( + 'description' => "The person's age", + 'type' => 'int', + 'unsigned' => TRUE, + 'not null' => TRUE, + 'default' => 0, + ), + 'job' => array( + 'description' => "The person's job", + 'type' => 'varchar', + 'length' => 255, + 'not null' => TRUE, + 'default' => 'Undefined', + ), + ), + 'primary key' => array('name', 'age'), + ); + return $schema; } diff --git a/core/modules/taxonomy/lib/Drupal/taxonomy/Tests/TaxonomyTermReferenceItemTest.php b/core/modules/taxonomy/lib/Drupal/taxonomy/Tests/TaxonomyTermReferenceItemTest.php index 0dbdd35..78c877f 100644 --- a/core/modules/taxonomy/lib/Drupal/taxonomy/Tests/TaxonomyTermReferenceItemTest.php +++ b/core/modules/taxonomy/lib/Drupal/taxonomy/Tests/TaxonomyTermReferenceItemTest.php @@ -42,7 +42,7 @@ public static function getInfo() { public function setUp() { parent::setUp(); - $this->installEntitySchema('taxonomy'); + $this->installEntitySchema('taxonomy_term'); $vocabulary = entity_create('taxonomy_vocabulary', array( 'name' => $this->randomName(),