Skip to content

Commit

Permalink
Fix tests and a warning with php 8 (#9)
Browse files Browse the repository at this point in the history
* fixed test setup

* fixed typo

* updated workflow

* fix

* workflow fix

* another fix

* fix

* fix

* fixed warnings in php 8

* updated and fixed tests

* updated workflow

* removed unused dev deps
  • Loading branch information
koertho committed Aug 18, 2022
1 parent f2b121f commit 81cc4d1
Show file tree
Hide file tree
Showing 8 changed files with 32 additions and 25 deletions.
12 changes: 6 additions & 6 deletions .github/workflows/ci.yml
Expand Up @@ -9,13 +9,13 @@ jobs:
strategy:
fail-fast: false
matrix:
php: [ 7.2., 7.3, 7.4, 8.0 ]
contao: [ 4.4.*, 4.9.*, 4.10.* ]
php: [ 7.2, 7.3, 7.4, 8.0 ]
contao: [ 4.9.*, 4.13.* ]
exclude:
- php: 8.0
contao: 4.4.*
- php: 7.2
contao: 4.*
contao: 4.13.*
- php: 7.3
contao: 4.13.*
steps:
- name: Setup PHP
uses: shivammathur/setup-php@v2
Expand All @@ -31,7 +31,7 @@ jobs:
- name: Install the dependencies
id: composer-install
run: composer require contao/core-bundle:${{ matrix.contao }} --no-interaction
continue-on-error: ${{ matrix.php == 8.0 }}
# continue-on-error: ${{ matrix.contao == 4.13.* }}

- name: Run the unit tests
if: steps.composer-install.conclusion == 'success' && steps.composer-install.outcome == 'success'
Expand Down
2 changes: 2 additions & 0 deletions .gitignore
@@ -1,3 +1,5 @@
composer.lock
.idea
vendor
.phpunit.result.cache
.ddev
3 changes: 3 additions & 0 deletions CHANGELOG.md
Expand Up @@ -4,6 +4,9 @@ All notable changes to this project will be documented in this file.

This project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).

## [1.5.9] - 2022-06-02
- Fixed: warning in php 8

## [1.5.8] - 2022-03-25
- Fixed: exception if the templates folder does not exist ([#8], [@qzminski])

Expand Down
22 changes: 12 additions & 10 deletions composer.json
Expand Up @@ -19,18 +19,14 @@
"webmozart/path-util": "^2.3"
},
"require-dev": {
"contao/test-case": "1.1.*",
"contao/core-bundle": ">=4.4.0,<4.11",
"contao/core-bundle": "^4.13",
"contao/test-case": "^4.9",
"contao/manager-plugin": "^2.0",
"friendsofphp/php-cs-fixer": "^2.2",
"phpunit/phpunit": "^6.5",
"phpunit/phpunit-mock-objects": "^4.0|^5.0",
"phpunit/php-token-stream": "^1.4|^2.0|^3.0",
"php-http/guzzle6-adapter": "^1.1",
"php-http/message-factory": "^1.0.2",
"satooshi/php-coveralls": "^2.0",
"symfony/phpunit-bridge": "^3.2",
"heimrichhannot/contao-test-utilities-bundle": "^0.1.3"
"phpunit/phpunit": "^8.0",
"php-coveralls/php-coveralls": "^2.0",
"symfony/phpunit-bridge": "^4.4 || ^5.4",
"heimrichhannot/contao-test-utilities-bundle": "^0.1.5"
},
"autoload": {
"psr-4": {
Expand All @@ -44,5 +40,11 @@
},
"extra": {
"contao-manager-plugin": "HeimrichHannot\\TwigSupportBundle\\ContaoManager\\Plugin"
},
"config": {
"allow-plugins": {
"contao-components/installer": true,
"contao/manager-plugin": true
}
}
}
2 changes: 1 addition & 1 deletion phpunit.xml.dist
Expand Up @@ -12,7 +12,7 @@
convertWarningsToExceptions="true"
processIsolation="false"
stopOnFailure="false"
syntaxCheck="false">
>
<php>
<ini name="error_reporting" value="-1"/>
<ini name="display_errors" value="1"/>
Expand Down
4 changes: 2 additions & 2 deletions src/Helper/NormalizerHelper.php
@@ -1,7 +1,7 @@
<?php

/*
* Copyright (c) 2020 Heimrich & Hannot GmbH
* Copyright (c) 2022 Heimrich & Hannot GmbH
*
* @license LGPL-3.0-or-later
*/
Expand Down Expand Up @@ -101,7 +101,7 @@ public function normalizeObject($object, $data = [], $options = []): array
$method->setAccessible(true);
$data[$property] = $method->invoke($object);
} else {
$data[$property] = $object->{$method->name}();
$data[$property] = @$object->{$method->name}();
}

