Skip to content

Commit

Permalink
Consolidate unit and functional tests and fix unit tests
Browse files Browse the repository at this point in the history
- put the unit and functional tests in the same CI job
- Fix the mention manager tests
  • Loading branch information
BentiGorlich committed Dec 25, 2024
1 parent ca70bd4 commit 662a10d
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 31 deletions.
34 changes: 6 additions & 28 deletions .github/workflows/action.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -53,34 +53,6 @@ jobs:
- name: Build frontend (production)
run: npm run build

unit-test:
runs-on: ubuntu-latest
container:
image: danger89/mbin-pipeline:1.3.0
steps:
- uses: actions/checkout@v4

- name: Get Composer Cache Directory
id: composer-cache
run: |
echo "dir=$(composer config cache-files-dir)" >> $GITHUB_OUTPUT
- uses: actions/cache@v4
with:
path: ${{ steps.composer-cache.outputs.dir }}
key: ${{ runner.os }}-composer-${{ hashFiles('**/composer.lock') }}
restore-keys: ${{ runner.os }}-composer-

- run: cp .env.example .env
- name: Composer install
run: composer install --no-scripts --no-progress

- name: Run unit tests
env:
COMPOSER_CACHE_DIR: ${{ steps.composer-cache.outputs.dir }}
SYMFONY_DEPRECATIONS_HELPER: disabled
run: php bin/phpunit tests/Unit

integration-test:
runs-on: ubuntu-latest
container:
Expand Down Expand Up @@ -123,6 +95,12 @@ jobs:
- name: Build frontend (production)
run: npm run build

- name: Run unit tests
env:
COMPOSER_CACHE_DIR: ${{ steps.composer-cache.outputs.dir }}
SYMFONY_DEPRECATIONS_HELPER: disabled
run: php bin/phpunit tests/Unit

- name: Run integration tests
env:
COMPOSER_CACHE_DIR: ${{ steps.composer-cache.outputs.dir }}
Expand Down
6 changes: 3 additions & 3 deletions tests/Unit/Service/MentionManagerTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,10 @@

namespace App\Tests\Unit\Service;

use App\Service\MentionManager;
use App\Service\SettingsManager;
use App\Tests\WebTestCase;
use PHPUnit\Framework\Attributes\DataProvider;
use Symfony\Bundle\FrameworkBundle\Test\WebTestCase;

class MentionManagerTest extends WebTestCase
{
Expand All @@ -26,8 +27,7 @@ public function testExtract(string $input, ?array $output): void

// Replace the actual setting service with the mock in the container
$this->getContainer()->set(SettingsManager::class, $settingsManagerMock);

$manager = $this->mentionManager;
$manager = $this->getContainer()->get(MentionManager::class);
$this->assertEquals($output, $manager->extract($input));
}

Expand Down

0 comments on commit 662a10d

Please sign in to comment.