Skip to content

Commit

Permalink
Merge pull request #54 from mremi/sonata
Browse files Browse the repository at this point in the history
chore(deps): support only sonata-project/admin-bundle ^4.0 and sonata-project/twig-extensions ^2.0 and drop support for Symfony 3
  • Loading branch information
mremi authored Oct 26, 2022
2 parents 45fc04f + b8921bf commit 74c2272
Show file tree
Hide file tree
Showing 11 changed files with 76 additions and 43 deletions.
4 changes: 2 additions & 2 deletions Admin/LogsAdmin.php
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
namespace Ekino\DataProtectionBundle\Admin;

use Sonata\AdminBundle\Admin\AbstractAdmin;
use Sonata\AdminBundle\Route\RouteCollection;
use Sonata\AdminBundle\Route\RouteCollectionInterface;

/**
* Class LogsAdmin.
Expand All @@ -36,7 +36,7 @@ class LogsAdmin extends AbstractAdmin
/**
* {@inheritdoc}
*/
protected function configureRoutes(RouteCollection $collection): void
protected function configureRoutes(RouteCollectionInterface $collection): void
{
$collection->add('decrypt_encrypt', 'decrypt-encrypt', [], [], [], '', [], ['GET', 'POST']);
}
Expand Down
2 changes: 2 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,8 @@ master
* Drop support for PHP 7
* Bump PHPStan from ^0.12 to ^1.0
* Allow Symfony 6
* Drop support for Symfony 3
* Support only sonata-project/admin-bundle ^4.0 and sonata-project/twig-extensions ^2.0

