Skip to content

Commit

Permalink
Add compatibility for symfony 6.4 and 7.0
Browse files Browse the repository at this point in the history
Add attributes to tenant entity
fix deprecations
  • Loading branch information
Matth-- committed Jan 9, 2024
1 parent 4bfebc2 commit 5eb0cf3
Show file tree
Hide file tree
Showing 16 changed files with 80 additions and 43 deletions.
18 changes: 12 additions & 6 deletions .github/workflows/php.yml
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,10 @@ jobs:
- name: Install dependencies
if: steps.composer-cache.outputs.cache-hit != 'true'
run: composer install --prefer-dist --no-progress --no-suggest
- name: Run php-cs-fixer
run: PHP_CS_FIXER_IGNORE_ENV=1 tools/php-cs-fixer fix --dry-run --diff --ansi
- name: Run psalm
run: tools/psalm
test:
runs-on: ubuntu-latest
strategy:
Expand All @@ -37,12 +41,18 @@ jobs:
- description: 'PHP 8.1 - SF 5.4.*'
php: '8.1'
symfony_version: '5.4.*'
- description: 'PHP 8.0 - SF 6.0.*'
- description: 'PHP 8.0 - SF 6.3.*'
php: '8.0'
symfony_version: '6.0.*'
- description: 'PHP 8.1 - SF 6.0.*'
- description: 'PHP 8.1 - SF 6.3.*'
php: '8.1'
symfony_version: '6.0.*'
- description: 'PHP 8.3 - SF 6.4.*'
php: '8.3'
symfony_version: '6.4.*'
- description: 'PHP 8.3 - SF 7.0'
php: '8.3'
symfony_version: '7.0.*'
name: Tests ${{ matrix.description }}
steps:
- name: Checkout
Expand All @@ -65,10 +75,6 @@ jobs:
- run: |
sed -ri 's/"symfony\/(.+)": "(.+)"/"symfony\/\1": "'${{ matrix.symfony_version }}'"/' composer.json;
- run: composer update --no-interaction --no-progress --ansi ${{ matrix.composer_flags }}
- name: Run php-cs-fixer
run: tools/php-cs-fixer fix --dry-run --diff --ansi
- name: Run psalm
run: tools/psalm
- name: Run Tests
run: vendor/bin/phpunit --coverage-clover=coverage.xml
- name: Upload coverage to Codecov
Expand Down
3 changes: 1 addition & 2 deletions Tests/Functional/Repository/TenantRepositoryTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@

namespace AtlassianConnectBundle\Tests\Functional\Repository;

use AtlassianConnectBundle\Entity\Tenant;
use AtlassianConnectBundle\Repository\TenantRepositoryInterface;
use AtlassianConnectBundle\Tests\Functional\KernelTestCase;
use Doctrine\ORM\EntityManagerInterface;
Expand Down Expand Up @@ -48,7 +47,7 @@ public function testSaveTenant(): void
$tenant->setEventType('event');
$repository->save($tenant);

self::getContainer()->get(EntityManagerInterface::class)->clear(Tenant::class);
self::getContainer()->get(EntityManagerInterface::class)->clear();

$this->assertNotNull($repository->findByClientKey('new_client_key'));
}
Expand Down
1 change: 0 additions & 1 deletion Tests/Functional/app/config/base/security.yaml
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
security:
enable_authenticator_manager: true
providers:
jwt_user_provider:
id: jwt_user_provider
Expand Down
2 changes: 2 additions & 0 deletions Tests/Functional/app/config/packages/doctrine.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,8 @@ doctrine:
driver: pdo_sqlite
path: "%kernel.cache_dir%/test-database.sqlite"
orm:
enable_lazy_ghost_objects: true
report_fields_where_declared: true
auto_generate_proxy_classes: true
naming_strategy: doctrine.orm.naming_strategy.underscore_number_aware
auto_mapping: true
12 changes: 9 additions & 3 deletions Tests/Functional/app/config/routes.yaml
Original file line number Diff line number Diff line change
@@ -1,6 +1,12 @@
controllers:
resource: ../src/Controller/
type: annotation
protected:
path: /protected/route
controller: AtlassianConnectBundle\Tests\Functional\App\Controller\ProtectedController::protectedRoute

