Skip to content

Commit

Permalink
Test MariaDB
Browse files Browse the repository at this point in the history
  • Loading branch information
staudenmeir committed Jan 4, 2022
1 parent 9b65000 commit 747c034
Show file tree
Hide file tree
Showing 12 changed files with 117 additions and 41 deletions.
22 changes: 20 additions & 2 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -9,9 +9,19 @@ jobs:
strategy:
matrix:
php: [8.1, 8.0, 7.4, 7.3]
database: [mysql, pgsql, sqlite, sqlsrv]
database: [mysql, mariadb, pgsql, sqlite, sqlsrv]
release: [stable, lowest]
include:
- database: mysql
pdo: mysql
- database: mariadb
pdo: mysql
- database: pgsql
pdo: pgsql
- database: sqlite
pdo: sqlite
- database: sqlsrv
pdo: sqlsrv
- php: 8.0
release: stable
coverage: xdebug
Expand All @@ -24,6 +34,13 @@ jobs:
MYSQL_DATABASE: test
ports:
- 3306
mariadb:
image: mariadb:latest
env:
MYSQL_ROOT_PASSWORD: password
MYSQL_DATABASE: test
ports:
- 3306
pgsql:
image: postgres:latest
env:
Expand Down Expand Up @@ -55,7 +72,7 @@ jobs:
with:
php-version: ${{ matrix.php }}
tools: pecl
extensions: bcmath, ctype, json, mbstring, openssl, pdo, pdo_${{ matrix.database }}, tokenizer, xml
extensions: bcmath, ctype, json, mbstring, openssl, pdo, pdo_${{ matrix.pdo }}, tokenizer, xml
coverage: ${{ matrix.coverage }}
- run: |
mysql -h 127.0.0.1 --port ${{ job.services.mysql.ports[3306] }} -u root -ppassword -e "ALTER USER 'root'@'%' IDENTIFIED WITH mysql_native_password BY 'password'"
Expand All @@ -71,6 +88,7 @@ jobs:
env:
DATABASE: ${{ matrix.database }}
MYSQL_PORT: ${{ job.services.mysql.ports[3306] }}
MARIADB_PORT: ${{ job.services.mariadb.ports[3306] }}
PGSQL_PORT: ${{ job.services.pgsql.ports[5432] }}
SQLSRV_PORT: ${{ job.services.sqlsrv.ports[1433] }}
- run: php tests/coverage/scrutinizer.php
Expand Down
2 changes: 1 addition & 1 deletion .scrutinizer.yml
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
tools:
external_code_coverage:
runs: 4
runs: 5
timeout: 600
13 changes: 8 additions & 5 deletions tests/AncestorsTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@

namespace Tests;

use Illuminate\Database\Capsule\Manager as DB;
use Tests\Models\User;

class AncestorsTest extends TestCase
Expand Down Expand Up @@ -86,7 +85,7 @@ public function testLazyEagerLoadingAndSelf()