if (\is_object($data[$property])) {
Expand Down
8 changes: 4 additions & 4 deletions tests/EventListener/RenderListenerTest.php
@@ -1,7 +1,7 @@
<?php

/*
* Copyright (c) 2021 Heimrich & Hannot GmbH
* Copyright (c) 2022 Heimrich & Hannot GmbH
*
* @license LGPL-3.0-or-later
*/
Expand Down Expand Up @@ -41,7 +41,7 @@ public function createTestInstance(array $parameters = [], ?MockBuilder $mockBui

if (!isset($parameters['eventDispatcher'])) {
$eventDispatcher = $this->createMock(EventDispatcherInterface::class);
$eventDispatcher->method('dispatch')->willReturnArgument(1);
$eventDispatcher->method('dispatch')->willReturnArgument(0);
$parameters['eventDispatcher'] = $eventDispatcher;
}

Expand Down Expand Up @@ -185,7 +185,7 @@ public function testOnParseWidgetSkipTemplates()
public function testPrepareContaoTemplateSkipOnException()
{
$dispatcher = $this->createMock(EventDispatcherInterface::class);
$dispatcher->method('dispatch')->willReturnCallback(function ($eventName, BeforeParseTwigTemplateEvent $event) {
$dispatcher->method('dispatch')->willReturnCallback(function (BeforeParseTwigTemplateEvent $event, $eventName = '') {
if ('disabled' === $event->getTemplateName()) {
throw new SkipTemplateException('SkipTemplateException');
}
Expand Down Expand Up @@ -217,7 +217,7 @@ public function testPrepareContaoTemplateSkipOnException()
public function testOnParseWidgetSkipOnException()
{
$dispatcher = $this->createMock(EventDispatcherInterface::class);
$dispatcher->method('dispatch')->willReturnCallback(function ($eventName, BeforeParseTwigTemplateEvent $event) {
$dispatcher->method('dispatch')->willReturnCallback(function (BeforeParseTwigTemplateEvent $event, $eventName = '') {
if ('form_text' === $event->getTemplateName()) {
throw new SkipTemplateException('SkipTemplateException');
}
Expand Down
4 changes: 2 additions & 2 deletions tests/Template/TwigFrontendTemplateTest.php
@@ -1,7 +1,7 @@
<?php

/*
* Copyright (c) 2021 Heimrich & Hannot GmbH
* Copyright (c) 2022 Heimrich & Hannot GmbH
*
* @license LGPL-3.0-or-later
*/
Expand All @@ -21,7 +21,7 @@ class TwigFrontendTemplateTest extends ContaoTestCase
public function testInherit()
{
$instance = $this->getMockBuilder(TwigFrontendTemplate::class)->disableOriginalConstructor()->setMethods(null)->getMock();
$container = $this->mockContainer();
$container = $this->getContainerWithContaoConfiguration();
System::setContainer($container);
$this->assertEmpty($instance->inherit());

Expand Down

0 comments on commit 81cc4d1

Please sign in to comment.