mirror of
https://github.com/codeigniter4/CodeIgniter4.git
synced 2025-02-20 11:44:28 +08:00
Merge pull request #7509 from kenjis/test-db-getVersion
fix: PostgreSQL getVersion() output
This commit is contained in:
commit
dee68ccf70
@ -133,7 +133,9 @@ class Connection extends BaseConnection
|
||||
}
|
||||
|
||||
$pgVersion = pg_version($this->connID);
|
||||
$this->dataCache['version'] = $pgVersion['server'] ?? '';
|
||||
$this->dataCache['version'] = isset($pgVersion['server']) ?
|
||||
(preg_match('/^(\d+\.\d+)/', $pgVersion['server'], $matches) ? $matches[1] : '') :
|
||||
'';
|
||||
|
||||
return $this->dataCache['version'];
|
||||
}
|
||||
|
34
tests/system/Database/Live/GetVersionTest.php
Normal file
34
tests/system/Database/Live/GetVersionTest.php
Normal file
@ -0,0 +1,34 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* This file is part of CodeIgniter 4 framework.
|
||||
*
|
||||
* (c) CodeIgniter Foundation <admin@codeigniter.com>
|
||||
*
|
||||
* For the full copyright and license information, please view
|
||||
* the LICENSE file that was distributed with this source code.
|
||||
*/
|
||||
|
||||
namespace CodeIgniter\Database\Live;
|
||||
|
||||
use CodeIgniter\Test\CIUnitTestCase;
|
||||
use CodeIgniter\Test\DatabaseTestTrait;
|
||||
|
||||
/**
|
||||
* @group DatabaseLive
|
||||
*
|
||||
* @internal
|
||||
*/
|
||||
final class GetVersionTest extends CIUnitTestCase
|
||||
{
|
||||
use DatabaseTestTrait;
|
||||
|
||||
protected $migrate = false;
|
||||
|
||||
public function testGetVersion()
|
||||
{
|
||||
$version = $this->db->getVersion();
|
||||
|
||||
$this->assertMatchesRegularExpression('/\A\d+(\.\d+)*\z/', $version);
|
||||
}
|
||||
}
|
Loading…
x
Reference in New Issue
Block a user