Dec 27, 2014
Beta 3 --> Beta 4: Configuration schema and metadata
When I attempted to run the automated test suite for the module, several of the tests failed that had passed in the previous beta of D8.
But the following fatal error was also displayed:
Uncaught PHP Exception Drupal\Core\Config\Schema\SchemaIncompleteException: "No schema for optimizely.settings" at /var/www/html/opti/core/lib/Drupal/Core/Config/Testing/ConfigSchemaChecker.php line 91
For the module, optimizely.settings is the name of a group of configuration settings that are implemented using the Simple Configuration API, which I blogged about in this post.
So what happened?
As of Beta 4, by default the TestBase class and its derived classes such as WebTestBase are required to provide schemas for configuration data. This can be done through use of a .schema.yml file.
For example, for the optimizely module, I created the file
whose contents are
label: 'Optimizely Config Data'
label: 'Optimizely ID Number'
The type property indicates that this schema is to provide static mappings. The mapping property then describes one or more settings. In this case, there is just the one setting optimizely_id.
Besides integer, other commonly used types would be string and text. There are several others that are pre-defined, and you can also define your own type.
The translatable property is false by default but I decided to explicitly code it to emphasize that a primary purpose of these schemas is to document items that may need to be translated.
For each group of settings such as optimizely.settings, there may be an additional file named optimizely.settings.yml that provides other data about those settings, such as their values. I didn't need such a file here, but the source articles give examples and a lot of info.
One final thing: if you really don't want to adhere to this requirement, you can disable the check for the presence of schemas by including the following line in your test class. However, this is an expediency that is discouraged.
protected $strictConfigSchema = FALSE;
Update: the langcode key is now required for automated testing. See http://optimizely-to-drupal-8.blogspot.com/2015/12/drupal-8-beta-14-beta-15-missing.html
All TestBase derived tests now enforce strict configuration schema adherence by default