Skip to content
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
43 changes: 39 additions & 4 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,7 @@ jobs:
run: vendor/bin/php-cs-fixer fix --ansi

phpunit:
name: PHPUnit (PHP ${{ matrix.php }})
name: PHPUnit (PHP ${{ matrix.php }}, ${{ matrix.database }})
runs-on: ubuntu-24.04
container:
image: php:${{ matrix.php }}-alpine
Expand All @@ -98,6 +98,19 @@ jobs:
--health-retries 5
ports:
- 3306:3306
postgres:
image: postgres:17-alpine
env:
POSTGRES_DB: davis_test
POSTGRES_USER: davis
POSTGRES_PASSWORD: davis
options: >-
--health-cmd pg_isready
--health-interval 10s
--health-timeout 5s
--health-retries 5
ports:
- 5432:5432

strategy:
matrix:
Expand All @@ -106,6 +119,10 @@ jobs:
- '8.3'
- '8.4'
- '8.5'
database:
- mysql
- postgresql
- sqlite
fail-fast: false

steps:
Expand All @@ -120,19 +137,37 @@ jobs:
docker-php-ext-configure zip
# ext-ldap is optional for Davis (only AUTH_METHOD=LDAP needs it) but the LDAP tests
# skip themselves without it, and we would rather run them
docker-php-ext-install pdo pdo_mysql intl gd zip ldap
apk add postgresql-dev sqlite-dev
docker-php-ext-install pdo pdo_mysql pdo_pgsql pdo_sqlite intl gd zip ldap

- name: Install Composer
run: wget -qO - https://getcomposer.org/installer | php -- --install-dir=/usr/local/bin --filename=composer --quiet

- name: Install dependencies with Composer
run: composer install --no-progress --no-interaction --ansi

- name: Run tests with PHPUnit
# The three engines differ in ways the suite has to see: SQLite enforces neither foreign
# keys nor column lengths, and PostgreSQL rejects writes MySQL accepts. The test database is
# built by the migrations (see tests/bootstrap.php), so this also covers the schema an
# install actually gets.
- name: Run tests with PHPUnit (MySQL)
if: matrix.database == 'mysql'
env:
DATABASE_URL: mysql://davis:davis@mysql:3306/davis_test
run: vendor/bin/phpunit --process-isolation --colors=always

- name: Run tests with PHPUnit (PostgreSQL)
if: matrix.database == 'postgresql'
env:
DATABASE_URL: postgresql://davis:davis@postgres:5432/davis_test?serverVersion=17&charset=utf8
run: vendor/bin/phpunit --process-isolation --colors=always

- name: Run tests with PHPUnit (SQLite)
if: matrix.database == 'sqlite'
env:
DATABASE_URL: sqlite:///%kernel.project_dir%/var/data_test.db
run: vendor/bin/phpunit --process-isolation --colors=always

migrations:
name: Migrations (${{ matrix.database }})
runs-on: ubuntu-24.04
Expand Down Expand Up @@ -220,7 +255,7 @@ jobs:
run: |
php bin/console doctrine:database:create --if-not-exists --env=test
php bin/console doctrine:migrations:migrate --no-interaction --env=test
php bin/console doctrine:schema:validate --skip-sync --env=test
php bin/console doctrine:schema:validate --env=test
Comment on lines -223 to +258

Copy link
Copy Markdown
Owner Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

no more needed because we have IDENTITY now on PG