license_protected:
path: /protected/license-route
defaults:
requires_license: true
controller: AtlassianConnectBundle\Tests\Functional\App\Controller\ProtectedController::licenseProtectedRoute

ac:
resource: "@AtlassianConnectBundle/Resources/config/routing.php"
7 changes: 0 additions & 7 deletions Tests/Functional/app/src/Controller/ProtectedController.php
Original file line number Diff line number Diff line change
Expand Up @@ -6,21 +6,14 @@

use Symfony\Bundle\FrameworkBundle\Controller\AbstractController;
use Symfony\Component\HttpFoundation\Response;
use Symfony\Component\Routing\Annotation\Route;

final class ProtectedController extends AbstractController
{
/**
* @Route("/protected/route")
*/
public function protectedRoute(): Response
{
return new Response('OK');
}

/**
* @Route("/protected/license-route", defaults={"requires_license": "true"})
*/
public function licenseProtectedRoute(): Response
{
return new Response('OK');
Expand Down
6 changes: 6 additions & 0 deletions Tests/Functional/app/src/Kernel.php
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
namespace AtlassianConnectBundle\Tests\Functional\App;

use AtlassianConnectBundle\AtlassianConnectBundle;
use AtlassianConnectBundle\Tests\Functional\App\DependencyInjection\SecurityCompilerPass;
use Doctrine\Bundle\DoctrineBundle\DoctrineBundle;
use Doctrine\Bundle\FixturesBundle\DoctrineFixturesBundle;
use Psr\Log\NullLogger;
Expand All @@ -13,6 +14,7 @@
use Symfony\Bundle\SecurityBundle\SecurityBundle;
use Symfony\Bundle\TwigBundle\TwigBundle;
use Symfony\Component\Config\Loader\LoaderInterface;
use Symfony\Component\DependencyInjection\Compiler\PassConfig;
use Symfony\Component\DependencyInjection\ContainerBuilder;
use Symfony\Component\HttpKernel\Bundle\BundleInterface;
use Symfony\Component\HttpKernel\Kernel as BaseKernel;
Expand Down Expand Up @@ -63,6 +65,10 @@ protected function configureContainer(ContainerBuilder $container, LoaderInterfa

protected function build(ContainerBuilder $container): void
{
if (self::MAJOR_VERSION < 6) {
$container->prependExtensionConfig('security', ['enable_authenticator_manager' => true]);
}

$container->register('logger', NullLogger::class);
}
}
12 changes: 3 additions & 9 deletions Tests/Listener/LicenseListenerTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@
use AtlassianConnectBundle\Listener\LicenseListener;
use PHPUnit\Framework\MockObject\MockObject;
use PHPUnit\Framework\TestCase;
use Symfony\Component\DependencyInjection\ParameterBag\ParameterBagInterface;
use Symfony\Component\HttpFoundation\RedirectResponse;
use Symfony\Component\HttpFoundation\Request;
use Symfony\Component\HttpKernel\Event\RequestEvent;
Expand All @@ -33,13 +32,7 @@ protected function setUp(): void

public function testItSkipsOnASubRequest(): void
{
$attributeParameterBag = $this->createMock(ParameterBagInterface::class);
$attributeParameterBag
->expects($this->never())
->method('get');

$request = new Request();
$request->attributes = $attributeParameterBag;
$request = new Request([], [], []);

$event = $this->getEvent(
$this->kernel,
Expand All @@ -48,6 +41,7 @@ public function testItSkipsOnASubRequest(): void
);

$this->getLicenseListener()->onKernelRequest($event);
$this->assertNull($event->getResponse());
}

public function testItSkipsWhenTheRouteIsNotNullAndRouteRequiresNoLicense(): void
Expand Down Expand Up @@ -85,7 +79,7 @@ public function testItSkipsWhenTheRouteIsNotNullAndRouteHasNoRequiresLicenseAttr
$event = $this->getEvent(
$this->kernel,
$request,
KernelInterface::MASTER_REQUEST
KernelInterface::MAIN_REQUEST
);

$this->getLicenseListener()->onKernelRequest($event);
Expand Down
4 changes: 2 additions & 2 deletions Tests/Service/AtlassianRestClientTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -151,7 +151,7 @@ public function testGetTenantFromTokenStorage(): void
public function testNoTenantInToken(): void
{
$this->expectException(\RuntimeException::class);
$this->expectDeprecationMessage('Could not get tenant from token');
$this->expectExceptionMessage('Could not get tenant from token');

$this->tokenStorage
->expects($this->once())
Expand All @@ -164,7 +164,7 @@ public function testNoTenantInToken(): void
public function testNotInTenantContext(): void
{
$this->expectException(\RuntimeException::class);
$this->expectDeprecationMessage('Current user is not a Tenant');
$this->expectExceptionMessage('Current user is not a Tenant');

$this->tokenStorage
->expects($this->once())
Expand Down
24 changes: 12 additions & 12 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -8,26 +8,26 @@
"require": {
"php": "^8.0",
"ext-json": "*",
"symfony/dependency-injection": "^5.4|^6.0",
"symfony/http-kernel": "^5.4|^6.0",
"symfony/config": "^5.4|^6.0",
"symfony/http-client": "^5.4|^6.0",
"symfony/yaml": "^5.4|^6.0",
"symfony/security-bundle": "^5.4|^6.0",
"symfony/routing": "^5.4|^6.0",
"symfony/console": "^5.4|^6.0",
"symfony/dependency-injection": "^5.4|^6.0|^7.0",
"symfony/http-kernel": "^5.4|^6.0|^7.0",
"symfony/config": "^5.4|^6.0|^7.0",
"symfony/http-client": "^5.4|^6.0|^7.0",
"symfony/yaml": "^5.4|^6.0|^7.0",
"symfony/security-bundle": "^5.4|^6.0|^7.0",
"symfony/routing": "^5.4|^6.0|^7.0",
"symfony/console": "^5.4|^6.0|^7.0",
"doctrine/orm": "^2.5",
"twig/twig": "^2.10|^3.0",
"firebase/php-jwt": "^6.2"
},
"require-dev": {
"phpunit/phpunit": "^9.5.10",
"symfony/framework-bundle": "^5.4|^6.0",
"symfony/framework-bundle": "^5.4|^6.0|^7.0",
"doctrine/doctrine-bundle": "^1.12|^2.5",
"symfony/browser-kit": "^5.4|^6.0",
"symfony/twig-bundle": "^5.4|^6.0",
"symfony/browser-kit": "^5.4|^6.0|^7.0",
"symfony/twig-bundle": "^5.4|^6.0|^7.0",
"doctrine/doctrine-fixtures-bundle": "^2.3|^3.0",
"symfony/phpunit-bridge": "^5.4|^6.0"
"symfony/phpunit-bridge": "^5.4|^6.0|^7.0"
},
"authors": [
{
Expand Down
4 changes: 4 additions & 0 deletions src/DependencyInjection/Configuration.php
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,10 @@

class Configuration implements ConfigurationInterface
{
/**
* @psalm-suppress UndefinedInterfaceMethod
* @psalm-suppress UndefinedMethod
*/
public function getConfigTreeBuilder(): TreeBuilder
{
$treeBuilder = new TreeBuilder('atlassian_connect');
Expand Down
1 change: 1 addition & 0 deletions src/Entity/Tenant.php
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
* @ORM\HasLifecycleCallbacks()
* @ORM\Entity()
*/
#[ORM\Entity, ORM\Table(name: 'tenant'), ORM\HasLifecycleCallbacks]
class Tenant implements TenantInterface
{
use TenantTrait;
Expand Down
Loading

0 comments on commit 5eb0cf3

Please sign in to comment.