Skip to content

Commit

Permalink
Merge branch 'release/0.7.26'
Browse files Browse the repository at this point in the history
  • Loading branch information
eliashaeussler committed Nov 24, 2023
2 parents f54337d + 36548aa commit 38b7319
Show file tree
Hide file tree
Showing 17 changed files with 399 additions and 537 deletions.
1 change: 0 additions & 1 deletion .gitattributes
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,6 @@
/docker-compose.yml export-ignore
/packaging_exclude.php export-ignore
/phpstan.neon export-ignore
/phpstan-baseline.neon export-ignore
/phpunit.xml export-ignore
/rector.php export-ignore
/renovate.json export-ignore
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/cgl.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ jobs:
- name: Setup PHP
uses: shivammathur/setup-php@v2
with:
php-version: 8.1
php-version: 8.2
tools: composer:v2, composer-require-checker, composer-unused
coverage: none

Expand Down
40 changes: 35 additions & 5 deletions .github/workflows/tests.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ jobs:
fail-fast: false
matrix:
typo3-version: ["10.4", "11.5"]
php-version: ["7.4", "8.0", "8.1", "8.2"]
php-version: ["7.4", "8.0", "8.1", "8.2", "8.3"]
dependencies: ["highest", "lowest"]
exclude:
- typo3-version: "10.4"
Expand All @@ -25,6 +25,8 @@ jobs:
php-version: "8.1"
- typo3-version: "10.4"
php-version: "8.2"
- typo3-version: "10.4"
php-version: "8.3"
steps:
- uses: actions/checkout@v4
with:
Expand Down Expand Up @@ -61,7 +63,7 @@ jobs:
- name: Setup PHP
uses: shivammathur/setup-php@v2
with:
php-version: 8.1
php-version: 8.3
tools: composer:v2
coverage: pcov

Expand All @@ -73,21 +75,49 @@ jobs:
- name: Run tests
run: composer test:coverage

# Report coverage
# Upload artifact
- name: Fix coverage path
working-directory: .Build/log/coverage
run: sed -i 's#/home/runner/work/handlebars/handlebars#${{ github.workspace }}#g' clover.xml
- name: Upload coverage artifact
uses: actions/upload-artifact@v3
with:
name: coverage
path: .Build/log/coverage/clover.xml
retention-days: 7

coverage-report:
name: Report test coverage
runs-on: ubuntu-latest
needs: coverage
steps:
- uses: actions/checkout@v4
with:
fetch-depth: 0

# Download artifact
- name: Download coverage artifact
id: download
uses: actions/download-artifact@v3
with:
name: coverage

# CodeClimate
- name: CodeClimate report
uses: paambaati/[email protected]
if: env.CC_TEST_REPORTER_ID
env:
CC_TEST_REPORTER_ID: ${{ secrets.CC_TEST_REPORTER_ID }}
with:
coverageLocations: |
${{ github.workspace }}/.Build/log/coverage/clover.xml:clover
${{ steps.download.outputs.download-path }}/clover.xml:clover
# codecov
- name: codecov report
uses: codecov/codecov-action@v3
with:
token: ${{ secrets.CODECOV_TOKEN }}
directory: .Build/log/coverage
files: |
${{ steps.download.outputs.download-path }}/clover.xml
fail_ci_if_error: true
verbose: true
2 changes: 1 addition & 1 deletion Documentation/Installation/Index.rst
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ Installation
Requirements
============

* PHP 7.1 - 8.2
* PHP 7.1 - 8.3
* TYPO3 10.4 LTS - 11.5 LTS

.. _steps:
Expand Down
2 changes: 1 addition & 1 deletion Documentation/Settings.cfg
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[general]
project = Handlebars
release = 0.7.25
release = 0.7.26
copyright = since 2020 by coding. powerful. systems. CPS GmbH
author = Elias Häußler

Expand Down
23 changes: 10 additions & 13 deletions Tests/Unit/Cache/HandlebarsCacheTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -25,9 +25,7 @@