v1.3.1
------
Expand Down
2 changes: 1 addition & 1 deletion DependencyInjection/EnvVarEncryptedProcessor.php
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ public function __construct(EncryptorInterface $encryptor)
/**
* {@inheritdoc}
*/
public function getEnv($prefix, $name, \Closure $getEnv)
public function getEnv(string $prefix, string $name, \Closure $getEnv): string
{
if ('ekino_encrypted' === $prefix) {
return $this->encryptor->decrypt($getEnv($name));
Expand Down
4 changes: 2 additions & 2 deletions Tests/Admin/LogsAdminTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
use Ekino\DataProtectionBundle\Controller\LogsAdminController;
use PHPUnit\Framework\TestCase;
use ReflectionMethod;
use Sonata\AdminBundle\Route\RouteCollection;
use Sonata\AdminBundle\Route\RouteCollectionInterface;

/**
* Class LogsAdminTest.
Expand Down Expand Up @@ -46,7 +46,7 @@ protected function setUp(): void
*/
public function testConfigureRoutes(): void
{
$routeCollection = $this->createMock(RouteCollection::class);
$routeCollection = $this->createMock(RouteCollectionInterface::class);
$routeCollection->expects($this->once())
->method('add')
->with('decrypt_encrypt', 'decrypt-encrypt', [], [], [], '', [], ['GET', 'POST']);
Expand Down
25 changes: 25 additions & 0 deletions Tests/BypassFinalHook.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
<?php

declare(strict_types=1);

/*
* This file is part of the ekino/data-protection-bundle project.
*
* (c) Ekino
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/

namespace Ekino\DataProtectionBundle\Tests;

use DG\BypassFinals;
use PHPUnit\Runner\BeforeTestHook;

final class BypassFinalHook implements BeforeTestHook
{
public function executeBeforeTest(string $test): void
{
BypassFinals::enable();
}
}
10 changes: 4 additions & 6 deletions Tests/Command/EncryptCommandTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -55,9 +55,8 @@ protected function setUp(): void

public function testExcecute(): void
{
$this->input->expects($this->at(0))->method('getArgument')->with('text')->willReturn('SomeText');
$this->input->expects($this->at(1))->method('getOption')->with('secret')->willReturn('theApplicationSecret');
$this->input->expects($this->at(2))->method('getOption')->with('method')->willReturn(self::CIPHER);
$this->input->expects($this->once())->method('getArgument')->with('text')->willReturn('SomeText');
$this->input->expects($this->exactly(2))->method('getOption')->withConsecutive(['secret'], ['method'])->willReturnOnConsecutiveCalls('theApplicationSecret', self::CIPHER);

$this->output->expects($this->exactly(2))->method('writeln');

Expand All @@ -66,9 +65,8 @@ public function testExcecute(): void

public function testExcecuteWithBadCipher(): void
{
$this->input->expects($this->at(0))->method('getArgument')->with('text')->willReturn('SomeText');
$this->input->expects($this->at(1))->method('getOption')->with('secret')->willReturn('theApplicationSecret');
$this->input->expects($this->at(2))->method('getOption')->with('method')->willReturn('NotACipher');
$this->input->expects($this->once())->method('getArgument')->with('text')->willReturn('SomeText');
$this->input->expects($this->exactly(2))->method('getOption')->withConsecutive(['secret'], ['method'])->willReturnOnConsecutiveCalls('theApplicationSecret', 'NotACipher');

$this->output->expects($this->never())->method('writeln');

Expand Down
7 changes: 2 additions & 5 deletions Tests/Controller/LogsAdminControllerTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,6 @@
use Symfony\Component\Form\Form;
use Symfony\Component\HttpFoundation\Request;
use Symfony\Component\HttpFoundation\Response;
use Symfony\Component\Translation\TranslatorInterface;

/**
* Class LogsAdminControllerTest.
Expand Down Expand Up @@ -52,7 +51,7 @@ protected function setUp(): void
->disableOriginalClone()
->disableArgumentCloning()
->disallowMockingUnknownTypes()
->setMethods(['addFlash', 'createForm', 'get', 'renderWithExtraParams'])
->onlyMethods(['addFlash', 'createForm', 'renderWithExtraParams', 'trans'])
->getMock();
}

Expand Down Expand Up @@ -106,9 +105,7 @@ public function testDecryptEncryptActionNok(): void

$request = $this->createMock(Request::class);

$translator = $this->createMock(TranslatorInterface::class);
$translator->expects($this->once())->method('trans')->willReturn('admin.logs.encrypt.error');
$this->controller->expects($this->once())->method('get')->with($this->equalTo('translator'))->willReturn($translator);
$this->controller->expects($this->once())->method('trans')->with('admin.logs.encrypt.error', [], 'EkinoDataProtectionBundle');

$this->controller->decryptEncryptAction($request);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ public function testLoadWithInvalidConfigs(array $configs, string $exceptionMess

$this->fail(sprintf('Expecting %s with message \'%s\'', InvalidConfigurationException::class, $exceptionMessage));
} catch (InvalidConfigurationException $e) {
$this->assertRegExp($exceptionMessage, $e->getMessage());
$this->assertMatchesRegularExpression($exceptionMessage, $e->getMessage());
}
}

Expand Down
21 changes: 11 additions & 10 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -17,22 +17,23 @@
"ext-json": "*",
"ext-openssl": "*",
"monolog/monolog": "^1.24 || ~2.0",
"symfony/config": "^3.4 || ^4.4 || ^5.3 || ^6.0",
"symfony/console": "^3.4 || ^4.4 || ^5.3 || ^6.0",
"symfony/dependency-injection": "^3.4 || ^4.4 || ^5.3 || ^6.0",
"symfony/form": "^3.4 || ^4.4 || ^5.3 || ^6.0",
"symfony/http-kernel": "^3.4 || ^4.4 || ^5.3 || ^6.0",
"symfony/options-resolver": "^3.4 || ^4.4 || ^5.3 || ^6.0",
"symfony/translation": "^3.4 || ^4.4 || ^5.3 || ^6.0",
"symfony/validator": "^3.4 || ^4.4 || ^5.3 || ^6.0"
"symfony/config": "^4.4 || ^5.3 || ^6.0",
"symfony/console": "^4.4 || ^5.3 || ^6.0",
"symfony/dependency-injection": "^4.4 || ^5.3 || ^6.0",
"symfony/form": "^4.4 || ^5.3 || ^6.0",
"symfony/http-kernel": "^4.4 || ^5.3 || ^6.0",
"symfony/options-resolver": "^4.4 || ^5.3 || ^6.0",
"symfony/translation": "^4.4 || ^5.3 || ^6.0",
"symfony/validator": "^4.4 || ^5.3 || ^6.0"
},
"require-dev": {
"dg/bypass-finals": "^1.4",
"ekino/phpstan-banned-code": "^1.0",
"friendsofphp/php-cs-fixer": "^3.0",
"phpstan/phpstan-phpunit": "^1.0",
"phpunit/phpunit": "^9.5",
"sonata-project/admin-bundle": "3.*",
"sonata-project/twig-extensions": "1.*"
"sonata-project/admin-bundle": "^4.0",
"sonata-project/twig-extensions": "^2.0"
},
"autoload": {
"psr-4": { "Ekino\\DataProtectionBundle\\": "" },
Expand Down
3 changes: 2 additions & 1 deletion phpstan.neon.dist
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,8 @@ parameters:
- %rootDir%/../../..
checkGenericClassInNonGenericObjectType: false
checkMissingIterableValueType: false
excludes_analyse:

excludePaths:
- %rootDir%/../../../vendor/*

- %rootDir%/../../../DependencyInjection/Configuration.php
39 changes: 24 additions & 15 deletions phpunit.xml.dist
Original file line number Diff line number Diff line change
@@ -1,30 +1,39 @@
<?xml version="1.0" encoding="UTF-8"?>
<phpunit xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:noNamespaceSchemaLocation="https://schema.phpunit.de/7.2/phpunit.xsd"
xsi:noNamespaceSchemaLocation="https://schema.phpunit.de/9.3/phpunit.xsd"
bootstrap="vendor/autoload.php"
beStrictAboutOutputDuringTests="true"
beStrictAboutTodoAnnotatedTests="true"
verbose="true">

<coverage processUncoveredFiles="true">
<include>
<directory>./</directory>
</include>

<exclude>
<directory>./Resources</directory>
<directory>./Tests</directory>
<directory>./vendor</directory>
</exclude>

<report>
<clover outputFile="build/phpunit/clover.xml"/>
<html outputDirectory="build/phpunit/html"/>
</report>
</coverage>

<testsuites>
<testsuite name="default">
<directory suffix="Test.php">Tests</directory>
</testsuite>
</testsuites>

<filter>
<whitelist processUncoveredFilesFromWhitelist="true">
<directory>./</directory>
<exclude>
<directory>./Resources</directory>
<directory>./Tests</directory>
<directory>./vendor</directory>
</exclude>
</whitelist>
</filter>

<logging>
<log type="coverage-clover" target="build/phpunit/clover.xml"/>
<log type="junit" target="build/phpunit/junit.xml"/>
<log type="coverage-html" target="build/phpunit/html"/>
<junit outputFile="build/phpunit/junit.xml"/>
</logging>

<extensions>
<extension class="Ekino\DataProtectionBundle\Tests\BypassFinalHook"/>
</extensions>
</phpunit>

0 comments on commit 74c2272

Please sign in to comment.