# An empty schema only proves the DDL is valid. Seed the kind of row a DAV client
# creates (optional columns left NULL) so the rollback is exercised against data too.
php bin/console dbal:run-sql "INSERT INTO addressbooks (id, principaluri, uri, synctoken) VALUES (nextval('addressbooks_id_seq'), 'principals/ci', 'ci-rollback-probe', 1)" --env=test
Expand Down
2 changes: 1 addition & 1 deletion src/Entity/AddressBook.php
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
class AddressBook
{
#[ORM\Id]
#[ORM\GeneratedValue]
#[ORM\GeneratedValue(strategy: 'IDENTITY')]
#[ORM\Column(type: 'integer')]
private $id;

Expand Down
2 changes: 1 addition & 1 deletion src/Entity/AddressBookChange.php
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
class AddressBookChange
{
#[ORM\Id]
#[ORM\GeneratedValue]
#[ORM\GeneratedValue(strategy: 'IDENTITY')]
#[ORM\Column(type: 'integer')]
private $id;

Expand Down
2 changes: 1 addition & 1 deletion src/Entity/Calendar.php
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ class Calendar
public const COMPONENT_NOTES = 'VJOURNAL';

#[ORM\Id]
#[ORM\GeneratedValue]
#[ORM\GeneratedValue(strategy: 'IDENTITY')]
#[ORM\Column(type: 'integer')]
private $id;

Expand Down
2 changes: 1 addition & 1 deletion src/Entity/CalendarChange.php
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
class CalendarChange
{
#[ORM\Id]
#[ORM\GeneratedValue]
#[ORM\GeneratedValue(strategy: 'IDENTITY')]
#[ORM\Column(type: 'integer')]
private $id;

Expand Down
2 changes: 1 addition & 1 deletion src/Entity/CalendarInstance.php
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ public static function getOwnerAccesses(): array
}

#[ORM\Id]
#[ORM\GeneratedValue]
#[ORM\GeneratedValue(strategy: 'IDENTITY')]
#[ORM\Column(type: 'integer')]
private $id;

Expand Down
2 changes: 1 addition & 1 deletion src/Entity/CalendarObject.php
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
class CalendarObject
{
#[ORM\Id]
#[ORM\GeneratedValue]
#[ORM\GeneratedValue(strategy: 'IDENTITY')]
#[ORM\Column(type: 'integer')]
private $id;

Expand Down
2 changes: 1 addition & 1 deletion src/Entity/CalendarSubscription.php
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
class CalendarSubscription
{
#[ORM\Id]
#[ORM\GeneratedValue]
#[ORM\GeneratedValue(strategy: 'IDENTITY')]
#[ORM\Column(type: 'integer')]
private $id;

Expand Down
2 changes: 1 addition & 1 deletion src/Entity/Card.php
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
class Card
{
#[ORM\Id]
#[ORM\GeneratedValue]
#[ORM\GeneratedValue(strategy: 'IDENTITY')]
#[ORM\Column(type: 'integer')]
private $id;

Expand Down
2 changes: 1 addition & 1 deletion src/Entity/Lock.php
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
class Lock
{
#[ORM\Id]
#[ORM\GeneratedValue]
#[ORM\GeneratedValue(strategy: 'IDENTITY')]
#[ORM\Column(type: 'integer')]
private $id;

Expand Down
2 changes: 1 addition & 1 deletion src/Entity/Principal.php
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ class Principal
public const WRITE_PROXY_SUFFIX = '/calendar-proxy-write';

#[ORM\Id]
#[ORM\GeneratedValue]
#[ORM\GeneratedValue(strategy: 'IDENTITY')]
#[ORM\Column(type: 'integer')]
private $id;

Expand Down
2 changes: 1 addition & 1 deletion src/Entity/PropertyStorage.php
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
class PropertyStorage
{
#[ORM\Id]
#[ORM\GeneratedValue]
#[ORM\GeneratedValue(strategy: 'IDENTITY')]
#[ORM\Column(type: 'integer')]
private $id;

Expand Down
2 changes: 1 addition & 1 deletion src/Entity/SchedulingObject.php
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
class SchedulingObject
{
#[ORM\Id]
#[ORM\GeneratedValue]
#[ORM\GeneratedValue(strategy: 'IDENTITY')]
#[ORM\Column(type: 'integer')]
private $id;

Expand Down
2 changes: 1 addition & 1 deletion src/Entity/User.php
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ class User
public const DEFAULT_AUTH_REALM = 'SabreDAV';

#[ORM\Id]
#[ORM\GeneratedValue]
#[ORM\GeneratedValue(strategy: 'IDENTITY')]
#[ORM\Column(type: 'integer')]
private $id;

Expand Down
2 changes: 2 additions & 0 deletions tests/Functional/Service/DiagnosticsTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -76,6 +76,8 @@ public function testAHealthyInstallReportsNothingToLookAt(): void
{
$diagnostics = $this->diagnosticsWith();

// The test database is built by the migrations, so none of them are pending
$this->assertSame(Diagnostics::OK, $this->severityOf($diagnostics, 'diagnostics.migrations'));
$this->assertSame(Diagnostics::OK, $this->severityOf($diagnostics, 'diagnostics.log_file'));
$this->assertSame(Diagnostics::OK, $this->severityOf($diagnostics, 'diagnostics.environment'));
$this->assertSame(Diagnostics::OK, $this->severityOf($diagnostics, 'diagnostics.timezone'));
Expand Down
12 changes: 9 additions & 3 deletions tests/bootstrap.php
Original file line number Diff line number Diff line change
Expand Up @@ -10,11 +10,17 @@
(new Dotenv())->bootEnv(dirname(__DIR__).'/.env');
}

// Create the test database, update the schema and resets the fixture before each test.
// Create the test database, build its schema and reset the fixtures before each test.
// Note: `--quiet` is needed here for each step so that PHPUnit doesn't fail.
$actions = [
'doctrine:database:create --if-not-exists ',
'doctrine:schema:update --complete --force',
// No `--if-not-exists`: it asks the platform to list its databases, which SQLite cannot do.
// Creating an existing database is a no-op here either way, the exit code is ignored below.
'doctrine:database:create',
// The schema is built by the migrations, not by `doctrine:schema:update`, so the tests run
// against the schema an install actually has. The two are not the same on PostgreSQL: DBAL
// models an identity column without its `DEFAULT nextval(...)`, and the sabre/dav backends
// INSERT without an id, so every DAV write would fail against a schema:update database.
'doctrine:migrations:migrate --no-interaction --allow-no-migration',
'doctrine:fixtures:load --no-interaction',
];

Expand Down