use Fr\Typo3Handlebars\Cache\HandlebarsCache;
use Fr\Typo3Handlebars\Tests\Unit\HandlebarsCacheTrait;
use Prophecy\Argument;
use Prophecy\PhpUnit\ProphecyTrait;
use Prophecy\Prophecy\ObjectProphecy;
use PHPUnit\Framework\MockObject\MockObject;
use TYPO3\CMS\Core\Cache\Frontend\FrontendInterface;
use TYPO3\TestingFramework\Core\Unit\UnitTestCase;

Expand All @@ -40,12 +38,11 @@
class HandlebarsCacheTest extends UnitTestCase
{
use HandlebarsCacheTrait;
use ProphecyTrait;

/**
* @var ObjectProphecy|FrontendInterface
* @var FrontendInterface&MockObject
*/
protected $cacheProphecy;
protected $cacheMock;

/**
* @var HandlebarsCache
Expand All @@ -57,15 +54,15 @@ protected function setUp(): void
parent::setUp();

$cache = $this->getCache();
$this->cacheProphecy = $this->prophesize(FrontendInterface::class);
$this->cacheProphecy->get(Argument::type('string'))->will(function (array $parameters) use ($cache) {
$cachedTemplate = $cache->get($parameters[0]);
return $cachedTemplate;

$this->cacheMock = $this->createMock(FrontendInterface::class);
$this->cacheMock->method('get')->willReturnCallback(function (string $entryIdentifier) use ($cache) {
return $cache->get($entryIdentifier);
});
$this->cacheProphecy->set(Argument::type('string'), Argument::type('string'))->will(function (array $parameters) use ($cache) {
$cache->set($parameters[0], $parameters[1]);
$this->cacheMock->method('set')->willReturnCallback(function (string $entryIdentifier, $data) use ($cache) {
$cache->set($entryIdentifier, $data);
});
$this->subject = new HandlebarsCache($this->cacheProphecy->reveal());
$this->subject = new HandlebarsCache($this->cacheMock);
}

/**
Expand Down
9 changes: 3 additions & 6 deletions Tests/Unit/Compatibility/View/HandlebarsViewResolverTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,6 @@
use Fr\Typo3Handlebars\Tests\Unit\Fixtures\Classes\DataProcessing\DummyProcessor;
use Fr\Typo3Handlebars\Tests\Unit\Fixtures\Classes\DummyConfigurationManager;
use Fr\Typo3Handlebars\Tests\Unit\Fixtures\Classes\DummyView;
use Prophecy\PhpUnit\ProphecyTrait;
use Symfony\Component\DependencyInjection\Container;
use TYPO3\CMS\Core\Information\Typo3Version;
use TYPO3\CMS\Extbase\Object\ObjectManager;
Expand All @@ -43,8 +42,6 @@
*/
class HandlebarsViewResolverTest extends UnitTestCase
{
use ProphecyTrait;

/**
* @var DummyProcessor
*/
Expand All @@ -65,9 +62,9 @@ protected function setUp(): void
// Handle different constructor arguments between TYPO3 11.4+ and lower
$typo3Version = new Typo3Version();
if ($typo3Version->getMajorVersion() < 11) {
$objectManagerProphecy = $this->prophesize(ObjectManager::class);
$objectManagerProphecy->get('foo')->willReturn(new DummyView());
$firstConstructorArgument = $objectManagerProphecy->reveal();
$objectManagerMock = $this->createMock(ObjectManager::class);
$objectManagerMock->method('get')->with('foo')->willReturn(new DummyView());
$firstConstructorArgument = $objectManagerMock;
} else {
$container = new Container();
$container->set('foo', new DummyView());
Expand Down
16 changes: 7 additions & 9 deletions Tests/Unit/DataProcessing/SimpleProcessorTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -29,8 +29,7 @@
use Fr\Typo3Handlebars\Renderer\Helper\VarDumpHelper;
use Fr\Typo3Handlebars\Tests\Unit\HandlebarsCacheTrait;
use Fr\Typo3Handlebars\Tests\Unit\HandlebarsTemplateResolverTrait;
use Prophecy\PhpUnit\ProphecyTrait;
use Prophecy\Prophecy\ObjectProphecy;
use PHPUnit\Framework\MockObject\MockObject;
use Psr\Log\Test\TestLogger;
use Symfony\Component\EventDispatcher\EventDispatcher;
use TYPO3\CMS\Core\Http\ServerRequest;
Expand All @@ -48,12 +47,11 @@ class SimpleProcessorTest extends UnitTestCase
{
use HandlebarsCacheTrait;
use HandlebarsTemplateResolverTrait;
use ProphecyTrait;

/**
* @var ObjectProphecy|ContentObjectRenderer
* @var ContentObjectRenderer&MockObject
*/
protected $contentObjectRendererProphecy;
protected $contentObjectRendererMock;

/**
* @var TestLogger
Expand All @@ -74,15 +72,15 @@ protected function setUp(): void
{
parent::setUp();

$this->contentObjectRendererProphecy = $this->prophesize(ContentObjectRenderer::class);
$this->contentObjectRendererMock = $this->createMock(ContentObjectRenderer::class);
$this->logger = new TestLogger();
$this->renderer = new HandlebarsRenderer($this->getCache(), new EventDispatcher(), $this->getTemplateResolver());
$this->subject = new SimpleProcessor($this->renderer);
$this->subject->cObj = $this->contentObjectRendererProphecy->reveal();
$this->subject->cObj = $this->contentObjectRendererMock;
$this->subject->setLogger($this->logger);

$GLOBALS['TYPO3_REQUEST'] = new ServerRequest();
$GLOBALS['TSFE'] = $this->prophesize(TypoScriptFrontendController::class)->reveal();
$GLOBALS['TSFE'] = $this->createMock(TypoScriptFrontendController::class);
}

/**
Expand Down Expand Up @@ -115,7 +113,7 @@ public function processReturnsRenderedTemplate(): void
'title' => 'foo',
'comment' => 'baz',
];
$this->contentObjectRendererProphecy->data = $data;
$this->contentObjectRendererMock->data = $data;

$configuration = [
'userFunc.' => [
Expand Down
5 changes: 1 addition & 4 deletions Tests/Unit/Event/AfterRenderingEventTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,6 @@

use Fr\Typo3Handlebars\Event\AfterRenderingEvent;
use Fr\Typo3Handlebars\Renderer\HandlebarsRenderer;
use Prophecy\PhpUnit\ProphecyTrait;
use TYPO3\TestingFramework\Core\Unit\UnitTestCase;

/**
Expand All @@ -36,8 +35,6 @@
*/
class AfterRenderingEventTest extends UnitTestCase
{
use ProphecyTrait;

/**
* @var AfterRenderingEvent
*/
Expand All @@ -46,7 +43,7 @@ class AfterRenderingEventTest extends UnitTestCase
protected function setUp(): void
{
parent::setUp();
$this->subject = new AfterRenderingEvent('foo', 'baz', $this->prophesize(HandlebarsRenderer::class)->reveal());
$this->subject = new AfterRenderingEvent('foo', 'baz', $this->createMock(HandlebarsRenderer::class));
}

/**
Expand Down
5 changes: 1 addition & 4 deletions Tests/Unit/Event/BeforeRenderingEventTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,6 @@

use Fr\Typo3Handlebars\Event\BeforeRenderingEvent;
use Fr\Typo3Handlebars\Renderer\HandlebarsRenderer;
use Prophecy\PhpUnit\ProphecyTrait;
use TYPO3\TestingFramework\Core\Unit\UnitTestCase;

/**
Expand All @@ -36,8 +35,6 @@
*/
class BeforeRenderingEventTest extends UnitTestCase
{
use ProphecyTrait;

/**
* @var BeforeRenderingEvent
*/
Expand All @@ -46,7 +43,7 @@ class BeforeRenderingEventTest extends UnitTestCase
protected function setUp(): void
{
parent::setUp();
$this->subject = new BeforeRenderingEvent('foo', ['foo' => 'baz'], $this->prophesize(HandlebarsRenderer::class)->reveal());
$this->subject = new BeforeRenderingEvent('foo', ['foo' => 'baz'], $this->createMock(HandlebarsRenderer::class));
}

/**
Expand Down
18 changes: 8 additions & 10 deletions Tests/Unit/Renderer/HandlebarsRendererTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -32,8 +32,7 @@
use Fr\Typo3Handlebars\Tests\Unit\Fixtures\Classes\Renderer\Template\DummyTemplateResolver;
use Fr\Typo3Handlebars\Tests\Unit\HandlebarsCacheTrait;
use Fr\Typo3Handlebars\Tests\Unit\HandlebarsTemplateResolverTrait;
use Prophecy\PhpUnit\ProphecyTrait;
use Prophecy\Prophecy\ObjectProphecy;
use PHPUnit\Framework\MockObject\MockObject;
use Psr\Log\Test\TestLogger;
use Symfony\Component\EventDispatcher\EventDispatcher;
use TYPO3\CMS\Frontend\Controller\TypoScriptFrontendController;
Expand All @@ -49,7 +48,6 @@ class HandlebarsRendererTest extends UnitTestCase
{
use HandlebarsCacheTrait;
use HandlebarsTemplateResolverTrait;
use ProphecyTrait;

/**
* @var TestLogger
Expand All @@ -62,18 +60,18 @@ class HandlebarsRendererTest extends UnitTestCase
protected $subject;

/**
* @var ObjectProphecy|TypoScriptFrontendController
* @var TypoScriptFrontendController&MockObject
*/
protected $tsfeProphecy;
protected $tsfeMock;

protected function setUp(): void
{
parent::setUp();

$this->renewSubject();
$this->tsfeProphecy = $this->prophesize(TypoScriptFrontendController::class);
$this->tsfeMock = $this->createMock(TypoScriptFrontendController::class);

$GLOBALS['TSFE'] = $this->tsfeProphecy->reveal();
$GLOBALS['TSFE'] = $this->tsfeMock;
}

/**
Expand Down Expand Up @@ -188,12 +186,12 @@ public function renderLogsCriticalErrorIfTemplateCompilationFails(): void
public function renderDoesNotStoreRenderedTemplateInCacheIfDebugModeIsEnabled(): void
{
// Test with TypoScript config.debug = 1
$this->tsfeProphecy->config = ['config' => ['debug' => '1']];
$this->tsfeMock->config = ['config' => ['debug' => '1']];
$this->renewSubject()->render('DummyTemplate');
$this->assertCacheIsEmptyForTemplate('DummyTemplate.hbs');

// Test with TYPO3_CONF_VARS
$this->tsfeProphecy->config = [];
$this->tsfeMock->config = [];
$GLOBALS['TYPO3_CONF_VARS']['FE']['debug'] = 1;
$this->renewSubject()->render('DummyTemplate');
$this->assertCacheIsEmptyForTemplate('DummyTemplate.hbs');
Expand All @@ -204,7 +202,7 @@ public function renderDoesNotStoreRenderedTemplateInCacheIfDebugModeIsEnabled():
*/
public function renderDoesNotStoreRenderedTemplateInCacheIfCachingIsDisabled(): void
{
$this->tsfeProphecy->no_cache = true;
$this->tsfeMock->no_cache = true;
$this->subject->render('DummyTemplate');
$this->assertCacheIsEmptyForTemplate('DummyTemplate.hbs');
}
Expand Down
Loading

0 comments on commit 38b7319

Please sign in to comment.