Skip to content

Commit

Permalink
Allow symfony v6 and work around issues with specs based on Contao mo…
Browse files Browse the repository at this point in the history
…dels
  • Loading branch information
dmolineus committed Feb 7, 2024
1 parent 1b2ad9c commit f6a8ae1
Show file tree
Hide file tree
Showing 9 changed files with 88 additions and 43 deletions.
2 changes: 1 addition & 1 deletion .phpcq.lock
Original file line number Diff line number Diff line change
@@ -1 +1 @@
{"plugins":{"psalm":{"api-version":"1.0.0","version":"1.2.0.0","type":"php-file","url":"https://phpcq.github.io/repository/psalm-1.2.0.0.php","signature":null,"requirements":{"php":{"php":"^7.4 || ^8.0","ext-dom":"*"},"tool":{"psalm":"^3.0 || ^4.0 || ^5.0"}},"checksum":{"type":"sha-512","value":"4a550c9226d7bca582d7c10bd87cce01190c96398936b1613421640c83df62ed1c6e0d44c1b39635414ea8cf4a892a6458d27590793238add24e7cb5547e6ffd"},"tools":{"psalm":{"version":"5.19.0","url":"https://github.com/vimeo/psalm/releases/download/5.19.0/psalm.phar","requirements":{"php":{"php":"^7.4 || ~8.0.0 || ~8.1.0 || ~8.2.0 || ~8.3.0","ext-SimpleXML":"*","ext-ctype":"*","ext-dom":"*","ext-json":"*","ext-libxml":"*","ext-mbstring":"*","ext-tokenizer":"*"}},"checksum":null,"signature":"https://github.com/vimeo/psalm/releases/download/5.19.0/psalm.phar.asc"}},"composerLock":null},"composer-require-checker":{"api-version":"1.0.0","version":"1.1.1.0","type":"php-file","url":"https://phpcq.github.io/repository/composer-require-checker-1.1.1.0.php","signature":null,"requirements":{"php":{"php":"^7.4 || ^8.0"},"tool":{"composer-require-checker":"^3.8 || ^4.0"}},"checksum":{"type":"sha-512","value":"d5415bddfe024c5749d894034583882aee4e5c3e1087815d9fdd81cb5e71630f631a0e35de0ff84b97fbbf738c16ece5f83bd8c00695913eb846aa6f04577dc2"},"tools":{"composer-require-checker":{"version":"4.8.0","url":"https://github.com/maglnet/ComposerRequireChecker/releases/download/4.8.0/composer-require-checker.phar","requirements":{"php":{"php":"~8.2.0 || ~8.3.0","ext-phar":"*"}},"checksum":null,"signature":"https://github.com/maglnet/ComposerRequireChecker/releases/download/4.8.0/composer-require-checker.phar.asc"}},"composerLock":null},"phpmd":{"api-version":"1.0.0","version":"1.0.2.0","type":"php-file","url":"https://phpcq.github.io/repository/phpmd-1.0.2.0.php","signature":null,"requirements":{"php":{"php":"^7.3 || ^8.0","ext-dom":"*"},"tool":{"phpmd":"^2.6.1"}},"checksum":{"type":"sha-512","value":"f22280a6dec8dbdd2ec1d83b294f23237fe32c34f4a298e52038e0a7a0074d541635b2b488b1a6098a42d8418a6cd8eb804406ea82b91e362be2b5d11a0915b0"},"tools":{"phpmd":{"version":"2.15.0","url":"https://github.com/phpmd/phpmd/releases/download/2.15.0/phpmd.phar","requirements":{"php":{"php":">=5.3.9","ext-xml":"*"}},"checksum":null,"signature":"https://github.com/phpmd/phpmd/releases/download/2.15.0/phpmd.phar.asc"}},"composerLock":null},"phpcpd":{"api-version":"1.0.0","version":"1.1.1.0","type":"php-file","url":"https://phpcq.github.io/repository/phpcpd-1.1.1.0.php","signature":null,"requirements":{"php":{"php":"^7.3 || ^8.0","ext-dom":"*"},"tool":{"phpcpd":"^6.0"}},"checksum":{"type":"sha-512","value":"1189ce0bf3fade4cb4241f1d96f915ef8fc7651f4450dc79fdf464ee3d6be3009316f0d423ce2d4af9d76ad50807b7fdf4d77bfa6d9ee2c91d6eda32ea214433"},"tools":{"phpcpd":{"version":"6.0.3","url":"https://phar.phpunit.de/phpcpd-6.0.3.phar","requirements":{"php":{"php":">=7.3","ext-dom":"*"}},"checksum":{"type":"sha-256","value":"2cbaea7cfda1bb4299d863eb075e977c3f49055dd16d88529fae5150d48a84cb"},"signature":"https://phar.phpunit.de/phpcpd-6.0.3.phar.asc"}},"composerLock":null},"phploc":{"api-version":"1.0.0","version":"1.0.0.0","type":"php-file","url":"https://phpcq.github.io/repository/phploc-1.0.0.0.php","signature":null,"requirements":{"php":{"php":"^7.3 || ^8.0","ext-dom":"*","ext-json":"*"},"tool":{"phploc":"^3.0 || ^4.0 || ^5.0 || ^6.0 || ^7.0"}},"checksum":{"type":"sha-512","value":"f67b02d494796adf553cb3dd13ec06c1cb8e53c799954061749424251379541637538199afb3afa3c7a01cabd1cb6f1c53eb621f015dff9644c6c7cbf10c56d1"},"tools":{"phploc":{"version":"7.0.2","url":"https://phar.phpunit.de/phploc-7.0.2.phar","requirements":{"php":{"php":">=7.3","ext-dom":"*","ext-json":"*"}},"checksum":{"type":"sha-256","value":"3d59778ec86faf25fd00e3a329b2f9ad4a3c751ca91601ea7dab70f887b0bf46"},"signature":"https://phar.phpunit.de/phploc-7.0.2.phar.asc"}},"composerLock":null},"phpcs":{"api-version":"1.0.0","version":"1.1.0.0","type":"php-file","url":"https://phpcq.github.io/repository/phpcs-1.1.0.0.php","signature":null,"requirements":{"php":{"php":"^7.3 || ^8.0","ext-dom":"*"},"tool":{"phpcs":"^3.0 || ^2.0","phpcbf":"^3.0 || ^2.0"}},"checksum":{"type":"sha-512","value":"2737022369da1318cc4e0ea194e8a81019f7b079080d869aab878b7486052fdbe68fee3f28131f35573226def1aabd4bd005e038ee7b767c137b1107c1492a83"},"tools":{"phpcs":{"version":"3.7.2","url":"https://github.com/squizlabs/PHP_CodeSniffer/releases/download/3.7.2/phpcs.phar","requirements":{"php":{"php":">=5.4.0","ext-tokenizer":"*","ext-xmlwriter":"*","ext-simplexml":"*"}},"checksum":null,"signature":"https://github.com/squizlabs/PHP_CodeSniffer/releases/download/3.7.2/phpcs.phar.asc"},"phpcbf":{"version":"3.7.2","url":"https://github.com/squizlabs/PHP_CodeSniffer/releases/download/3.7.2/phpcbf.phar","requirements":{"php":{"php":">=5.4.0","ext-tokenizer":"*","ext-xmlwriter":"*","ext-simplexml":"*"}},"checksum":null,"signature":"https://github.com/squizlabs/PHP_CodeSniffer/releases/download/3.7.2/phpcbf.phar.asc"}},"composerLock":null},"composer-normalize":{"api-version":"1.0.0","version":"1.1.0.0","type":"php-file","url":"https://phpcq.github.io/repository/composer-normalize-1.1.0.0.php","signature":null,"requirements":{"php":{"php":"^7.3 || ^8.0","ext-json":"*"},"tool":{"composer-normalize":"^2.1"}},"checksum":{"type":"sha-512","value":"d59d3557cb20630734878a9115df5dd32d5aff815e5b15be36f6fb5d6e9d83dd36efd84215ab6529edcc924f600946f739a0d9e67723deff95c88346ab502498"},"tools":{"composer-normalize":{"version":"2.41.1","url":"https://github.com/ergebnis/composer-normalize/releases/download/2.41.1/composer-normalize.phar","requirements":{"php":{"php":"~8.1.0 || ~8.2.0 || ~8.3.0","ext-json":"*"}},"checksum":null,"signature":"https://github.com/ergebnis/composer-normalize/releases/download/2.41.1/composer-normalize.phar.asc"}},"composerLock":null},"phpspec":{"api-version":"1.0.0","version":"1.0.0","type":"php-file","url":"./.phpcq/local/phpspec-plugin.php","signature":null,"requirements":{},"checksum":{"type":"sha-512","value":"0307cb00e814c3de436e2c0cc87e4cb949fdec8ce8b3f8fc5a25f7b3631f27dfe8e2b867f4e6419ad4668e252a29267d022c3f6fa20118e4016df66ccfce5605"},"tools":{},"composerLock":null}},"tools":[]}
{"plugins":{"psalm":{"api-version":"1.0.0","version":"1.2.0.0","type":"php-file","url":"https://phpcq.github.io/repository/plugin/psalm/psalm-1.2.0.0.php","signature":null,"requirements":{"php":{"php":"^7.4 || ^8.0","ext-dom":"*"},"tool":{"psalm":"^3.0 || ^4.0 || ^5.0"}},"checksum":{"type":"sha-512","value":"4a550c9226d7bca582d7c10bd87cce01190c96398936b1613421640c83df62ed1c6e0d44c1b39635414ea8cf4a892a6458d27590793238add24e7cb5547e6ffd"},"tools":{"psalm":{"version":"5.21.1","url":"https://github.com/vimeo/psalm/releases/download/5.21.1/psalm.phar","requirements":{"php":{"php":"^7.4 || ~8.0.0 || ~8.1.0 || ~8.2.0 || ~8.3.0","ext-SimpleXML":"*","ext-ctype":"*","ext-dom":"*","ext-json":"*","ext-libxml":"*","ext-mbstring":"*","ext-tokenizer":"*"}},"checksum":null,"signature":"https://github.com/vimeo/psalm/releases/download/5.21.1/psalm.phar.asc"}},"composerLock":null},"composer-require-checker":{"api-version":"1.0.0","version":"1.1.1.0","type":"php-file","url":"https://phpcq.github.io/repository/plugin/composer-require-checker/composer-require-checker-1.1.1.0.php","signature":null,"requirements":{"php":{"php":"^7.4 || ^8.0"},"tool":{"composer-require-checker":"^3.8 || ^4.0"}},"checksum":{"type":"sha-512","value":"d5415bddfe024c5749d894034583882aee4e5c3e1087815d9fdd81cb5e71630f631a0e35de0ff84b97fbbf738c16ece5f83bd8c00695913eb846aa6f04577dc2"},"tools":{"composer-require-checker":{"version":"4.8.0","url":"https://github.com/maglnet/ComposerRequireChecker/releases/download/4.8.0/composer-require-checker.phar","requirements":{"php":{"php":"~8.2.0 || ~8.3.0","ext-phar":"*"}},"checksum":null,"signature":"https://github.com/maglnet/ComposerRequireChecker/releases/download/4.8.0/composer-require-checker.phar.asc"}},"composerLock":null},"phpmd":{"api-version":"1.0.0","version":"1.0.2.0","type":"php-file","url":"https://phpcq.github.io/repository/plugin/phpmd/phpmd-1.0.2.0.php","signature":null,"requirements":{"php":{"php":"^7.3 || ^8.0","ext-dom":"*"},"tool":{"phpmd":"^2.6.1"}},"checksum":{"type":"sha-512","value":"f22280a6dec8dbdd2ec1d83b294f23237fe32c34f4a298e52038e0a7a0074d541635b2b488b1a6098a42d8418a6cd8eb804406ea82b91e362be2b5d11a0915b0"},"tools":{"phpmd":{"version":"2.15.0","url":"https://github.com/phpmd/phpmd/releases/download/2.15.0/phpmd.phar","requirements":{"php":{"php":">=5.3.9","ext-xml":"*"}},"checksum":null,"signature":"https://github.com/phpmd/phpmd/releases/download/2.15.0/phpmd.phar.asc"}},"composerLock":null},"phpcpd":{"api-version":"1.0.0","version":"1.1.1.0","type":"php-file","url":"https://phpcq.github.io/repository/plugin/phpcpd/phpcpd-1.1.1.0.php","signature":null,"requirements":{"php":{"php":"^7.3 || ^8.0","ext-dom":"*"},"tool":{"phpcpd":"^6.0"}},"checksum":{"type":"sha-512","value":"1189ce0bf3fade4cb4241f1d96f915ef8fc7651f4450dc79fdf464ee3d6be3009316f0d423ce2d4af9d76ad50807b7fdf4d77bfa6d9ee2c91d6eda32ea214433"},"tools":{"phpcpd":{"version":"6.0.3","url":"https://phar.phpunit.de/phpcpd-6.0.3.phar","requirements":{"php":{"php":">=7.3","ext-dom":"*"}},"checksum":{"type":"sha-256","value":"2cbaea7cfda1bb4299d863eb075e977c3f49055dd16d88529fae5150d48a84cb"},"signature":"https://phar.phpunit.de/phpcpd-6.0.3.phar.asc"}},"composerLock":null},"phploc":{"api-version":"1.0.0","version":"1.0.0.0","type":"php-file","url":"https://phpcq.github.io/repository/plugin/phploc/phploc-1.0.0.0.php","signature":null,"requirements":{"php":{"php":"^7.3 || ^8.0","ext-dom":"*","ext-json":"*"},"tool":{"phploc":"^3.0 || ^4.0 || ^5.0 || ^6.0 || ^7.0"}},"checksum":{"type":"sha-512","value":"f67b02d494796adf553cb3dd13ec06c1cb8e53c799954061749424251379541637538199afb3afa3c7a01cabd1cb6f1c53eb621f015dff9644c6c7cbf10c56d1"},"tools":{"phploc":{"version":"7.0.2","url":"https://phar.phpunit.de/phploc-7.0.2.phar","requirements":{"php":{"php":">=7.3","ext-dom":"*","ext-json":"*"}},"checksum":{"type":"sha-256","value":"3d59778ec86faf25fd00e3a329b2f9ad4a3c751ca91601ea7dab70f887b0bf46"},"signature":"https://phar.phpunit.de/phploc-7.0.2.phar.asc"}},"composerLock":null},"phpcs":{"api-version":"1.0.0","version":"1.1.1.0","type":"php-file","url":"https://phpcq.github.io/repository/plugin/phpcs/phpcs-1.1.1.0.php","signature":null,"requirements":{"php":{"php":"^7.3 || ^8.0","ext-dom":"*"},"tool":{"phpcs":"^3.0 || ^2.0","phpcbf":"^3.0 || ^2.0"}},"checksum":{"type":"sha-512","value":"2737022369da1318cc4e0ea194e8a81019f7b079080d869aab878b7486052fdbe68fee3f28131f35573226def1aabd4bd005e038ee7b767c137b1107c1492a83"},"tools":{"phpcs":{"version":"3.8.1","url":"https://github.com/PHPCSStandards/PHP_CodeSniffer/releases/download/3.8.1/phpcs.phar","requirements":{"php":{"php":">=5.4.0","ext-simplexml":"*","ext-tokenizer":"*","ext-xmlwriter":"*"}},"checksum":null,"signature":"https://github.com/PHPCSStandards/PHP_CodeSniffer/releases/download/3.8.1/phpcs.phar.asc"},"phpcbf":{"version":"3.8.1","url":"https://github.com/PHPCSStandards/PHP_CodeSniffer/releases/download/3.8.1/phpcbf.phar","requirements":{"php":{"php":">=5.4.0","ext-simplexml":"*","ext-tokenizer":"*","ext-xmlwriter":"*"}},"checksum":null,"signature":"https://github.com/PHPCSStandards/PHP_CodeSniffer/releases/download/3.8.1/phpcbf.phar.asc"}},"composerLock":null},"composer-normalize":{"api-version":"1.0.0","version":"1.1.0.0","type":"php-file","url":"https://phpcq.github.io/repository/plugin/composer-normalize/composer-normalize-1.1.0.0.php","signature":null,"requirements":{"php":{"php":"^7.3 || ^8.0","ext-json":"*"},"tool":{"composer-normalize":"^2.1"}},"checksum":{"type":"sha-512","value":"d59d3557cb20630734878a9115df5dd32d5aff815e5b15be36f6fb5d6e9d83dd36efd84215ab6529edcc924f600946f739a0d9e67723deff95c88346ab502498"},"tools":{"composer-normalize":{"version":"2.42.0","url":"https://github.com/ergebnis/composer-normalize/releases/download/2.42.0/composer-normalize.phar","requirements":{"php":{"php":"~7.4.0 || ~8.0.0 || ~8.1.0 || ~8.2.0 || ~8.3.0","ext-json":"*"}},"checksum":null,"signature":"https://github.com/ergebnis/composer-normalize/releases/download/2.42.0/composer-normalize.phar.asc"}},"composerLock":null},"phpspec":{"api-version":"1.0.0","version":"1.0.0","type":"php-file","url":"./.phpcq/local/phpspec-plugin.php","signature":null,"requirements":{},"checksum":{"type":"sha-512","value":"0307cb00e814c3de436e2c0cc87e4cb949fdec8ce8b3f8fc5a25f7b3631f27dfe8e2b867f4e6419ad4668e252a29267d022c3f6fa20118e4016df66ccfce5605"},"tools":{},"composerLock":null}},"tools":[]}
1 change: 1 addition & 0 deletions .phpcq.yaml.dist
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,7 @@ phpcq:
# phpmd
- 0F9684B8B16B7AB0
- 9093F8B32E4815AA
- 5E6DDE998AB73B8E

