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

feat: added more versions to check #121

Open
wants to merge 11 commits into
base: master
Choose a base branch
from
Open
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
14 changes: 7 additions & 7 deletions .github/workflows/tests.yml
Original file line number Diff line number Diff line change
@@ -1,22 +1,22 @@
name: PHP Tests
on: [push, pull_request]
on: [ push, pull_request ]
jobs:
build:
runs-on: ubuntu-latest

strategy:
matrix:
php: [ '8.2' ]
mysql-version: [ '5.7', '8.0', '8.4' ]
matrix:
php: [ '8.2', '8.3', '8.4' ]
mysql-version: [ 'mysql:5.5' ]

services:
mysql:
image: "mysql:${{ matrix.mysql-version }}"
image: "${{ matrix.mysql-version }}"
env:
MYSQL_ROOT_PASSWORD: root
MYSQL_DATABASE: mysqlreplication_test
ports:
- 3306/tcp
- 3310:3306

steps:
- name: Checkout
Expand Down Expand Up @@ -51,4 +51,4 @@ jobs:
run: composer install --prefer-dist --no-progress --no-suggest

- name: Run tests
run: vendor/bin/phpunit --coverage-text
run: MYSQL_PORT=3310 vendor/bin/phpunit --coverage-text
14 changes: 14 additions & 0 deletions src/MySQLReplication/Tools.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
<?php

declare(strict_types=1);

namespace MySQLReplication;

class Tools
{
public static function getFromEnv(string $name, null|int|string $default = null): null|int|string
{
$value = getenv($name) ?: null;
return $value ?? $default;
}
}
5 changes: 4 additions & 1 deletion tests/Integration/BaseCase.php
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@
use MySQLReplication\Event\DTO\RotateDTO;
use MySQLReplication\Event\DTO\TableMapDTO;
use MySQLReplication\MySQLReplicationFactory;
use MySQLReplication\Tools;
use PHPUnit\Framework\TestCase;
use RuntimeException;

Expand All @@ -40,11 +41,13 @@ protected function setUp(): void
->withUser('root')
->withHost('0.0.0.0')
->withPassword('root')
->withPort(3306)
->withPort((int)Tools::getFromEnv('MYSQL_PORT', 3306))
->withEventsIgnore($this->getIgnoredEvents());

$this->connect();

var_dump($this->mySQLReplicationFactory?->getServerInfo(), $this->configBuilder->build());

if ($this->mySQLReplicationFactory?->getServerInfo()->versionRevision >= 8 && $this->mySQLReplicationFactory?->getServerInfo()->isGeneric()) {
self::assertInstanceOf(RotateDTO::class, $this->getEvent());
}
Expand Down
Loading