Skip to content

Commit f93b2d1

Browse files
committed
improve
1 parent 4caebc5 commit f93b2d1

File tree

5 files changed

+15
-12
lines changed

5 files changed

+15
-12
lines changed

tests/ColumnTest.php

Lines changed: 5 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@
1616
use Yiisoft\Db\Oracle\Column\JsonColumn;
1717
use Yiisoft\Db\Oracle\Tests\Provider\ColumnProvider;
1818
use Yiisoft\Db\Oracle\Tests\Support\IntegrationTestTrait;
19+
use Yiisoft\Db\Oracle\Tests\Support\TestConnection;
1920
use Yiisoft\Db\Query\Query;
2021
use Yiisoft\Db\Schema\Column\ColumnInterface;
2122
use Yiisoft\Db\Schema\Column\DoubleColumn;
@@ -38,8 +39,7 @@ final class ColumnTest extends CommonColumnTest
3839
public function testQueryWithTypecasting(): void
3940
{
4041
$db = $this->getSharedConnection();
41-
$version = $db->getServerInfo()->getVersion();
42-
$isOldVersion = version_compare($version, '21', '<');
42+
$isOldVersion = version_compare(TestConnection::getServerVersion(), '21', '<');
4343

4444
$this->loadFixture(
4545
__DIR__ . '/Support/Fixture/'
@@ -64,8 +64,7 @@ public function testQueryWithTypecasting(): void
6464
public function testCommandWithPhpTypecasting(): void
6565
{
6666
$db = $this->getSharedConnection();
67-
$version = $db->getServerInfo()->getVersion();
68-
$isOldVersion = version_compare($version, '21', '<');
67+
$isOldVersion = version_compare(TestConnection::getServerVersion(), '21', '<');
6968

7069
$this->loadFixture(
7170
__DIR__ . '/Support/Fixture/'
@@ -136,8 +135,7 @@ public function testSelectWithPhpTypecasting(): void
136135
public function testPhpTypecast(): void
137136
{
138137
$db = $this->getSharedConnection();
139-
$version = $db->getServerInfo()->getVersion();
140-
$isOldVersion = version_compare($version, '21', '<');
138+
$isOldVersion = version_compare(TestConnection::getServerVersion(), '21', '<');
141139

142140
$this->loadFixture(
143141
__DIR__ . '/Support/Fixture/'
@@ -150,8 +148,7 @@ public function testPhpTypecast(): void
150148
public function testColumnInstance(): void
151149
{
152150
$db = $this->getSharedConnection();
153-
$version = $db->getServerInfo()->getVersion();
154-
$isOldVersion = version_compare($version, '21', '<');
151+
$isOldVersion = version_compare(TestConnection::getServerVersion(), '21', '<');
155152

156153
$this->loadFixture(
157154
__DIR__ . '/Support/Fixture/'

tests/CommandTest.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -610,7 +610,7 @@ public function testCreateSearchIndex()
610610
{
611611
$db = $this->getSharedConnection();
612612

613-
if (version_compare($db->getServerInfo()->getVersion(), '21', '<')) {
613+
if (version_compare(TestConnection::getServerVersion(), '21', '<')) {
614614
$this->markTestSkipped('Search index is supported since Oracle 21');
615615
}
616616

tests/Provider/QueryBuilderProvider.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -379,7 +379,7 @@ public static function buildColumnDefinition(): array
379379
$values['reference($reference)'][0] = 'number(10) REFERENCES "ref_table" ("id") ON DELETE SET NULL';
380380
$values['reference($referenceWithSchema)'][0] = 'number(10) REFERENCES "ref_schema"."ref_table" ("id") ON DELETE SET NULL';
381381

382-
$version = TestConnection::getShared()->getServerInfo()->getVersion();
382+
$version = TestConnection::getServerVersion();
383383
if (version_compare($version, '21', '>=')) {
384384
$values['array()'][0] = 'json';
385385
$values['structured()'][0] = 'json';

tests/SchemaTest.php

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@
1414
use Yiisoft\Db\Oracle\Schema;
1515
use Yiisoft\Db\Oracle\Tests\Provider\SchemaProvider;
1616
use Yiisoft\Db\Oracle\Tests\Support\IntegrationTestTrait;
17+
use Yiisoft\Db\Oracle\Tests\Support\TestConnection;
1718
use Yiisoft\Db\Schema\Column\ColumnInterface;
1819
use Yiisoft\Db\Tests\Common\CommonSchemaTest;
1920
use Yiisoft\Db\Tests\Support\TestHelper;
@@ -31,7 +32,7 @@ final class SchemaTest extends CommonSchemaTest
3132
public function testColumns(array $columns, string $tableName = 'type', ?string $dump = null): void
3233
{
3334
$db = $this->getSharedConnection();
34-
$version21 = version_compare($db->getServerInfo()->getVersion(), '21', '>=');
35+
$version21 = version_compare(TestConnection::getServerVersion(), '21', '>=');
3536

3637
if ($version21 && $tableName === 'type') {
3738
$dump = __DIR__ . '/Support/Fixture/oci21.sql';
@@ -93,7 +94,7 @@ public function testGetSchemaNames(): void
9394

9495
$schema = $db->getSchema();
9596

96-
if (version_compare($db->getServerInfo()->getVersion(), '12', '>')) {
97+
if (version_compare(TestConnection::getServerVersion(), '12', '>')) {
9798
$this->assertContains('SYSBACKUP', $schema->getSchemaNames());
9899
} else {
99100
$this->assertEmpty($schema->getSchemaNames());

tests/Support/TestConnection.php

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,11 @@ public static function getShared(): Connection
2121
return $db;
2222
}
2323

24+
public static function getServerVersion(): string
25+
{
26+
return self::getShared()->getServerInfo()->getVersion();
27+
}
28+
2429
public static function dsn(): string
2530
{
2631
return self::$dsn ??= (string) new Dsn(

0 commit comments

Comments
 (0)