Skip to content

Commit b9552b9

Browse files
feat: add Oracle database support with corresponding test classes for improved functionality. (#62)
1 parent e37c93f commit b9552b9

13 files changed

+241
-4
lines changed

.github/workflows/build-oracle.yml

Lines changed: 43 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,43 @@
1+
on:
2+
pull_request:
3+
paths-ignore:
4+
- 'docs/**'
5+
- 'README.md'
6+
- 'CHANGELOG.md'
7+
- '.gitignore'
8+
- '.gitattributes'
9+
10+
push:
11+
paths-ignore:
12+
- 'docs/**'
13+
- 'README.md'
14+
- 'CHANGELOG.md'
15+
- '.gitignore'
16+
- '.gitattributes'
17+
18+
name: build-oracle
19+
20+
jobs:
21+
oracle:
22+
name: Oracle tests.
23+
uses: php-forge/actions/.github/workflows/phpunit-database.yml@main
24+
secrets:
25+
CODECOV_TOKEN: ${{ secrets.CODECOV_TOKEN }}
26+
with:
27+
concurrency-group: oracle-${{ github.ref }}
28+
database-env: |
29+
{
30+
"ORACLE_DATABASE": "yiitest",
31+
"ORACLE_PASSWORD": "root"
32+
}
33+
database-health-cmd: "healthcheck.sh"
34+
database-health-retries: 10
35+
database-image: gvenzl/oracle-free
36+
database-port: 1521
37+
database-type: oci
38+
database-versions: '["23"]'
39+
enable-concurrency: true
40+
extensions: pdo, pdo_oci
41+
os: '["ubuntu-latest"]'
42+
php-version: '["8.4"]'
43+
phpunit-group: oci

tests/TestCase.php

Lines changed: 11 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -178,11 +178,18 @@ protected function createDatabase(): void
178178
$command->dropTable('multiple_tree')->execute();
179179
}
180180

