Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add compatability with symfony 6.4 and prepare for 7.0 #80

Merged
merged 1 commit into from
Jan 9, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
28 changes: 14 additions & 14 deletions .github/workflows/php.yml
Original file line number Diff line number Diff line change
Expand Up @@ -25,24 +25,28 @@ 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:
fail-fast: false
matrix:
include:
- description: 'PHP 8.0 - SF 5.4.*'
php: '8.0'
symfony_version: '5.4.*'
- description: 'PHP 8.1 - SF 5.4.*'
php: '8.1'
symfony_version: '5.4.*'
- description: 'PHP 8.0 - SF 6.0.*'
php: '8.0'
symfony_version: '6.0.*'
- description: 'PHP 8.1 - SF 6.0.*'
php: '8.1'
symfony_version: '6.0.*'
- description: 'PHP 8.3 - SF 6.3.*'
php: '8.3'
symfony_version: '6.3.*'
- 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 @@ -63,12 +67,8 @@ jobs:
php-version: ${{ matrix.php }}
coverage: "pcov"
- run: |
sed -ri 's/"symfony\/(.+)": "(.+)"/"symfony\/\1": "'${{ matrix.symfony_version }}'"/' composer.json;
sed -Ei '/"symfony\/var-exporter":/! 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
22 changes: 22 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
# Change Log
All notable changes to this project will be documented in this file (after version 4.0).

## [4.1.0] - 2024-01-09

Run composer update

### Added

- Add attribute support for the Tenant entity
- This allows you to drop support for the annotations driver for doctrine.
- Check compatibility with Symfonh 6.4
- Add support for Symfony 7.0

### Changed

### Fixed

### Removed

- Dropped support for PHP 8.0 (symfony var-exporter)
- Dropped support for Symfony 6.1 and 6.2 (unmaintained versions. Upgrade immediately)
7 changes: 5 additions & 2 deletions Tests/Functional/Repository/TenantRepositoryTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -33,8 +33,10 @@ public function testFindTenantByClientKey(): void
public function testSaveTenant(): void
{
self::bootKernel();
/** @var TenantRepositoryInterface $repository */
$repository = self::getContainer()->get(TenantRepositoryInterface::class);

/** @var Tenant $tenant */
$tenant = $repository->initializeTenant();
$tenant->setClientKey('new_client_key');
$tenant->setAddonKey('key');
Expand All @@ -48,8 +50,9 @@ 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'));
$this->assertNotNull($tenant = $repository->findByClientKey('new_client_key'));
$this->assertNotNull($tenant->getCreatedAt());
}
}
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
4 changes: 4 additions & 0 deletions Tests/Functional/app/src/Kernel.php
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,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
27 changes: 14 additions & 13 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -6,28 +6,29 @@
"type": "symfony-bundle",
"license": "MIT",
"require": {
"php": "^8.0",
"php": "^8.1",
"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.3|^7.0",
"symfony/http-kernel": "^5.4|^6.3|^7.0",
"symfony/config": "^5.4|^6.3|^7.0",
"symfony/http-client": "^5.4|^6.3|^7.0",
"symfony/yaml": "^5.4|^6.3|^7.0",
"symfony/security-bundle": "^5.4|^6.3|^7.0",
"symfony/routing": "^5.4|^6.3|^7.0",
"symfony/console": "^5.4|^6.3|^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.3|^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.3|^7.0",
"symfony/twig-bundle": "^5.4|^6.3|^7.0",
"doctrine/doctrine-fixtures-bundle": "^2.3|^3.0",
"symfony/phpunit-bridge": "^5.4|^6.0"
"symfony/phpunit-bridge": "^5.4|^6.3|^7.0",
"symfony/var-exporter": "^6.3|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
Loading