Skip to content

Commit c3b3943

Browse files
committed
feat: add Oracle database support with corresponding test classes for improved functionality.
1 parent e37c93f commit c3b3943

13 files changed

+236
-2
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-xe
36+
database-port: 1521
37+
database-type: oracle
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: oracle

tests/TestCase.php

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -178,10 +178,14 @@ 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+
181185
$command->createTable(
182186
'tree',
183187
[
184-
'id' => $this->primaryKey()->notNull(),
188+
'id' => $primaryKey,
185189
'name' => $this->text()->notNull(),
186190
'lft' => $this->integer()->notNull(),
187191
'rgt' => $this->integer()->notNull(),
@@ -192,7 +196,7 @@ protected function createDatabase(): void
192196
$command->createTable(
193197
'multiple_tree',
194198
[
195-
'id' => $this->primaryKey()->notNull(),
199+
'id' => $primaryKey,
196200
'tree' => $this->integer(),
197201
'name' => $this->text()->notNull(),
198202
'lft' => $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/XE;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/XE;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/XE;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/XE;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/XE;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/XE;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/XE;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/XE;charset=AL32UTF8;';
15+
protected string $password = 'root';
16+
protected string $username = 'system';
17+
}

0 commit comments

Comments
 (0)