181+
$primaryKey = $this->driverName === 'oci'
182+
? 'NUMBER GENERATED BY DEFAULT AS IDENTITY PRIMARY KEY'
183+
: $this->primaryKey()->notNull();
184+
$name = $this->driverName === 'oci'
185+
? $this->string()->notNull()
186+
: $this->text()->notNull();
187+
181188
$command->createTable(
182189
'tree',
183190
[
184-
'id' => $this->primaryKey()->notNull(),
185-
'name' => $this->text()->notNull(),
191+
'id' => $primaryKey,
192+
'name' => $name,
186193
'lft' => $this->integer()->notNull(),
187194
'rgt' => $this->integer()->notNull(),
188195
'depth' => $this->integer()->notNull(),
@@ -192,9 +199,9 @@ protected function createDatabase(): void
192199
$command->createTable(
193200
'multiple_tree',
194201
[
195-
'id' => $this->primaryKey()->notNull(),
202+
'id' => $primaryKey,
196203
'tree' => $this->integer(),
197-
'name' => $this->text()->notNull(),
204+
'name' => $name,
198205
'lft' => $this->integer()->notNull(),
199206
'rgt' => $this->integer()->notNull(),
200207
'depth' => $this->integer()->notNull(),
Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
<?php
2+
3+
declare(strict_types=1);
4+
5+
namespace yii2\extensions\nestedsets\tests\oracle;
6+
7+
use PHPUnit\Framework\Attributes\Group;
8+
use yii2\extensions\nestedsets\tests\base\AbstractCacheManagement;
9+
10+
#[Group('oci')]
11+
final class CacheManagementTest extends AbstractCacheManagement
12+
{
13+
protected string $driverName = 'oci';
14+
protected string|null $dsn = 'oci:dbname=localhost/FREEPDB1;charset=AL32UTF8;';
15+
protected string $password = 'root';
16+
protected string $username = 'system';
17+
}
Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
<?php
2+
3+
declare(strict_types=1);
4+
5+
namespace yii2\extensions\nestedsets\tests\oracle;
6+
7+
use PHPUnit\Framework\Attributes\Group;
8+
use yii2\extensions\nestedsets\tests\base\AbstractExceptionHandling;
9+
10+
#[Group('oci')]
11+
final class ExceptionHandlingTest extends AbstractExceptionHandling
12+
{
13+
protected string $driverName = 'oci';
14+
protected string|null $dsn = 'oci:dbname=localhost/FREEPDB1;charset=AL32UTF8;';
15+
protected string $password = 'root';
16+
protected string $username = 'system';
17+
}

tests/oracle/ExtensibilityTest.php

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
<?php
2+
3+
declare(strict_types=1);
4+
5+
namespace yii2\extensions\nestedsets\tests\oracle;
6+
7+
use PHPUnit\Framework\Attributes\Group;
8+
use yii2\extensions\nestedsets\tests\base\AbstractExtensibility;
9+
10+
#[Group('oci')]
11+
final class ExtensibilityTest extends AbstractExtensibility
12+
{
13+
protected string $driverName = 'oci';
14+
protected string|null $dsn = 'oci:dbname=localhost/FREEPDB1;charset=AL32UTF8;';
15+
protected string $password = 'root';
16+
protected string $username = 'system';
17+
}

tests/oracle/NodeAppendTest.php

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
<?php
2+
3+
declare(strict_types=1);
4+
5+
namespace yii2\extensions\nestedsets\tests\oracle;
6+
7+
use PHPUnit\Framework\Attributes\Group;
8+
use yii2\extensions\nestedsets\tests\base\AbstractNodeAppend;
9+
10+
#[Group('oci')]
11+
final class NodeAppendTest extends AbstractNodeAppend
12+
{
13+
protected string $driverName = 'oci';
14+
protected string|null $dsn = 'oci:dbname=localhost/FREEPDB1;charset=AL32UTF8;';
15+
protected string $password = 'root';
16+
protected string $username = 'system';
17+
}

tests/oracle/NodeDeleteTest.php

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
<?php
2+
3+
declare(strict_types=1);
4+
5+
namespace yii2\extensions\nestedsets\tests\oracle;
6+
7+
use PHPUnit\Framework\Attributes\Group;
8+
use yii2\extensions\nestedsets\tests\base\AbstractNodeDelete;
9+
10+
#[Group('oci')]
11+
final class NodeDeleteTest extends AbstractNodeDelete
12+
{
13+
protected string $driverName = 'oci';
14+
protected string|null $dsn = 'oci:dbname=localhost/FREEPDB1;charset=AL32UTF8;';
15+
protected string $password = 'root';
16+
protected string $username = 'system';
17+
}

tests/oracle/NodeInsertTest.php

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
<?php
2+
3+
declare(strict_types=1);
4+
5+
namespace yii2\extensions\nestedsets\tests\oracle;
6+
7+
use PHPUnit\Framework\Attributes\Group;
8+
use yii2\extensions\nestedsets\tests\base\AbstractNodeInsert;
9+
10+
#[Group('oci')]
11+
final class NodeInsertTest extends AbstractNodeInsert
12+
{
13+
protected string $driverName = 'oci';
14+
protected string|null $dsn = 'oci:dbname=localhost/FREEPDB1;charset=AL32UTF8;';
15+
protected string $password = 'root';
16+
protected string $username = 'system';
17+
}

tests/oracle/NodePrependTest.php

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
<?php
2+
3+
declare(strict_types=1);
4+
5+
namespace yii2\extensions\nestedsets\tests\oracle;
6+
7+
use PHPUnit\Framework\Attributes\Group;
8+
use yii2\extensions\nestedsets\tests\base\AbstractNodePrepend;
9+
10+
#[Group('oci')]
11+
final class NodePrependTest extends AbstractNodePrepend
12+
{
13+
protected string $driverName = 'oci';
14+
protected string|null $dsn = 'oci:dbname=localhost/FREEPDB1;charset=AL32UTF8;';
15+
protected string $password = 'root';
16+
protected string $username = 'system';
17+
}

tests/oracle/NodeStateTest.php

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
<?php
2+
3+
declare(strict_types=1);
4+
5+
namespace yii2\extensions\nestedsets\tests\oracle;
6+
7+
use PHPUnit\Framework\Attributes\Group;
8+
use yii2\extensions\nestedsets\tests\base\AbstractNodeState;
9+
10+
#[Group('oci')]
11+
final class NodeStateTest extends AbstractNodeState
12+
{
13+
protected string $driverName = 'oci';
14+
protected string|null $dsn = 'oci:dbname=localhost/FREEPDB1;charset=AL32UTF8;';
15+
protected string $password = 'root';
16+
protected string $username = 'system';
17+
}

0 commit comments

Comments
 (0)