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

Fix workflows for tests #53

Merged
merged 13 commits into from
Jan 26, 2024
5 changes: 4 additions & 1 deletion .env.test
Original file line number Diff line number Diff line change
Expand Up @@ -6,4 +6,7 @@ PANTHER_APP_ENV=panther
PANTHER_ERROR_SCREENSHOT_DIR=./var/error-screenshots

# Root access needed to create the new TEST database
DATABASE_URL="mysql://root:biblioteca@db:3306/biblioteca?serverVersion=15&charset=utf8"
DATABASE_URL="sqlite:///%kernel.project_dir%/data/database.sqlite"

TYPESENSE_URL=http://localhost:8108
TYPESENSE_KEY=xyz
67 changes: 40 additions & 27 deletions .github/workflows/symfony.yml
Original file line number Diff line number Diff line change
Expand Up @@ -13,31 +13,44 @@ permissions:
jobs:
symfony-tests:
runs-on: ubuntu-latest
strategy:
matrix:
typesense-version: [ 0.23.1 ]

steps:
# To automatically get bug fixes and new Php versions for shivammathur/setup-php,
# change this to (see https://github.com/shivammathur/setup-php#bookmark-versioning):
# uses: shivammathur/setup-php@v2
- uses: shivammathur/setup-php@v2
with:
php-version: '8.2'
- uses: actions/checkout@v3
- name: Copy .env.test.local
run: php -r "file_exists('.env.test.local') || copy('.env.test', '.env.test.local');"
- name: Cache Composer packages
id: composer-cache
uses: actions/cache@v3
with:
path: vendor
key: ${{ runner.os }}-php-${{ hashFiles('**/composer.lock') }}
restore-keys: |
${{ runner.os }}-php-
- name: Install Dependencies
run: composer install -q --no-ansi --no-interaction --no-scripts --no-progress --prefer-dist
- name: Create Database
run: |
mkdir -p data
touch data/database.sqlite
- name: Execute tests
env:
DATABASE_URL: sqlite:///%kernel.project_dir%/data/database.sqlite
run: composer test
- name: Start Typesense
uses: jirevwe/typesense-github-action@v1.0.1
with:
typesense-version: ${{ matrix.typesense-version }}
typesense-api-key: xyz
- name: Curl Typesense
run: sleep 10 && curl http://localhost:8108/health

- uses: shivammathur/setup-php@v2
with:
php-version: '8.2'
- uses: actions/checkout@v3
- name: Copy .env.test.local
run: php -r "file_exists('.env.test.local') || copy('.env.test', '.env.test.local');"
- name: Cache Composer packages
id: composer-cache
uses: actions/cache@v3
with:
path: vendor
key: ${{ runner.os }}-php-${{ hashFiles('**/composer.lock') }}
restore-keys: |
${{ runner.os }}-php-
- name: Install Dependencies
run: composer install -q --no-ansi --no-interaction --no-scripts --no-progress --prefer-dist
- name: Create Database
run: |
mkdir -p data
touch data/database.sqlite
- name: Execute tests
env:
DATABASE_URL: sqlite:///%kernel.project_dir%/data/database.sqlite
run: |
bin/console doctrine:schema:create --env=test
bin/console doctrine:schema:update --force --complete --env=test
bin/console typesense:create --env=test
composer test
2 changes: 1 addition & 1 deletion config/bundles.php
Original file line number Diff line number Diff line change
Expand Up @@ -21,5 +21,5 @@
Symfony\UX\StimulusBundle\StimulusBundle::class => ['all' => true],
Andante\PageFilterFormBundle\AndantePageFilterFormBundle::class => ['all' => true],
Symandy\DatabaseBackupBundle\SymandyDatabaseBackupBundle::class => ['all' => true],
ACSEO\TypesenseBundle\ACSEOTypesenseBundle::class => ['all' => true],
ACSEO\TypesenseBundle\ACSEOTypesenseBundle::class => ['all'=> true],
];
2 changes: 1 addition & 1 deletion config/packages/acseo_typesense.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -43,4 +43,4 @@ acseo_typesense:
finder_parameters:
query_by: title,serie,publisher,extension,authors,tags
limit: 18
num_typos: 2
num_typos: 2
Empty file added data/database.sqlite
Empty file.
2 changes: 1 addition & 1 deletion src/Twig/Components/AddBookToShelf.php
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,7 @@ public function remove(EntityManagerInterface $entityManager, #[LiveArg] int $sh
$shelf = $shelfRepository->find($shelfId);

if (null === $shelf) {
throw new RuntimeException('Shelf not found');
throw new \RuntimeException('Shelf not found');
}

$this->book->removeShelf($shelf);
Expand Down
2 changes: 1 addition & 1 deletion src/Twig/UniqueIdExtension.php
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@

class UniqueIdExtension extends AbstractExtension
{
public function getFunctions()
public function getFunctions(): array
{
return [
new TwigFunction('unique_id', [$this, 'uniqueID']),
Expand Down
11 changes: 7 additions & 4 deletions tests/GedmoTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,11 @@
use App\Entity\Book;
use Doctrine\ORM\EntityManagerInterface;
use Symfony\Bundle\FrameworkBundle\Test\KernelTestCase;

class GedmoTest extends KernelTestCase
{
protected function setUp(): void{
protected function setUp(): void
{
self::bootKernel();

/** @var EntityManagerInterface $entityManager */
Expand All @@ -16,7 +18,8 @@ protected function setUp(): void{
$entityManager->getConnection()->executeQuery("DELETE FROM book");
}

public function testTimestamp(): void{
public function testTimestamp(): void
{

/** @var EntityManagerInterface $entityManager */
$entityManager = self::getContainer()->get('doctrine.orm.entity_manager');
Expand All @@ -34,6 +37,6 @@ public function testTimestamp(): void{
self::assertNotNull($book->getCreated(), 'The created date should be set by Doctrine Extensions');
self::assertNotNull($book->getUpdated(), 'The updated date should be set by Doctrine Extensions');

}
}

}
}
Loading