diff --git a/.woodpecker/code-style.yml b/.woodpecker/code-style.yml new file mode 100644 index 0000000..6f13ed1 --- /dev/null +++ b/.woodpecker/code-style.yml @@ -0,0 +1,10 @@ +steps: + code-style: + image: composer + commands: + - composer global config repositories.repo-name vcs https://git.digital-competence.de/Packages/php-codesniffer + - composer global config --no-plugins allow-plugins.dealerdirect/phpcodesniffer-composer-installer true + - composer global require digicomp/php-codesniffer:@dev + - composer global exec -- phpcs --runtime-set ignore_warnings_on_exit 1 --standard=DigiComp Classes/ Tests/ + when: + - event: [push, pull_request, manual] diff --git a/.woodpecker/functional-tests.yml b/.woodpecker/functional-tests.yml new file mode 100644 index 0000000..ecfbb6b --- /dev/null +++ b/.woodpecker/functional-tests.yml @@ -0,0 +1,34 @@ +workspace: + base: /woodpecker + path: package + +matrix: + include: + - FLOW_VERSION: 6.3 + PHP_VERSION: 7.4 + - FLOW_VERSION: 7.3 + PHP_VERSION: 7.4 + - FLOW_VERSION: 7.3 + PHP_VERSION: 8.2 + - FLOW_VERSION: 8.2 + PHP_VERSION: 8.2 + +steps: + functional-tests: + image: "thecodingmachine/php:${PHP_VERSION}-v4-cli" + environment: + # Enable the PDO_SQLITE extension + - "PHP_EXTENSION_PDO_SQLITE=1" + - "FLOW_VERSION=${FLOW_VERSION}" + - "NEOS_BUILD_DIR=/woodpecker/Build-${FLOW_VERSION}" + commands: + - "sudo mkdir $NEOS_BUILD_DIR" + - "sudo chown -R docker:docker $NEOS_BUILD_DIR" + - "cd $NEOS_BUILD_DIR" + - "composer create-project --no-install neos/flow-base-distribution:^$FLOW_VERSION ." + - "composer config repositories.repo-name path /woodpecker/package" + - "composer remove --dev --no-update neos/behat || composer remove --no-update neos/behat" + - "composer require digicomp/fluid-currentcontroller-expression:@dev" + - "bin/phpunit --configuration Build/BuildEssentials/PhpUnit/FunctionalTests.xml Packages/Application/DigiComp.FluidCurrentControllerExpression/Tests/Functional" + when: + - event: [ push, pull_request, manual ] diff --git a/Classes/CurrentControllerExpressionNode.php b/Classes/CurrentControllerExpressionNode.php new file mode 100644 index 0000000..66778c2 --- /dev/null +++ b/Classes/CurrentControllerExpressionNode.php @@ -0,0 +1,41 @@ +getControllerContext()->getRequest(), + $propertyToReturn + ); + } + return ''; + } +} diff --git a/Configuration/Objects.yaml b/Configuration/Objects.yaml new file mode 100644 index 0000000..7fadaa7 --- /dev/null +++ b/Configuration/Objects.yaml @@ -0,0 +1,9 @@ +Neos\FluidAdaptor\Core\Rendering\RenderingContext: + properties: + expressionNodeTypes: + value: + - Neos\FluidAdaptor\Core\Parser\SyntaxTree\Expression\LegacyNamespaceExpressionNode + - TYPO3Fluid\Fluid\Core\Parser\SyntaxTree\Expression\CastingExpressionNode + - TYPO3Fluid\Fluid\Core\Parser\SyntaxTree\Expression\MathExpressionNode + - TYPO3Fluid\Fluid\Core\Parser\SyntaxTree\Expression\TernaryExpressionNode + - DigiComp\FluidCurrentControllerExpression\CurrentControllerExpressionNode diff --git a/Configuration/Testing/Views.yaml b/Configuration/Testing/Views.yaml new file mode 100644 index 0000000..6da4506 --- /dev/null +++ b/Configuration/Testing/Views.yaml @@ -0,0 +1,7 @@ +- + requestFilter: 'isFormat("html") && isPackage("DigiComp.FluidCurrentControllerExpression")' + options: + layoutRootPaths: + - "resource://DigiComp.FluidCurrentControllerExpression/Private/Layouts" + partialRootPaths: + - "resource://DigiComp.FluidCurrentControllerExpression/Private/Partials" diff --git a/Resources/Private/Layouts/Test.html b/Resources/Private/Layouts/Test.html new file mode 100644 index 0000000..24f730c --- /dev/null +++ b/Resources/Private/Layouts/Test.html @@ -0,0 +1 @@ + diff --git a/Resources/Private/Templates/Tests/Functional/Fixtures/Test/Index.html b/Resources/Private/Templates/Tests/Functional/Fixtures/Test/Index.html new file mode 100644 index 0000000..48b6549 --- /dev/null +++ b/Resources/Private/Templates/Tests/Functional/Fixtures/Test/Index.html @@ -0,0 +1,6 @@ +{currentController:name} +{currentController:actionName} +{currentController:packageKey} +{currentController:subpackageKey} +{currentController:objectName} +{currentController:format} diff --git a/Resources/Private/Templates/Tests/Functional/Fixtures/Test/WithLayout.html b/Resources/Private/Templates/Tests/Functional/Fixtures/Test/WithLayout.html new file mode 100644 index 0000000..a20d817 --- /dev/null +++ b/Resources/Private/Templates/Tests/Functional/Fixtures/Test/WithLayout.html @@ -0,0 +1,7 @@ + +{currentController:name} +{currentController:actionName} +{currentController:packageKey} +{currentController:subpackageKey} +{currentController:objectName} +{currentController:format} diff --git a/Tests/Functional/CurrentControllerExpressionNodeTest.php b/Tests/Functional/CurrentControllerExpressionNodeTest.php new file mode 100644 index 0000000..0f73e9c --- /dev/null +++ b/Tests/Functional/CurrentControllerExpressionNodeTest.php @@ -0,0 +1,65 @@ +setUriPattern('test/currentcontrollerexpressions/test(/{@action})'); + $route->setDefaults([ + '@package' => 'DigiComp.FluidCurrentControllerExpression', + '@subpackage' => 'Tests\Functional\Fixtures', + '@controller' => 'Test', + '@action' => 'index', + ]); + $route->setAppendExceedingArguments(true); + $this->router->addRoute($route); + } + + /** + * @test + */ + public function itReturnsCurrentControllerInformations(): void + { + $response = $this->browser->request('http://localhost/test/currentcontrollerexpressions/test'); + static::assertEquals( + 'Test +index +DigiComp.FluidCurrentControllerExpression +Tests\Functional\Fixtures +DigiComp\FluidCurrentControllerExpression\Tests\Functional\Fixtures\Controller\TestController +html +', + (string)$response->getBody() + ); + + $response = $this->browser->request('http://localhost/test/currentcontrollerexpressions/test/withlayout'); + static::assertEquals( + 'Test +withLayout +DigiComp.FluidCurrentControllerExpression +Tests\Functional\Fixtures +DigiComp\FluidCurrentControllerExpression\Tests\Functional\Fixtures\Controller\TestController +html +', + (string)$response->getBody() + ); + } +} diff --git a/Tests/Functional/Fixtures/Controller/TestController.php b/Tests/Functional/Fixtures/Controller/TestController.php new file mode 100644 index 0000000..19911f3 --- /dev/null +++ b/Tests/Functional/Fixtures/Controller/TestController.php @@ -0,0 +1,18 @@ +