1. Go to this page and download the library: Download sandstorm/e2etesttools library. Choose the download type require.
2. Extract the ZIP file and open the index.php.
3. Add this code to the index.php.
<?php
require_once('vendor/autoload.php');
/* Start to develop here. Best regards https://php-download.com/ */
sandstorm / e2etesttools example snippets
use Behat\Behat\Context\Context;
use Neos\Behat\Tests\Behat\FlowContextTrait;
use Neos\ContentRepository\Tests\Behavior\Features\Bootstrap\NodeOperationsTrait;
use Neos\Flow\ObjectManagement\ObjectManagerInterface;
use Neos\Flow\Tests\Behavior\Features\Bootstrap\SecurityOperationsTrait;
use Sandstorm\E2ETestTools\Tests\Behavior\Bootstrap\FusionRenderingTrait;
use Sandstorm\E2ETestTools\Tests\Behavior\Bootstrap\PlaywrightTrait;
__DIR__ . '/../../../../../../Packages/Application/Sandstorm.E2ETestTools/Tests/Behavior/Bootstrap/PlaywrightTrait.php');
class FeatureContext implements Context
{
// This is for integration with Flow (so you have access to $this->objectManager of Flow). (part of Neos.Behat)
use FlowContextTrait;
// prerequisite of NodeOperationsTrait (part of Neos.Flow)
use SecurityOperationsTrait;
// create Nodes etc. in Behat tests (part of Neos.ContentRepository)
use NodeOperationsTrait {
// take overridden "iHaveTheFollowingNodes" from FusionRenderingTrait
FusionRenderingTrait::iHaveTheFollowingNodes insteadof NodeOperationsTrait;
}
// Render Fusion code and Styleguide (part of Sandstorm.E2ETestTools)
use FusionRenderingTrait;
// Browser Automation
use PlaywrightTrait;
/**
* @var ObjectManagerInterface
*/
protected $objectManager;
public function __construct()
{
if (self::$bootstrap === null) {
self::$bootstrap = $this->initializeFlow();
}
$this->objectManager = self::$bootstrap->getObjectManager();
$this->setupSecurity();
$this->setupPlaywright();
// !!! You need to add the Site Package Key here, so that we are able to load the Fusion code properly.
$this->setupFusionRendering('Site.Package.Key.Here');
// !!! Important for usage with Neos: you need to publish resources that are created from fixtures
$this->PersistentResourceTrait_registerResourcePersistedHook(function () {
// publish resources post persist hook for PersistentResources created by fixtures
// execute a: './flow resource:publish'
});
}
/**
* @return ObjectManagerInterface
*/
public function getObjectManager(): ObjectManagerInterface
{
return $this->objectManager;
}
}
namespace PACKAGEKEY\Command;
use Neos\ContentRepository\Domain\Model\NodeInterface;
use Neos\ContentRepository\Domain\Service\ContextFactoryInterface;
use Neos\Flow\Annotations as Flow;
use Neos\Flow\Cli\CommandController;
use Sandstorm\E2ETestTools\StepGenerator\NodeTableBuilderService;
class StepGeneratorCommandController extends CommandController
{
/**
* @Flow\Inject
*/
protected ContextFactoryInterface $contextFactory;
/**
* Main API for creating NodeTable instances to print BDD steps.
*
* @Flow\Inject
*/
protected NodeTableBuilderService $nodeTableBuilderService;
public function homepageCommand()
{
$nodeTable = $this->nodeTableBuilderService->nodeTable()
->withDefaultNodeProperties(['Language' => 'de'])
->build();
$siteNode = $this->getSiteNode();
$nodeTable->addParents($siteNode);
$nodeTable->addNode($siteNode);
$nodeTable->addNodesUnderneathExcludingAutoGeneratedChildNodes($siteNode, '!Neos.Neos:Document'); // we recurse into the content of the homepage
$nodeTable->addNodesUnderneathExcludingAutoGeneratedChildNodes($siteNode, 'Neos.Neos:Document'); // we render the remaining document nodes so we can have a menu rendered (but without content)
$nodeTable->print();
}
/**
* @return NodeInterface
*/
public function getSiteNode(): NodeInterface
{
$context = $this->contextFactory->create([
'workspaceName' => 'live',
'invisibleContentShown' => true,
'dimensions' => [
'language' => ['de']
],
'targetDimensions' => [
'language' => 'de'
]
]);
return $context->getCurrentSiteNode();
}
}
// ... Step Generator Command Controller
public function homepageCommand()
{
$nodeTable = $this->nodeTableBuilderService->nodeTable()
->withDefaultNodeProperties(['Language' => 'de'])
// !!! Here you setup your directory for storing your fixture files.
// It will print a path relative to the Flow package directory.
// -> most likely: Sites/Your.PackageKey/Tests/Behavior/Features/Homepage/Resources/someSHA1.png (depending on the type of the composer package)
->withFixtureBasePath('Your.PackageKey', 'Tests/Behavior/Features/Homepage/Resources/')
->build();
$siteNode = $this->getSiteNode();
$nodeTable->addParents($siteNode);
$nodeTable->addNode($siteNode);
$nodeTable->addNodesUnderneathExcludingAutoGeneratedChildNodes($siteNode, '!Neos.Neos:Document'); // we recurse into the content of the homepage
$nodeTable->addNodesUnderneathExcludingAutoGeneratedChildNodes($siteNode, 'Neos.Neos:Document'); // we render the remaining document nodes so we can have a menu rendered (but without content)
// when the table is printed, it
...
/**
* @Given my base URL is :baseUrl
*/
public function myBaseUrlIs($baseUrl)
{
$this->setSystemUnderTestUrlModifier(function (string $staticBaseUrl) use ($baseUrl) {
return $baseUrl;
});
}
/**
* @Given my subdomain is :subdomain
*/
public function mySubdomainIs($subdomain)
{
$this->setSystemUnderTestUrlModifier(function (string $baseUrl) use ($subdomain) {
return sprintf("%s://%s.%s.nip.io:%s/%s",
parse_url($baseUrl, PHP_URL_SCHEME),
$subdomain,
parse_url($baseUrl, PHP_URL_HOST),
parse_url($baseUrl, PHP_URL_PORT),
parse_url($baseUrl, PHP_URL_PATH),
);
});
}
...
Loading please wait ...
Before you can download the PHP files, the dependencies should be resolved. This can take some minutes. Please be patient.