Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

9.0 Test, (Refactor) and rename Neos' Fusion View #4933

Open
mhsdesign opened this issue Mar 12, 2024 · 0 comments
Open

9.0 Test, (Refactor) and rename Neos' Fusion View #4933

mhsdesign opened this issue Mar 12, 2024 · 0 comments
Labels
9.0 Backlog A category for things that are okay to be rather 'hidden'

Comments

@mhsdesign
Copy link
Member

mhsdesign commented Mar 12, 2024

Related: to be overhauled draft pr: #4495

Wilhelm and me spend some time at the sprint discussing how the fusion view should work in the future and how it would be testable like this:

  Scenario: Page rendering
    Given the current Site package is My.Site
    And Packages Neos.Fusion and Neos.Neos are autoladed:
    When I have the fusion code for the package "My.Site":
    """fusion
    include: resource://Neos.Fusion/Private/Fusion/Root.fusion
    include: resource://Neos.Neos/Private/Fusion/Root.fusion

    prototype(Neos.Neos:Test.DocumentType1) < prototype(Neos.Fusion:Value) {
      value = 'implementation for DocumentType1'
    }
    """
    And i render the current request i expect
    """
    implementation for DocumentType2
    """

Steps

  • rename Neos's FusionView to SiteFusionView
  • extract logic to acquire document node etc to outside
    • by convention node documentNode and site must be passed, but they will be passed straight into the fusion runtime
    • other variables would work as well
    • maybe: throw an error if value is assigned as there is no legacy behaviour for this anymore?
  • the fusion view requires a dynamic variable / or option? siteResourcePackageKey which will be used to include the site package and as cache identifier in production
  • the view will get an additional option 'autoIncludes' => [] which can be configured for testing for example like ['Neos.Neos', 'Neos.Fusion'], if empty the global Neos.Neos.fusion.autoInclude configuration will be used.
  • Introduce package key dto in flow
  • ✅ introduce FusionAutoIncludeHandler in Neos.Neos that can be stubbed for testing, but by default checks if the package exits and loads the file from resource:// (resolved via TASK: Introduce full behat test for FrontendNodeController #5305)
interface FusionAutoIncludeHandler
{
    public function loadFusionFromPackage(string $packageKey, FusionSourceCodeCollection $sourceCodeCollection): FusionSourceCodeCollection;
}

which will be used like this in the fusion view

$sourceCodeCollection = FusionSourceCodeCollection::empty();
foreach ($this->getOption('autoInclude') ?: array_keys(array_filter($this->fusionAutoIncludeConfiguration, fn ($val) => $val === true)) as $packageKey) {
    $sourceCodeCollection = $this->fusionLoader->loadFusionFromPackage($packageKey, $sourceCodeCollection);
}

in the FusionService - which is discussable if we still need this empty service ... (see @todo reintroduce with edit preview mode support)

public function createFusionConfigurationFromSite(Site $site, FusionSourceCodeCollection $sourceCode): FusionConfiguration
{
    return $this->fusionConfigurationCache->cacheFusionConfigurationBySite($site, function () use ($site, $sourceCode) {
        $siteResourcesPackageKey = $site->getSiteResourcesPackageKey();
        $protypeGenerantorstuff = $this->fusionSourceCodeFactory->createFromNodeTypeDefinitions($site->getConfiguration()->contentRepositoryId);
        return $this->fusionParser->parseFromSource(
            $this->fusionLoader->loadFusionFromPackage(
                $siteResourcesPackageKey,
                $protypeGenerantorstuff
                    ->union($sourceCode)
            )

        );
    });
}

For testing the FusionAutoIncludeHandler will just return either the actual sources for Neos.Neos or fake stuff declared for MyTemp.Package

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
9.0 Backlog A category for things that are okay to be rather 'hidden'
Projects
None yet
Development

No branches or pull requests

1 participant