File tree Expand file tree Collapse file tree
tests/system/Database/Live Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -133,7 +133,9 @@ public function getVersion(): string
133133 }
134134
135135 $ pgVersion = pg_version ($ this ->connID );
136- $ this ->dataCache ['version ' ] = $ pgVersion ['server ' ] ?? '' ;
136+ $ this ->dataCache ['version ' ] = isset ($ pgVersion ['server ' ]) ?
137+ (preg_match ('/^(\d+\.\d+)/ ' , $ pgVersion ['server ' ], $ matches ) ? $ matches [1 ] : '' ) :
138+ '' ;
137139
138140 return $ this ->dataCache ['version ' ];
139141 }
Original file line number Diff line number Diff line change 1+ <?php
2+
3+ /**
4+ * This file is part of CodeIgniter 4 framework.
5+ *
6+ * (c) CodeIgniter Foundation <admin@codeigniter.com>
7+ *
8+ * For the full copyright and license information, please view
9+ * the LICENSE file that was distributed with this source code.
10+ */
11+
12+ namespace CodeIgniter \Database \Live ;
13+
14+ use CodeIgniter \Test \CIUnitTestCase ;
15+ use CodeIgniter \Test \DatabaseTestTrait ;
16+
17+ /**
18+ * @group DatabaseLive
19+ *
20+ * @internal
21+ */
22+ final class GetVersionTest extends CIUnitTestCase
23+ {
24+ use DatabaseTestTrait;
25+
26+ protected $ migrate = false ;
27+
28+ public function testGetVersion ()
29+ {
30+ $ version = $ this ->db ->getVersion ();
31+
32+ $ this ->assertMatchesRegularExpression ('/\A\d+(\.\d+)*\z/ ' , $ version );
33+ }
34+ }
You can’t perform that action at this time.
0 commit comments