diff --git a/.github/workflows/test-application.yaml b/.github/workflows/test-application.yaml index 2d19efd2..023c2ec3 100644 --- a/.github/workflows/test-application.yaml +++ b/.github/workflows/test-application.yaml @@ -20,37 +20,41 @@ jobs: matrix: include: - php-version: '7.2' - lint: false dependency-versions: 'lowest' - tools: 'composer:v1' + tools: 'composer:v2' env: SYMFONY_DEPRECATIONS_HELPER: disabled - php-version: '7.4' - lint: true dependency-versions: 'highest' tools: 'composer:v2' env: SYMFONY_DEPRECATIONS_HELPER: disabled - php-version: '8.0' - lint: true dependency-versions: 'highest' tools: 'composer:v2' env: SYMFONY_DEPRECATIONS_HELPER: disabled + - php-version: '8.1' - lint: true dependency-versions: 'highest' tools: 'composer:v2' env: SYMFONY_DEPRECATIONS_HELPER: disabled + - php-version: '8.2' - lint: true + dependency-versions: 'highest' + tools: 'composer:v2' + env: + SYMFONY_DEPRECATIONS_HELPER: disabled + + - php-version: '8.3' dependency-versions: 'highest' tools: 'composer:v2' env: SYMFONY_DEPRECATIONS_HELPER: weak + services: mysql: image: mysql:5.7 @@ -62,7 +66,7 @@ jobs: steps: - name: Checkout project - uses: actions/checkout@v2 + uses: actions/checkout@v4 - name: Install and configure PHP uses: shivammathur/setup-php@v2 @@ -71,8 +75,15 @@ jobs: extensions: 'mysql, gd' tools: ${{ matrix.tools }} + - name: Remove phpspec/prophecy-phpunit + if: ${{ matrix.php-version == '7.2' }} + run: composer remove phpspec/prophecy-phpunit --no-update --dev + + - name: Remove not required test tooling + run: composer remove "*php-cs-fixer*" "*phpstan*" --no-update --dev + - name: Install composer dependencies - uses: ramsey/composer-install@v1 + uses: ramsey/composer-install@v2 with: dependency-versions: ${{matrix.dependency-versions}} @@ -80,11 +91,32 @@ jobs: run: composer bootstrap-test-environment env: ${{ matrix.env }} - - name: Lint code - if: ${{ matrix.lint }} - run: composer lint - env: ${{ matrix.env }} - - name: Execute test cases run: composer test env: ${{ matrix.env }} + + lint: + name: 'PHP Lint' + runs-on: ubuntu-latest + + env: + DATABASE_URL: 'mysql://root:root@127.0.0.1/sulu_comment_test?serverVersion=5.7' + + steps: + - name: Checkout project + uses: actions/checkout@v4 + + - name: Install and configure PHP + uses: shivammathur/setup-php@v2 + with: + php-version: 8.3 + extensions: 'mysql, gd' + tools: 'composer:v2' + + - name: Install composer dependencies + uses: ramsey/composer-install@v2 + with: + dependency-versions: 'highest' + + - name: Lint code + run: composer lint diff --git a/Entity/ThreadRepository.php b/Entity/ThreadRepository.php index 28bd49c2..1c5c0221 100644 --- a/Entity/ThreadRepository.php +++ b/Entity/ThreadRepository.php @@ -46,6 +46,7 @@ public function findThreadsByIds(array $ids): array ->setParameter('ids', $ids) ->getQuery(); + /** @var ThreadInterface[] */ return $query->getResult(); } diff --git a/Tests/Application/Kernel.php b/Tests/Application/Kernel.php index 72f051cc..e82783ea 100644 --- a/Tests/Application/Kernel.php +++ b/Tests/Application/Kernel.php @@ -32,20 +32,23 @@ public function registerBundles(): iterable return $bundles; } - public function registerContainerConfiguration(LoaderInterface $loader) + public function registerContainerConfiguration(LoaderInterface $loader): void { parent::registerContainerConfiguration($loader); $context = $this->getContext(); $loader->load(__DIR__ . '/config/config_' . $context . '.yml'); - if (\version_compare(Kernel::VERSION, '6.0.0', '>=')) { - $loader->load(__DIR__ . '/config/security-6.yml'); - } else { + if (\class_exists(\Symfony\Bundle\SecurityBundle\Command\UserPasswordEncoderCommand::class)) { // detect Symfony <= 5.4 $loader->load(__DIR__ . '/config/security-5-4.yml'); + } else { + $loader->load(__DIR__ . '/config/security-6.yml'); } } + /** + * @return array + */ protected function getKernelParameters(): array { $parameters = parent::getKernelParameters(); diff --git a/Tests/Application/bin/console.php b/Tests/Application/bin/console.php index 344c61b8..91b7c863 100644 --- a/Tests/Application/bin/console.php +++ b/Tests/Application/bin/console.php @@ -33,7 +33,7 @@ if (\class_exists(Debug::class)) { Debug::enable(); } else { - \Symfony\Component\Debug\Debug::enable(); + Symfony\Component\Debug\Debug::enable(); } } diff --git a/Tests/Unit/Entity/ThreadTest.php b/Tests/Unit/Entity/ThreadTest.php index 0387e8cd..a3915413 100644 --- a/Tests/Unit/Entity/ThreadTest.php +++ b/Tests/Unit/Entity/ThreadTest.php @@ -13,11 +13,14 @@ use Doctrine\Common\Collections\ArrayCollection; use PHPUnit\Framework\TestCase; +use Prophecy\PhpUnit\ProphecyTrait; use Sulu\Bundle\CommentBundle\Entity\CommentInterface; use Sulu\Bundle\CommentBundle\Entity\Thread; class ThreadTest extends TestCase { + use ProphecyTrait; + public function testCommentCount() { $thread = new Thread('test', 1); diff --git a/Tests/Unit/Manager/CommentManagerTest.php b/Tests/Unit/Manager/CommentManagerTest.php index 00b2db33..198262bc 100644 --- a/Tests/Unit/Manager/CommentManagerTest.php +++ b/Tests/Unit/Manager/CommentManagerTest.php @@ -13,6 +13,7 @@ use PHPUnit\Framework\TestCase; use Prophecy\Argument; +use Prophecy\PhpUnit\ProphecyTrait; use Sulu\Bundle\CommentBundle\Entity\CommentInterface; use Sulu\Bundle\CommentBundle\Entity\CommentRepositoryInterface; use Sulu\Bundle\CommentBundle\Entity\ThreadInterface; @@ -26,6 +27,8 @@ class CommentManagerTest extends TestCase { + use ProphecyTrait; + /** * @var ThreadRepositoryInterface */ diff --git a/Tests/bootstrap.php b/Tests/bootstrap.php index bdb70242..220d2d86 100644 --- a/Tests/bootstrap.php +++ b/Tests/bootstrap.php @@ -19,6 +19,7 @@ } require $file; +require_once __DIR__ . '/prophecy_php_7_2.php'; // Load cached env vars if the .env.local.php file exists // Run "composer dump-env prod" to create it (requires symfony/flex >=1.2) diff --git a/Tests/prophecy_php_7_2.php b/Tests/prophecy_php_7_2.php new file mode 100644 index 00000000..f2d6e6b5 --- /dev/null +++ b/Tests/prophecy_php_7_2.php @@ -0,0 +1,18 @@ +