tasks:
fix:
Expand Down
8 changes: 4 additions & 4 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -30,10 +30,10 @@
"doctrine/dbal": "^2.11 || ^3.0",
"netzmacht/contao-toolkit": "^3.9 || ^4.0",
"netzmacht/html": "^2.0 || ^3.0",
"symfony/config": "^4.4 || ^5.4",
"symfony/dependency-injection": "^4.4 || ^5.4",
"symfony/http-kernel": "^4.4 || ^5.4",
"symfony/translation-contracts": "^1.1 || ^2.0"
"symfony/config": "^4.4 || ^5.4 || ^6.0",
"symfony/dependency-injection": "^4.4 || ^5.4 || ^6.0",
"symfony/http-kernel": "^4.4 || ^5.4 || ^6.0",
"symfony/translation-contracts": "^1.1 || ^2.0 || ^3.0"
},
"require-dev": {
"contao/manager-plugin": "^2.1",
Expand Down
1 change: 0 additions & 1 deletion phpcs.xml.dist
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,6 @@

<rule ref="SlevomatCodingStandard.TypeHints.ReturnTypeHint">
<properties>
<property name="enableNativeTypeHint" value="false" />
<property name="enableStaticTypeHint" value="false" />
<property name="enableMixedTypeHint" value="false" />
<property name="enableUnionTypeHint" value="false" />
Expand Down
7 changes: 6 additions & 1 deletion psalm.xml
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
resolveFromConfigFile="true"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns="https://getpsalm.org/schema/config"
xsi:schemaLocation="https://getpsalm.org/schema/config vendor/vimeo/psalm/config.xsd"
xsi:schemaLocation="https://getpsalm.org/schema/config https://getpsalm.org/schema/config"
>
<projectFiles>
<directory name="src" />
Expand All @@ -29,6 +29,11 @@
<referencedProperty name="Contao\FrontendTemplate::$activeConsentTool"/>
</errorLevel>
</UndefinedMagicPropertyAssignment>
<DeprecatedClass>
<errorLevel type="suppress">
<referencedClass name="Contao\Template"/>
</errorLevel>
</DeprecatedClass>
</issueHandlers>

<universalObjectCrates>
Expand Down
47 changes: 25 additions & 22 deletions spec/EventListener/Hook/ActivateConsentToolListenerSpec.php
Original file line number Diff line number Diff line change
Expand Up @@ -5,13 +5,16 @@
namespace spec\Hofff\Contao\Consent\Bridge\EventListener\Hook;

use Contao\LayoutModel;
use Contao\Model;
use Contao\ModuleModel;

Check failure on line 9 in spec/EventListener/Hook/ActivateConsentToolListenerSpec.php

View workflow job for this annotation

GitHub Actions / PHP 8.1

Type Contao\ModuleModel is not used in this file. (reported by phpcs: SlevomatCodingStandard.Namespaces.UnusedUses.UnusedUse)

Check failure on line 9 in spec/EventListener/Hook/ActivateConsentToolListenerSpec.php

View workflow job for this annotation

GitHub Actions / PHP 8.2

Type Contao\ModuleModel is not used in this file. (reported by phpcs: SlevomatCodingStandard.Namespaces.UnusedUses.UnusedUse)
use Contao\PageModel;
use Hofff\Contao\Consent\Bridge\ConsentToolManager;
use Hofff\Contao\Consent\Bridge\EventListener\Hook\ActivateConsentToolListener;
use Netzmacht\Contao\Toolkit\Data\Model\Repository;
use Netzmacht\Contao\Toolkit\Data\Model\RepositoryManager;
use PhpSpec\ObjectBehavior;
use Prophecy\Argument;
use ReflectionClass;

final class ActivateConsentToolListenerSpec extends ObjectBehavior
{
Expand All @@ -31,20 +34,19 @@ public function it_is_initializable(): void
$this->shouldHaveType(ActivateConsentToolListener::class);
}

public function it_activates_consent_tool(
ConsentToolManager $consentToolManager,
Repository $pageRepository,
PageModel $rootPageModel,
PageModel $pageModel,
LayoutModel $layoutModel,
): void {
$pageModel
->getWrappedObject()
->rootId = 1;
public function it_activates_consent_tool(ConsentToolManager $consentToolManager, Repository $pageRepository): void

Check warning on line 37 in spec/EventListener/Hook/ActivateConsentToolListenerSpec.php

View workflow job for this annotation

GitHub Actions / PHP 8.1

[37 - 57] Duplicate code fragment (reported by phpcpd)

Check warning on line 37 in spec/EventListener/Hook/ActivateConsentToolListenerSpec.php

View workflow job for this annotation

GitHub Actions / PHP 8.2

[37 - 57] Duplicate code fragment (reported by phpcpd)
{
$modelReflection = (new ReflectionClass(Model::class));
if ($modelReflection->hasProperty('arrColumnCastTypes')) {
$modelReflection->getProperty('arrColumnCastTypes')->setValue(['arrColumnCastTypes' => []]);
}

$layoutModel = (new ReflectionClass(LayoutModel::class))->newInstanceWithoutConstructor();
$pageModel = (new ReflectionClass(PageModel::class))->newInstanceWithoutConstructor();
$rootPageModel = (new ReflectionClass(PageModel::class))->newInstanceWithoutConstructor();

$rootPageModel
->getWrappedObject()
->hofff_consent_bridge_consent_tool = 'example';
$pageModel->rootId = 1;
$rootPageModel->hofff_consent_bridge_consent_tool = 'example';

$pageRepository->find(1)
->shouldBeCalled()
Expand All @@ -62,17 +64,18 @@ public function it_activates_consent_tool(
public function it_does_not_activate_unknown_consent_tool(
ConsentToolManager $consentToolManager,

Check warning on line 65 in spec/EventListener/Hook/ActivateConsentToolListenerSpec.php

View workflow job for this annotation

GitHub Actions / PHP 8.1

[65 - 85] Duplicate code fragment (reported by phpcpd)

Check warning on line 65 in spec/EventListener/Hook/ActivateConsentToolListenerSpec.php

View workflow job for this annotation

GitHub Actions / PHP 8.2

[65 - 85] Duplicate code fragment (reported by phpcpd)
Repository $pageRepository,
PageModel $rootPageModel,
PageModel $pageModel,
LayoutModel $layoutModel,
): void {
$pageModel
->getWrappedObject()
->rootId = 1;
$modelReflection = (new ReflectionClass(Model::class));
if ($modelReflection->hasProperty('arrColumnCastTypes')) {
$modelReflection->getProperty('arrColumnCastTypes')->setValue(['arrColumnCastTypes' => []]);
}

$layoutModel = (new ReflectionClass(LayoutModel::class))->newInstanceWithoutConstructor();
$pageModel = (new ReflectionClass(PageModel::class))->newInstanceWithoutConstructor();
$rootPageModel = (new ReflectionClass(PageModel::class))->newInstanceWithoutConstructor();

$rootPageModel
->getWrappedObject()
->hofff_consent_bridge_consent_tool = 'example';
$pageModel->rootId = 1;
$rootPageModel->hofff_consent_bridge_consent_tool = 'example';

$pageRepository->find(1)
->shouldBeCalled()
Expand Down
9 changes: 8 additions & 1 deletion spec/EventListener/Hook/GoogleWebfontsListenerSpec.php
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
namespace spec\Hofff\Contao\Consent\Bridge\EventListener\Hook;

use Contao\LayoutModel;
use Contao\Model;
use Contao\PageModel;
use Hofff\Contao\Consent\Bridge\ConsentId;
use Hofff\Contao\Consent\Bridge\ConsentId\ConsentIdParser;
Expand All @@ -15,6 +16,7 @@
use Netzmacht\Html\Attributes;
use PhpSpec\ObjectBehavior;
use Prophecy\Argument;
use ReflectionClass;

final class GoogleWebfontsListenerSpec extends ObjectBehavior
{
Expand All @@ -37,10 +39,15 @@ public function it_renders_supported_template(
ConsentId $consentId,
RequestScopeMatcher $scopeMatcher,
PageModel $pageModel,
LayoutModel $layoutModel,
): void {
$scopeMatcher->isFrontendRequest()->willReturn(true);

$modelReflection = (new ReflectionClass(Model::class));
if ($modelReflection->hasProperty('arrColumnCastTypes')) {
$modelReflection->getProperty('arrColumnCastTypes')->setValue(['arrColumnCastTypes' => []]);
}

$layoutModel = (new ReflectionClass(LayoutModel::class))->newInstanceWithoutConstructor();
$layoutModel->webfonts = 'foo';

$consentTool->determineConsentIdByName('google_webfonts')
Expand Down
Loading

0 comments on commit f6a8ae1

Please sign in to comment.