public function testExistenceQuery()
{
if (DB::connection()->getDriverName() === 'sqlsrv') {
if (in_array($this->database, ['mariadb', 'sqlsrv'])) {
$this->markTestSkipped();
}

Expand All @@ -97,7 +96,7 @@ public function testExistenceQuery()

public function testExistenceQueryAndSelf()
{
if (DB::connection()->getDriverName() === 'sqlsrv') {
if (in_array($this->database, ['mariadb', 'sqlsrv'])) {
$this->markTestSkipped();
}

Expand All @@ -108,7 +107,7 @@ public function testExistenceQueryAndSelf()

public function testExistenceQueryForSelfRelation()
{
if (DB::connection()->getDriverName() === 'sqlsrv') {
if (in_array($this->database, ['mariadb', 'sqlsrv'])) {
$this->markTestSkipped();
}

Expand All @@ -119,7 +118,7 @@ public function testExistenceQueryForSelfRelation()

public function testExistenceQueryForSelfRelationAndSelf()
{
if (DB::connection()->getDriverName() === 'sqlsrv') {
if (in_array($this->database, ['mariadb', 'sqlsrv'])) {
$this->markTestSkipped();
}

Expand All @@ -130,6 +129,10 @@ public function testExistenceQueryForSelfRelationAndSelf()

public function testUpdate()
{
if ($this->database === 'mariadb') {
$this->markTestSkipped();
}

$affected = User::find(8)->ancestors()->update(['parent_id' => 12]);

$this->assertEquals(3, $affected);
Expand Down
17 changes: 12 additions & 5 deletions tests/BelongsToManyOfDescendantsTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@

namespace Tests;

use Illuminate\Database\Capsule\Manager as DB;
use Illuminate\Database\Eloquent\SoftDeletingScope;
use Staudenmeir\LaravelAdjacencyList\Eloquent\Relations\BelongsToManyOfDescendants;
use Tests\Models\Role;
Expand Down Expand Up @@ -79,7 +78,7 @@ public function testLazyEagerLoadingAndSelf()

public function testExistenceQuery()
{
if (DB::connection()->getDriverName() === 'sqlsrv') {
if (in_array($this->database, ['mariadb', 'sqlsrv'])) {
$this->markTestSkipped();
}

Expand All @@ -90,7 +89,7 @@ public function testExistenceQuery()

public function testExistenceQueryAndSelf()
{
if (DB::connection()->getDriverName() === 'sqlsrv') {
if (in_array($this->database, ['mariadb', 'sqlsrv'])) {
$this->markTestSkipped();
}

Expand All @@ -101,7 +100,7 @@ public function testExistenceQueryAndSelf()

public function testExistenceQueryForSelfRelation()
{
if (DB::connection()->getDriverName() === 'sqlsrv') {
if (in_array($this->database, ['mariadb', 'sqlsrv'])) {
$this->markTestSkipped();
}

Expand All @@ -112,7 +111,7 @@ public function testExistenceQueryForSelfRelation()

public function testExistenceQueryForSelfRelationAndSelf()
{
if (DB::connection()->getDriverName() === 'sqlsrv') {
if (in_array($this->database, ['mariadb', 'sqlsrv'])) {
$this->markTestSkipped();
}

Expand All @@ -123,6 +122,10 @@ public function testExistenceQueryForSelfRelationAndSelf()

public function testDelete()
{
if ($this->database === 'mariadb') {
$this->markTestSkipped();
}

$affected = User::find(1)->roles()->delete();

$this->assertEquals(7, $affected);
Expand All @@ -132,6 +135,10 @@ public function testDelete()

public function testDeleteAndSelf()
{
if ($this->database === 'mariadb') {
$this->markTestSkipped();
}

$affected = User::find(1)->rolesAndSelf()->delete();

$this->assertEquals(8, $affected);
Expand Down
9 changes: 6 additions & 3 deletions tests/BloodlineTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@

namespace Tests;

use Illuminate\Database\Capsule\Manager as DB;
use Staudenmeir\LaravelAdjacencyList\Eloquent\Relations\Bloodline;
use Tests\Models\User;

Expand Down Expand Up @@ -54,7 +53,7 @@ public function testLazyEagerLoading()

public function testExistenceQuery()
{
if (DB::connection()->getDriverName() === 'sqlsrv') {
if (in_array($this->database, ['mariadb', 'sqlsrv'])) {
$this->markTestSkipped();
}

Expand All @@ -65,7 +64,7 @@ public function testExistenceQuery()

public function testExistenceQueryForSelfRelation()
{
if (DB::connection()->getDriverName() === 'sqlsrv') {
if (in_array($this->database, ['mariadb', 'sqlsrv'])) {
$this->markTestSkipped();
}

Expand All @@ -76,6 +75,10 @@ public function testExistenceQueryForSelfRelation()

public function testUpdate()
{
if ($this->database === 'mariadb') {
$this->markTestSkipped();
}

$affected = User::find(5)->bloodline()->delete();

$this->assertEquals(4, $affected);
Expand Down
13 changes: 8 additions & 5 deletions tests/DescendantsTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@

namespace Tests;

use Illuminate\Database\Capsule\Manager as DB;
use Staudenmeir\LaravelAdjacencyList\Eloquent\Relations\Descendants;
use Tests\Models\User;

Expand Down Expand Up @@ -88,7 +87,7 @@ public function testLazyEagerLoadingAndSelf()

public function testExistenceQuery()
{
if (DB::connection()->getDriverName() === 'sqlsrv') {
if (in_array($this->database, ['mariadb', 'sqlsrv'])) {
$this->markTestSkipped();
}

Expand All @@ -99,7 +98,7 @@ public function testExistenceQuery()

public function testExistenceQueryAndSelf()
{
if (DB::connection()->getDriverName() === 'sqlsrv') {
if (in_array($this->database, ['mariadb', 'sqlsrv'])) {
$this->markTestSkipped();
}

Expand All @@ -110,7 +109,7 @@ public function testExistenceQueryAndSelf()

public function testExistenceQueryForSelfRelation()
{
if (DB::connection()->getDriverName() === 'sqlsrv') {
if (in_array($this->database, ['mariadb', 'sqlsrv'])) {
$this->markTestSkipped();
}

Expand All @@ -121,7 +120,7 @@ public function testExistenceQueryForSelfRelation()

public function testExistenceQueryForSelfRelationAndSelf()
{
if (DB::connection()->getDriverName() === 'sqlsrv') {
if (in_array($this->database, ['mariadb', 'sqlsrv'])) {
$this->markTestSkipped();
}

Expand All @@ -132,6 +131,10 @@ public function testExistenceQueryForSelfRelationAndSelf()

public function testUpdate()
{
if ($this->database === 'mariadb') {
$this->markTestSkipped();
}

$affected = User::find(1)->descendants()->update(['parent_id' => 12]);

$this->assertEquals(8, $affected);
Expand Down
17 changes: 12 additions & 5 deletions tests/HasManyOfDescendantsTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@

namespace Tests;

use Illuminate\Database\Capsule\Manager as DB;
use Illuminate\Database\Eloquent\SoftDeletingScope;
use Staudenmeir\LaravelAdjacencyList\Eloquent\Relations\HasManyOfDescendants;
use Tests\Models\Post;
Expand Down Expand Up @@ -86,7 +85,7 @@ public function testLazyEagerLoadingAndSelf()

public function testExistenceQuery()
{
if (DB::connection()->getDriverName() === 'sqlsrv') {
if (in_array($this->database, ['mariadb', 'sqlsrv'])) {
$this->markTestSkipped();
}

Expand All @@ -97,7 +96,7 @@ public function testExistenceQuery()

public function testExistenceQueryAndSelf()
{
if (DB::connection()->getDriverName() === 'sqlsrv') {
if (in_array($this->database, ['mariadb', 'sqlsrv'])) {
$this->markTestSkipped();
}

Expand All @@ -108,7 +107,7 @@ public function testExistenceQueryAndSelf()

public function testExistenceQueryForSelfRelation()
{
if (DB::connection()->getDriverName() === 'sqlsrv') {
if (in_array($this->database, ['mariadb', 'sqlsrv'])) {
$this->markTestSkipped();
}

Expand All @@ -119,7 +118,7 @@ public function testExistenceQueryForSelfRelation()

public function testExistenceQueryForSelfRelationAndSelf()
{
if (DB::connection()->getDriverName() === 'sqlsrv') {
if (in_array($this->database, ['mariadb', 'sqlsrv'])) {
$this->markTestSkipped();
}

Expand All @@ -130,6 +129,10 @@ public function testExistenceQueryForSelfRelationAndSelf()

public function testUpdate()
{
if ($this->database === 'mariadb') {
$this->markTestSkipped();
}

$affected = User::find(1)->posts()->update(['user_id' => 11]);

$this->assertEquals(7, $affected);
Expand All @@ -139,6 +142,10 @@ public function testUpdate()

public function testUpdateAndSelf()
{
if ($this->database === 'mariadb') {
$this->markTestSkipped();
}

$affected = User::find(1)->postsAndSelf()->update(['user_id' => 11]);

$this->assertEquals(8, $affected);
Expand Down
Loading

0 comments on commit 747c034

Please sign in to comment.