Saturday, 11 November 2017

FakeDb, Layout tests and Sitecore 9

Following the previous post on this blog involving an issue we ran into upgrading a Sitecore project from 8.2 to 9, this one is also on the same subject. The issue this time was some unit tests that make use of the FakeDb library began to fail following the upgrade.

Noticing that it was just tests that involved checking the status of layout related fields, with the help of some de-compilation, it was clear that a change had occurred in the Sitecore.Data.Fields.LayoutField.GetFieldValue method that now involve the use of a pipeline components.

I found it was possible to resolve this by adding the following to the app.config file, within the &lgt;sitecore&ggt; element, for the test projects containing the failing tests:
    <pipelines>
      <getLayoutSourceFields>
        <processor type="Sitecore.Pipelines.GetLayoutSourceFields.GetFinalLayoutField, Sitecore.Kernel" />
        <processor type="Sitecore.Pipelines.GetLayoutSourceFields.GetLayoutField, Sitecore.Kernel" />
      </getLayoutSourceFields>
    </pipelines>

Have also submitted a PR to have this added to the default configuration for FakeDb, which, if accepted and a new release created, may remove the need for this amend.

No comments:

Post a Comment